mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
* 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
This commit is contained in:
parent
b3ebdadb2c
commit
ea4af65b72
@ -79,14 +79,13 @@ static void ResolveNodesTo(const PointerVal &FromPtr,
|
||||
if (!isa<ShadowDSNode>(FromPtr.Node)) return;
|
||||
|
||||
ShadowDSNode *Shadow = cast<ShadowDSNode>(FromPtr.Node);
|
||||
Shadow->resetCriticalMark();
|
||||
|
||||
typedef multimap<ShadowDSNode *, DSNode *> 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<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.
|
||||
delete CN;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user