diff options
Diffstat (limited to 'lib/Analysis/DataStructure/TopDownClosure.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/TopDownClosure.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index 1ceaedbe60..f4b7017b2e 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -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(©Helper), + &OldNodeMap)); ResolveCallSite(*Graph, CallSite); } } |