forked from OSchip/llvm-project
* Destroy alloca nodes when a graph gets inlined
* Add links to all subtrees when a shadow node gets resolved * Add critical node handling llvm-svn: 2001
This commit is contained in:
parent
ec414e125a
commit
b6c8c5138f
|
|
@ -79,14 +79,13 @@ static void ResolveNodesTo(const PointerVal &FromPtr,
|
||||||
if (!isa<ShadowDSNode>(FromPtr.Node)) return;
|
if (!isa<ShadowDSNode>(FromPtr.Node)) return;
|
||||||
|
|
||||||
ShadowDSNode *Shadow = cast<ShadowDSNode>(FromPtr.Node);
|
ShadowDSNode *Shadow = cast<ShadowDSNode>(FromPtr.Node);
|
||||||
|
Shadow->resetCriticalMark();
|
||||||
|
|
||||||
typedef multimap<ShadowDSNode *, DSNode *> ShadNodeMapTy;
|
typedef multimap<ShadowDSNode *, DSNode *> ShadNodeMapTy;
|
||||||
ShadNodeMapTy NodeMapping;
|
ShadNodeMapTy NodeMapping;
|
||||||
for (unsigned i = 0, e = ToVals.size(); i != e; ++i)
|
for (unsigned i = 0, e = ToVals.size(); i != e; ++i)
|
||||||
CalculateNodeMapping(Shadow, ToVals[i].Node, NodeMapping);
|
CalculateNodeMapping(Shadow, ToVals[i].Node, NodeMapping);
|
||||||
|
|
||||||
copyEdgesFromTo(Shadow, ToVals);
|
|
||||||
|
|
||||||
// Now loop through the shadow node graph, mirroring the edges in the shadow
|
// Now loop through the shadow node graph, mirroring the edges in the shadow
|
||||||
// graph onto the realized graph...
|
// graph onto the realized graph...
|
||||||
//
|
//
|
||||||
|
|
@ -94,6 +93,9 @@ static void ResolveNodesTo(const PointerVal &FromPtr,
|
||||||
E = NodeMapping.end(); I != E; ++I) {
|
E = NodeMapping.end(); I != E; ++I) {
|
||||||
DSNode *Node = I->second;
|
DSNode *Node = I->second;
|
||||||
ShadowDSNode *ShadNode = I->first;
|
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
|
// 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
|
// 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);
|
const FunctionDSGraph &NewFunction = DS.getDSGraph(F);
|
||||||
|
|
||||||
|
unsigned StartShadowNodes = ShadowNodes.size();
|
||||||
|
|
||||||
// Incorporate a copy of the called function graph into the current graph,
|
// Incorporate a copy of the called function graph into the current graph,
|
||||||
// allowing us to do local transformations to local graph to link
|
// allowing us to do local transformations to local graph to link
|
||||||
// arguments to call values, and call node to return value...
|
// arguments to call values, and call node to return value...
|
||||||
//
|
//
|
||||||
RetVals = cloneFunctionIntoSelf(NewFunction, false);
|
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!
|
} else { // We are looking at a recursive function!
|
||||||
StartNode = 0; // Arg nodes start at 0 now...
|
StartNode = 0; // Arg nodes start at 0 now...
|
||||||
RetVals = RetNode;
|
RetVals = RetNode;
|
||||||
|
|
@ -240,10 +250,30 @@ void FunctionDSGraph::computeClosure(const DataStructure &DS) {
|
||||||
|
|
||||||
// ArgNode is no longer useful, delete now!
|
// ArgNode is no longer useful, delete now!
|
||||||
delete ArgNode;
|
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<NewDSNode>(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.
|
// Now the call node is completely destructable. Eliminate it now.
|
||||||
delete CN;
|
delete CN;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue