summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DataStructure
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-09-20 16:34:13 +0000
committerChris Lattner <sabre@nondot.org>2003-09-20 16:34:13 +0000
commit04d9cb67703ad036ebe3015f57f5a31d7ce658dc (patch)
tree885d1b6987581fceafbcefa4ab102e43e42ef0b0 /llvm/lib/Analysis/DataStructure
parent36b877ae7fc1569585f929e49e6baf7f3ddbf57d (diff)
downloadbcm5719-llvm-04d9cb67703ad036ebe3015f57f5a31d7ce658dc.tar.gz
bcm5719-llvm-04d9cb67703ad036ebe3015f57f5a31d7ce658dc.zip
Switch from using CallInst's to represent call sites to using the LLVM
CallSite class. Now we can represent function calls by invoke instructions too! llvm-svn: 8629
Diffstat (limited to 'llvm/lib/Analysis/DataStructure')
-rw-r--r--llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp3
-rw-r--r--llvm/lib/Analysis/DataStructure/DataStructure.cpp4
-rw-r--r--llvm/lib/Analysis/DataStructure/DataStructureStats.cpp7
-rw-r--r--llvm/lib/Analysis/DataStructure/Local.cpp38
-rw-r--r--llvm/lib/Analysis/DataStructure/TopDownClosure.cpp6
5 files changed, 35 insertions, 23 deletions
diff --git a/llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp b/llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
index dd141f2daf6..f5d435fe45d 100644
--- a/llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
+++ b/llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
@@ -253,7 +253,8 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) {
Graph.mergeInGraph(CS, *Callee, Graph, 0);
} else {
- ActualCallees.insert(std::make_pair(&CS.getCallInst(), Callee));
+ ActualCallees.insert(std::make_pair(CS.getCallSite().getInstruction(),
+ Callee));
// Get the data structure graph for the called function.
//
diff --git a/llvm/lib/Analysis/DataStructure/DataStructure.cpp b/llvm/lib/Analysis/DataStructure/DataStructure.cpp
index 24bed38cc85..0a6fa57aa07 100644
--- a/llvm/lib/Analysis/DataStructure/DataStructure.cpp
+++ b/llvm/lib/Analysis/DataStructure/DataStructure.cpp
@@ -709,7 +709,7 @@ void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) {
// Define here to avoid including iOther.h and BasicBlock.h in DSGraph.h
Function &DSCallSite::getCaller() const {
- return *Inst->getParent()->getParent();
+ return *Site.getInstruction()->getParent()->getParent();
}
@@ -1044,7 +1044,7 @@ DSCallSite DSGraph::getCallSiteForArguments(Function &F) const {
if (isPointerType(I->getType()))
Args.push_back(getScalarMap().find(I)->second);
- return DSCallSite(*(CallInst*)0, getReturnNodeFor(F), &F, Args);
+ return DSCallSite(CallSite(), getReturnNodeFor(F), &F, Args);
}
diff --git a/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp b/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp
index 674f689a685..ffd560b2457 100644
--- a/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp
+++ b/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp
@@ -68,7 +68,7 @@ void DSGraphStats::countCallees(const Function& F) {
const std::vector<DSCallSite> &callSites = TDGraph->getFunctionCalls();
for (unsigned i = 0, N = callSites.size(); i != N; ++i)
- if (isIndirectCallee(callSites[i].getCallInst().getCalledValue())) {
+ if (isIndirectCallee(callSites[i].getCallSite().getCalledValue())) {
// This is an indirect function call
const std::vector<GlobalValue*> &Callees =
callSites[i].getCalleeNode()->getGlobals();
@@ -76,8 +76,9 @@ void DSGraphStats::countCallees(const Function& F) {
totalNumCallees += Callees.size();
++numIndirectCalls;
} else
- std::cerr << "WARNING: No callee in Function " << F.getName()
- << "at call:\n" << callSites[i].getCallInst();
+ std::cerr << "WARNING: No callee in Function '" << F.getName()
+ << "' at call: \n"
+ << *callSites[i].getCallSite().getInstruction();
}
TotalNumCallees += totalNumCallees;
diff --git a/llvm/lib/Analysis/DataStructure/Local.cpp b/llvm/lib/Analysis/DataStructure/Local.cpp
index cd81aab35f6..1b082833de5 100644
--- a/llvm/lib/Analysis/DataStructure/Local.cpp
+++ b/llvm/lib/Analysis/DataStructure/Local.cpp
@@ -7,14 +7,11 @@
#include "llvm/Analysis/DataStructure.h"
#include "llvm/Analysis/DSGraph.h"
-#include "llvm/iMemory.h"
-#include "llvm/iTerminators.h"
-#include "llvm/iPHINode.h"
-#include "llvm/iOther.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
+#include "llvm/Instructions.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Target/TargetData.h"
#include "Support/CommandLine.h"
@@ -96,11 +93,13 @@ namespace {
void visitLoadInst(LoadInst &LI);
void visitStoreInst(StoreInst &SI);
void visitCallInst(CallInst &CI);
+ void visitInvokeInst(InvokeInst &II);
void visitSetCondInst(SetCondInst &SCI) {} // SetEQ & friends are ignored
void visitFreeInst(FreeInst &FI);
void visitCastInst(CastInst &CI);
void visitInstruction(Instruction &I);
+ void visitCallSite(CallSite CS);
private:
// Helper functions used to implement the visitation functions...
@@ -405,29 +404,38 @@ void GraphBuilder::visitReturnInst(ReturnInst &RI) {
}
void GraphBuilder::visitCallInst(CallInst &CI) {
+ visitCallSite(&CI);
+}
+
+void GraphBuilder::visitInvokeInst(InvokeInst &II) {
+ visitCallSite(&II);
+}
+
+void GraphBuilder::visitCallSite(CallSite CS) {
// Set up the return value...
DSNodeHandle RetVal;
- if (isPointerType(CI.getType()))
- RetVal = getValueDest(CI);
+ Instruction *I = CS.getInstruction();
+ if (isPointerType(I->getType()))
+ RetVal = getValueDest(*I);
DSNode *Callee = 0;
- if (DisableDirectCallOpt || !isa<Function>(CI.getOperand(0)))
- Callee = getValueDest(*CI.getOperand(0)).getNode();
+ if (DisableDirectCallOpt || !isa<Function>(CS.getCalledValue()))
+ Callee = getValueDest(*CS.getCalledValue()).getNode();
std::vector<DSNodeHandle> Args;
- Args.reserve(CI.getNumOperands()-1);
+ Args.reserve(CS.arg_end()-CS.arg_begin());
// Calculate the arguments vector...
- for (unsigned i = 1, e = CI.getNumOperands(); i != e; ++i)
- if (isPointerType(CI.getOperand(i)->getType()))
- Args.push_back(getValueDest(*CI.getOperand(i)));
+ for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); I != E; ++I)
+ if (isPointerType((*I)->getType()))
+ Args.push_back(getValueDest(**I));
// Add a new function call entry...
if (Callee)
- FunctionCalls.push_back(DSCallSite(CI, RetVal, Callee, Args));
+ FunctionCalls.push_back(DSCallSite(CS, RetVal, Callee, Args));
else
- FunctionCalls.push_back(DSCallSite(CI, RetVal,
- cast<Function>(CI.getOperand(0)), Args));
+ FunctionCalls.push_back(DSCallSite(CS, RetVal, CS.getCalledFunction(),
+ Args));
}
void GraphBuilder::visitFreeInst(FreeInst &FI) {
diff --git a/llvm/lib/Analysis/DataStructure/TopDownClosure.cpp b/llvm/lib/Analysis/DataStructure/TopDownClosure.cpp
index 92a03ee2f40..13535e3f801 100644
--- a/llvm/lib/Analysis/DataStructure/TopDownClosure.cpp
+++ b/llvm/lib/Analysis/DataStructure/TopDownClosure.cpp
@@ -96,9 +96,10 @@ void TDDataStructures::ComputePostOrder(Function &F,hash_set<DSGraph*> &Visited,
const std::vector<DSCallSite> &FunctionCalls = G.getFunctionCalls();
for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) {
+ Instruction *CallI = FunctionCalls[i].getCallSite().getInstruction();
std::pair<BUDataStructures::ActualCalleesTy::const_iterator,
BUDataStructures::ActualCalleesTy::const_iterator>
- IP = ActualCallees.equal_range(&FunctionCalls[i].getCallInst());
+ IP = ActualCallees.equal_range(CallI);
for (BUDataStructures::ActualCalleesTy::const_iterator I = IP.first;
I != IP.second; ++I)
@@ -191,10 +192,11 @@ void TDDataStructures::inlineGraphIntoCallees(DSGraph &Graph) {
// Clone and merge the reachable subgraph from the call into callee's graph.
//
for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) {
+ Instruction *CallI = FunctionCalls[i].getCallSite().getInstruction();
// For each function in the invoked function list at this call site...
std::pair<BUDataStructures::ActualCalleesTy::const_iterator,
BUDataStructures::ActualCalleesTy::const_iterator>
- IP = ActualCallees.equal_range(&FunctionCalls[i].getCallInst());
+ IP = ActualCallees.equal_range(CallI);
// Multiple callees may have the same graph, so try to inline and merge
// only once for each <callSite,calleeGraph> pair, not once for each
OpenPOWER on IntegriCloud