summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-13 06:33:19 +0000
committerChris Lattner <sabre@nondot.org>2001-10-13 06:33:19 +0000
commit8cbbbef674ba632a0d0c234ea4e4da590b386bda (patch)
tree0c5c0f182885e97c7b4f2a792c7dab13a7fe7442 /llvm/lib
parentea85fe365e1a51912d15f90577e14f67beb28052 (diff)
downloadbcm5719-llvm-8cbbbef674ba632a0d0c234ea4e4da590b386bda.tar.gz
bcm5719-llvm-8cbbbef674ba632a0d0c234ea4e4da590b386bda.zip
* Add support for Invoke instructions
* Add support for indirect calls llvm-svn: 752
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/IPA/CallGraph.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/IPA/CallGraph.cpp b/llvm/lib/Analysis/IPA/CallGraph.cpp
index 87dbf2b4255..3f997a9dd40 100644
--- a/llvm/lib/Analysis/IPA/CallGraph.cpp
+++ b/llvm/lib/Analysis/IPA/CallGraph.cpp
@@ -4,6 +4,10 @@
// eventually implement call graph serialization and deserialization for
// annotation support.
//
+// This call graph represents a dynamic method invocation as a null method node.
+// A call graph may only have up to one null method node that represents all of
+// the dynamic method invocations.
+//
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/CallGraph.h"
@@ -12,6 +16,7 @@
#include "llvm/Module.h"
#include "llvm/Method.h"
#include "llvm/iOther.h"
+#include "llvm/iTerminators.h"
#include <algorithm>
using namespace cfg;
@@ -36,10 +41,13 @@ CallGraphNode *CallGraph::getNodeFor(Method *M) {
void CallGraph::addToCallGraph(Method *M) {
CallGraphNode *Node = getNodeFor(M);
- for (Method::inst_iterator II = M->inst_begin(), IE = M->inst_end();
- II != IE; ++II) {
- if (CallInst *CI = dyn_cast<CallInst>(*II))
+ for (Method::inst_iterator I = M->inst_begin(), E = M->inst_end();
+ I != E; ++I) {
+ // Dynamic calls will cause Null nodes to be created
+ if (CallInst *CI = dyn_cast<CallInst>(*I))
Node->addCalledMethod(getNodeFor(CI->getCalledMethod()));
+ else if (InvokeInst *II = dyn_cast<InvokeInst>(*I))
+ Node->addCalledMethod(getNodeFor(II->getCalledMethod()));
}
}
OpenPOWER on IntegriCloud