[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp DataStructure.cpp DataStructureStats.cpp Local.cpp TopDownClosure.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Sep 20 11:35:09 PDT 2003
Changes in directory llvm/lib/Analysis/DataStructure:
BottomUpClosure.cpp updated: 1.63 -> 1.64
DataStructure.cpp updated: 1.120 -> 1.121
DataStructureStats.cpp updated: 1.5 -> 1.6
Local.cpp updated: 1.61 -> 1.62
TopDownClosure.cpp updated: 1.53 -> 1.54
---
Log message:
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!
---
Diffs of the changes:
Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.63 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.64
--- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.63 Fri Aug 1 17:14:28 2003
+++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Sat Sep 20 11:34:11 2003
@@ -253,7 +253,8 @@
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.
//
Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.120 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.121
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.120 Thu Sep 11 13:12:35 2003
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sat Sep 20 11:34:11 2003
@@ -709,7 +709,7 @@
// 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 @@
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);
}
Index: llvm/lib/Analysis/DataStructure/DataStructureStats.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.5 llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.6
--- llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.5 Sat Sep 20 11:12:57 2003
+++ llvm/lib/Analysis/DataStructure/DataStructureStats.cpp Sat Sep 20 11:34:11 2003
@@ -68,7 +68,7 @@
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 @@
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;
Index: llvm/lib/Analysis/DataStructure/Local.cpp
diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.61 llvm/lib/Analysis/DataStructure/Local.cpp:1.62
--- llvm/lib/Analysis/DataStructure/Local.cpp:1.61 Thu Sep 11 13:12:35 2003
+++ llvm/lib/Analysis/DataStructure/Local.cpp Sat Sep 20 11:34:11 2003
@@ -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 @@
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::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) {
Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.53 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.54
--- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.53 Fri Aug 1 17:14:28 2003
+++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sat Sep 20 11:34:11 2003
@@ -96,9 +96,10 @@
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 @@
// 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
More information about the llvm-commits
mailing list