mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-01 00:33:09 +00:00
* Add support for Invoke instructions
* Add support for indirect calls git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2f004fdf18
commit
9f9e2befd0
@ -4,6 +4,10 @@
|
|||||||
// eventually implement call graph serialization and deserialization for
|
// eventually implement call graph serialization and deserialization for
|
||||||
// annotation support.
|
// 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"
|
#include "llvm/Analysis/CallGraph.h"
|
||||||
@ -12,6 +16,7 @@
|
|||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Method.h"
|
#include "llvm/Method.h"
|
||||||
#include "llvm/iOther.h"
|
#include "llvm/iOther.h"
|
||||||
|
#include "llvm/iTerminators.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace cfg;
|
using namespace cfg;
|
||||||
@ -36,10 +41,13 @@ CallGraphNode *CallGraph::getNodeFor(Method *M) {
|
|||||||
void CallGraph::addToCallGraph(Method *M) {
|
void CallGraph::addToCallGraph(Method *M) {
|
||||||
CallGraphNode *Node = getNodeFor(M);
|
CallGraphNode *Node = getNodeFor(M);
|
||||||
|
|
||||||
for (Method::inst_iterator II = M->inst_begin(), IE = M->inst_end();
|
for (Method::inst_iterator I = M->inst_begin(), E = M->inst_end();
|
||||||
II != IE; ++II) {
|
I != E; ++I) {
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(*II))
|
// Dynamic calls will cause Null nodes to be created
|
||||||
|
if (CallInst *CI = dyn_cast<CallInst>(*I))
|
||||||
Node->addCalledMethod(getNodeFor(CI->getCalledMethod()));
|
Node->addCalledMethod(getNodeFor(CI->getCalledMethod()));
|
||||||
|
else if (InvokeInst *II = dyn_cast<InvokeInst>(*I))
|
||||||
|
Node->addCalledMethod(getNodeFor(II->getCalledMethod()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user