Remove spurious caller pointer in DSCallSite.

Also add functions to access pointer argument nodes cleanly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4235 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vikram S. Adve
2002-10-20 21:41:02 +00:00
parent e80fe61a72
commit 26b98265b7
7 changed files with 52 additions and 41 deletions

View File

@ -53,14 +53,14 @@ void TDDataStructures::ResolveCallSite(DSGraph &Graph,
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 @@ void TDDataStructures::ResolveCallSite(DSGraph &Graph,
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 @@ DSGraph &TDDataStructures::calculateGraph(Function &F) {
// 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(&copyHelper),
&OldNodeMap));
ResolveCallSite(*Graph, CallSite);
}
}