[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp DataStructure.cpp Local.cpp Steensgaard.cpp TopDownClosure.cpp
Vikram Adve
vadve at cs.uiuc.edu
Sun Oct 20 16:42:00 PDT 2002
Changes in directory llvm/lib/Analysis/DataStructure:
BottomUpClosure.cpp updated: 1.19 -> 1.20
DataStructure.cpp updated: 1.27 -> 1.28
Local.cpp updated: 1.17 -> 1.18
Steensgaard.cpp updated: 1.3 -> 1.4
TopDownClosure.cpp updated: 1.10 -> 1.11
---
Log message:
Remove spurious caller pointer in DSCallSite.
Also add functions to access pointer argument nodes cleanly.
---
Diffs of the changes:
Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.19 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.20
--- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.19 Sun Oct 20 15:32:13 2002
+++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Sun Oct 20 16:41:02 2002
@@ -60,13 +60,13 @@
map<Value*, DSNodeHandle> &ValueMap) {
// Resolve all of the function arguments...
Function::aiterator AI = F.abegin();
- for (unsigned i = 2, e = Call.size(); i != e; ++i) {
+ for (unsigned i = 0, e = Call.getNumPtrArgs(); i != e; ++i) {
// Advance the argument iterator to the first pointer argument...
while (!isPointerType(AI->getType())) ++AI;
// Add the link from the argument scalar to the provided value
DSNodeHandle &NN = ValueMap[AI];
- NN.addEdgeTo(Call[i]);
+ NN.addEdgeTo(Call.getPtrArgNode(i));
++AI;
}
}
@@ -111,10 +111,6 @@
// Must be a function type, so this cast MUST succeed.
Function &FI = cast<Function>(*Callees[c]);
- // Record that this is a call site of FI.
- assert(&Call.getCaller() == &F && "Invalid caller in DSCallSite?");
- CallSites[&FI].push_back(Call);
-
if (&FI == &F) {
// Self recursion... simply link up the formal arguments with the
// actual arguments...
@@ -142,6 +138,11 @@
DEBUG(std::cerr << "\t\t[BU] Got graph for " << FI.getName()
<< " in: " << F.getName() << "\n");
+
+ // Record that the original DSCallSite was a call site of FI.
+ // This may or may not have been known when the DSCallSite was
+ // originally created.
+ CallSites[&FI].push_back(Call);
// Clone the callee's graph into the current graph, keeping
// track of where scalars in the old graph _used_ to point,
Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.27 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.28
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.27 Sun Oct 20 15:39:31 2002
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sun Oct 20 16:41:02 2002
@@ -6,6 +6,8 @@
#include "llvm/Analysis/DSGraph.h"
#include "llvm/Function.h"
+#include "llvm/BasicBlock.h"
+#include "llvm/iOther.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Target/TargetData.h"
#include "Support/STLExtras.h"
@@ -351,12 +353,15 @@
}
}
+// Define here to avoid including iOther.h and BasicBlock.h in DSGraph.h
+Function& DSCallSite::getCaller() const {
+ return * callInst->getParent()->getParent();
+}
template<typename _CopierFunction>
DSCallSite::DSCallSite(const DSCallSite& FromCall,
_CopierFunction nodeCopier)
: std::vector<DSNodeHandle>(),
- caller(&FromCall.getCaller()),
callInst(&FromCall.getCallInst()) {
reserve(FromCall.size());
@@ -547,15 +552,15 @@
// Mark stuff passed into functions calls as being incomplete...
for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) {
- DSCallSite &Args = FunctionCalls[i];
+ DSCallSite &Call = FunctionCalls[i];
// Then the return value is certainly incomplete!
- markIncompleteNode(Args.getReturnValueNode().getNode());
+ markIncompleteNode(Call.getReturnValueNode().getNode());
// The call does not make the function argument incomplete...
// All arguments to the function call are incomplete though!
- for (unsigned i = 2, e = Args.size(); i != e; ++i)
- markIncompleteNode(Args[i].getNode());
+ for (unsigned i = 0, e = Call.getNumPtrArgs(); i != e; ++i)
+ markIncompleteNode(Call.getPtrArgNode(i).getNode());
}
// Mark all of the nodes pointed to by global or cast nodes as incomplete...
Index: llvm/lib/Analysis/DataStructure/Local.cpp
diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.17 llvm/lib/Analysis/DataStructure/Local.cpp:1.18
--- llvm/lib/Analysis/DataStructure/Local.cpp:1.17 Sun Oct 20 13:07:37 2002
+++ llvm/lib/Analysis/DataStructure/Local.cpp Sun Oct 20 16:41:02 2002
@@ -356,7 +356,7 @@
void GraphBuilder::visitCallInst(CallInst &CI) {
// Add a new function call entry...
- FunctionCalls.push_back(DSCallSite(G.getFunction(), CI));
+ FunctionCalls.push_back(DSCallSite(CI));
DSCallSite &Args = FunctionCalls.back();
// Set up the return value...
Index: llvm/lib/Analysis/DataStructure/Steensgaard.cpp
diff -u llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.3 llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.4
--- llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.3 Sun Oct 20 13:07:37 2002
+++ llvm/lib/Analysis/DataStructure/Steensgaard.cpp Sun Oct 20 16:41:02 2002
@@ -91,14 +91,14 @@
RetVal.mergeWith(Call.getReturnValueNode());
// Loop over all pointer arguments, resolving them to their provided pointers
- unsigned ArgIdx = 2; // Skip retval and function to call...
+ unsigned PtrArgIdx = 0;
for (Function::aiterator AI = F->abegin(), AE = F->aend(); AI != AE; ++AI) {
std::map<Value*, DSNodeHandle>::iterator I = ValMap.find(AI);
if (I != ValMap.end()) // If its a pointer argument...
- I->second.addEdgeTo(Call[ArgIdx++]);
+ I->second.addEdgeTo(Call.getPtrArgNode(PtrArgIdx++));
}
- assert(ArgIdx == Call.size() && "Argument resolution mismatch!");
+ assert(PtrArgIdx == Call.getNumPtrArgs() && "Argument resolution mismatch!");
}
Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.10 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.11
--- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.10 Sun Oct 20 13:07:37 2002
+++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sun Oct 20 16:41:02 2002
@@ -53,14 +53,14 @@
Function &F = Graph.getFunction();
Function::aiterator AI = F.abegin();
- for (unsigned i = 2, e = CallSite.size(); i != e; ++i, ++AI) {
+ for (unsigned i = 0, e = CallSite.getNumPtrArgs(); i != e; ++i, ++AI) {
// Advance the argument iterator to the first pointer argument...
while (!DataStructureAnalysis::isPointerType(AI->getType())) ++AI;
// TD ...Merge the formal arg scalar with the actual arg node
DSNodeHandle &NodeForFormal = Graph.getNodeForValue(AI);
if (NodeForFormal.getNode())
- NodeForFormal.mergeWith(CallSite[i]);
+ NodeForFormal.mergeWith(CallSite.getPtrArgNode(i));
}
// Merge returned node in the caller with the "return" node in callee
@@ -68,6 +68,13 @@
Graph.getRetNode().mergeWith(CallSite.getReturnValueNode());
}
+
+static DSNodeHandle copyHelper(const DSNodeHandle* fromNode,
+ std::map<const DSNode*, DSNode*> *NodeMap) {
+ return DSNodeHandle((*NodeMap)[fromNode->getNode()], fromNode->getOffset());
+}
+
+
DSGraph &TDDataStructures::calculateGraph(Function &F) {
// Make sure this graph has not already been calculated, or that we don't get
// into an infinite loop with mutually recursive functions.
@@ -128,12 +135,8 @@
// Make a temporary copy of the call site, and transform the argument node
// pointers.
- DSCallSite TmpCallSite = CallSite;
- for (unsigned i = 0, e = CallSite.size(); i != e; ++i) {
- const DSNode *OldNode = TmpCallSite[i].getNode();
- TmpCallSite[i].setNode(OldNodeMap[OldNode]);
- }
-
+ DSCallSite TmpCallSite(CallSite, std::bind2nd(std::ptr_fun(©Helper),
+ &OldNodeMap));
ResolveCallSite(*Graph, CallSite);
}
}
More information about the llvm-commits
mailing list