From: Chris Lattner Date: Wed, 27 Mar 2002 19:44:33 +0000 (+0000) Subject: * Destroy alloca nodes when a graph gets inlined X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ea4af65b729eb67dbdd0a5f2be6635433230ccc6;p=oota-llvm.git * Destroy alloca nodes when a graph gets inlined * Add links to all subtrees when a shadow node gets resolved * Add critical node handling git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2001 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/DataStructure/ComputeClosure.cpp b/lib/Analysis/DataStructure/ComputeClosure.cpp index fdebfdd80b1..9fd7d607e14 100644 --- a/lib/Analysis/DataStructure/ComputeClosure.cpp +++ b/lib/Analysis/DataStructure/ComputeClosure.cpp @@ -79,14 +79,13 @@ static void ResolveNodesTo(const PointerVal &FromPtr, if (!isa(FromPtr.Node)) return; ShadowDSNode *Shadow = cast(FromPtr.Node); + Shadow->resetCriticalMark(); typedef multimap ShadNodeMapTy; ShadNodeMapTy NodeMapping; for (unsigned i = 0, e = ToVals.size(); i != e; ++i) CalculateNodeMapping(Shadow, ToVals[i].Node, NodeMapping); - copyEdgesFromTo(Shadow, ToVals); - // Now loop through the shadow node graph, mirroring the edges in the shadow // graph onto the realized graph... // @@ -94,6 +93,9 @@ static void ResolveNodesTo(const PointerVal &FromPtr, E = NodeMapping.end(); I != E; ++I) { DSNode *Node = I->second; ShadowDSNode *ShadNode = I->first; + PointerValSet PVSx; + PVSx.add(Node); + copyEdgesFromTo(ShadNode, PVSx); // Must loop over edges in the shadow graph, adding edges in the real graph // that correspond to to the edges, but are mapped into real values by the @@ -198,12 +200,20 @@ void FunctionDSGraph::computeClosure(const DataStructure &DS) { // const FunctionDSGraph &NewFunction = DS.getDSGraph(F); + unsigned StartShadowNodes = ShadowNodes.size(); + // Incorporate a copy of the called function graph into the current graph, // allowing us to do local transformations to local graph to link // arguments to call values, and call node to return value... // RetVals = cloneFunctionIntoSelf(NewFunction, false); + // Only detail is that we need to reset all of the critical shadow nodes + // in the incorporated graph, because they are now no longer critical. + // + for (unsigned i = StartShadowNodes, e = ShadowNodes.size(); i != e; ++i) + ShadowNodes[i]->resetCriticalMark(); + } else { // We are looking at a recursive function! StartNode = 0; // Arg nodes start at 0 now... RetVals = RetNode; @@ -240,10 +250,30 @@ void FunctionDSGraph::computeClosure(const DataStructure &DS) { // ArgNode is no longer useful, delete now! delete ArgNode; + } else { + ArgOffset++; // Step to the next argument... } } } + // Loop through the nodes, deleting alloc nodes in the inlined function... + // Since the memory has been released, we cannot access their pointer + // fields (with defined results at least), so it is not possible to use any + // pointers to the alloca. Drop them now, and remove the alloca's since + // they are dead (we just removed all links to them). Only do this if we + // are not self recursing though. :) + // + if (StartNode) // Don't do this if self recursing... + for (unsigned i = StartNode; i != Nodes.size(); ++i) + if (NewDSNode *NDS = dyn_cast(Nodes[i])) + if (NDS->isAllocaNode()) { + NDS->removeAllIncomingEdges(); // These edges are invalid now! + delete NDS; // Node is dead + Nodes.erase(Nodes.begin()+i); // Remove slot in Nodes array + --i; // Don't skip the next node + } + + // Now the call node is completely destructable. Eliminate it now. delete CN;