From f40f0a39bdd3846725576caf0d5a3fe261deecad Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 9 Nov 2002 22:07:02 +0000 Subject: [PATCH] eliminate the ability to remove global nodes from deadNodeElminate... for now. This slows stuff down a bit, but it should get much better before it gets any worse. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4666 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/DSGraph.h | 4 +-- include/llvm/Analysis/DataStructure/DSGraph.h | 4 +-- .../DataStructure/BottomUpClosure.cpp | 2 +- lib/Analysis/DataStructure/DataStructure.cpp | 32 +++---------------- lib/Analysis/DataStructure/Local.cpp | 2 +- lib/Analysis/DataStructure/Steensgaard.cpp | 2 +- lib/Analysis/DataStructure/TopDownClosure.cpp | 2 +- 7 files changed, 12 insertions(+), 36 deletions(-) diff --git a/include/llvm/Analysis/DSGraph.h b/include/llvm/Analysis/DSGraph.h index 1c7f77fd23f..1a4695ca2b0 100644 --- a/include/llvm/Analysis/DSGraph.h +++ b/include/llvm/Analysis/DSGraph.h @@ -135,7 +135,7 @@ public: // from the caller's graph entirely. This is only appropriate to use when // inlining graphs. // - void removeDeadNodes(bool KeepAllGlobals); + void removeDeadNodes(); // CloneFlags enum - Bits that may be passed into the cloneInto method to // specify how to clone the function graph. @@ -172,7 +172,7 @@ private: // merged with other nodes in the graph. This is used as the first step of // removeDeadNodes. // - void removeTriviallyDeadNodes(bool KeepAllGlobals = false); + void removeTriviallyDeadNodes(); }; #endif diff --git a/include/llvm/Analysis/DataStructure/DSGraph.h b/include/llvm/Analysis/DataStructure/DSGraph.h index 1c7f77fd23f..1a4695ca2b0 100644 --- a/include/llvm/Analysis/DataStructure/DSGraph.h +++ b/include/llvm/Analysis/DataStructure/DSGraph.h @@ -135,7 +135,7 @@ public: // from the caller's graph entirely. This is only appropriate to use when // inlining graphs. // - void removeDeadNodes(bool KeepAllGlobals); + void removeDeadNodes(); // CloneFlags enum - Bits that may be passed into the cloneInto method to // specify how to clone the function graph. @@ -172,7 +172,7 @@ private: // merged with other nodes in the graph. This is used as the first step of // removeDeadNodes. // - void removeTriviallyDeadNodes(bool KeepAllGlobals = false); + void removeTriviallyDeadNodes(); }; #endif diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index ade6ca68a5c..c03e1c20e71 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -154,7 +154,7 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) { if (Inlined) { Graph->maskIncompleteMarkers(); Graph->markIncompleteNodes(); - Graph->removeDeadNodes(/*KeepAllGlobals*/ true); + Graph->removeDeadNodes(); } } while (Inlined && !FCs.empty()); diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index aab344bb99c..cc43544504f 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -810,9 +810,9 @@ static void removeIdenticalCalls(vector &Calls, // other nodes in the graph. These nodes will all be trivially unreachable, so // we don't have to perform any non-trivial analysis here. // -void DSGraph::removeTriviallyDeadNodes(bool KeepAllGlobals) { +void DSGraph::removeTriviallyDeadNodes() { for (unsigned i = 0; i != Nodes.size(); ++i) - if (!KeepAllGlobals || !(Nodes[i]->NodeType & DSNode::GlobalNode)) + if (!(Nodes[i]->NodeType & DSNode::GlobalNode)) if (isNodeDead(Nodes[i])) { // This node is dead! delete Nodes[i]; // Free memory... Nodes.erase(Nodes.begin()+i--); // Remove from node list... @@ -981,9 +981,9 @@ static void markGlobalsAlive(DSGraph &G, std::set &Alive, // from the caller's graph entirely. This is only appropriate to use when // inlining graphs. // -void DSGraph::removeDeadNodes(bool KeepAllGlobals) { +void DSGraph::removeDeadNodes() { // Reduce the amount of work we have to do... - removeTriviallyDeadNodes(KeepAllGlobals); + removeTriviallyDeadNodes(); // FIXME: Merge nontrivially identical call nodes... @@ -1012,13 +1012,6 @@ void DSGraph::removeDeadNodes(bool KeepAllGlobals) { // The return value is alive as well... markAlive(RetNode.getNode(), Alive); - // Mark all globals or cast nodes that can reach a live node as alive. - // This also marks all nodes reachable from such nodes as alive. - // Of course, if KeepAllGlobals is specified, they would be live already. - - if (!KeepAllGlobals) - markGlobalsAlive(*this, Alive, false); - // Loop over all unreachable nodes, dropping their references... vector DeadNodes; DeadNodes.reserve(Nodes.size()); // Only one allocation is allowed. @@ -1129,23 +1122,6 @@ DSNode* GlobalDSGraph::cloneNodeInto(DSNode *OldNode, } -// GlobalDSGraph::cloneGlobals - Clone global nodes and all their externally -// visible target links (and recursively their such links) into this graph. -// -void GlobalDSGraph::cloneGlobals(DSGraph& Graph, bool CloneCalls) { - std::map NodeCache; -#if 0 - for (unsigned i = 0, N = Graph.Nodes.size(); i < N; ++i) - if (Graph.Nodes[i]->NodeType & DSNode::GlobalNode) - GlobalsGraph->cloneNodeInto(Graph.Nodes[i], NodeCache, false); - if (CloneCalls) - GlobalsGraph->cloneCalls(Graph); - - GlobalsGraph->removeDeadNodes(/*KeepAllGlobals*/ true); -#endif -} - - // GlobalDSGraph::cloneCalls - Clone function calls and their visible target // links (and recursively their such links) into this graph. // diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index 311810644a4..427c54377bc 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -134,7 +134,7 @@ DSGraph::DSGraph(Function &F, DSGraph *GG) : Func(&F), GlobalsGraph(GG) { markIncompleteNodes(); // Remove any nodes made dead due to merging... - removeDeadNodes(true); + removeDeadNodes(); } diff --git a/lib/Analysis/DataStructure/Steensgaard.cpp b/lib/Analysis/DataStructure/Steensgaard.cpp index 6dc2bda30be..e42ef231761 100644 --- a/lib/Analysis/DataStructure/Steensgaard.cpp +++ b/lib/Analysis/DataStructure/Steensgaard.cpp @@ -194,7 +194,7 @@ bool Steens::run(Module &M) { ResultGraph->markIncompleteNodes(false); // Remove any nodes that are dead after all of the merging we have done... - ResultGraph->removeDeadNodes(true); + ResultGraph->removeDeadNodes(); DEBUG(print(std::cerr, &M)); return false; diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index 1da43e5634f..5c15b50f13a 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -186,7 +186,7 @@ void TDDataStructures::calculateGraph(Function &F) { CG.maskIncompleteMarkers(); CG.markIncompleteNodes(/*markFormals*/ !F.hasInternalLinkage() /*&& FIXME: NEED TO CHECK IF ALL CALLERS FOUND!*/); - CG.removeDeadNodes(/*KeepAllGlobals*/ false); + CG.removeDeadNodes(); } DEBUG(std::cerr << " [TD] Done inlining into callees for: " << F.getName() -- 2.34.1