diff options
author | Chris Lattner <sabre@nondot.org> | 2005-03-13 20:15:06 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-03-13 20:15:06 +0000 |
commit | a66e353cf90e59df8da938560db6dc31caf9b423 (patch) | |
tree | 23d0500f7161b37f34626bec85df70bc75674d5f /lib/Analysis | |
parent | adfd5f14b426aa68f3d5b4c8c9b6145ae36af11d (diff) | |
download | external_llvm-a66e353cf90e59df8da938560db6dc31caf9b423.zip external_llvm-a66e353cf90e59df8da938560db6dc31caf9b423.tar.gz external_llvm-a66e353cf90e59df8da938560db6dc31caf9b423.tar.bz2 |
After finishing BU analysis, move all global variables from the globals
graph into main and mark them complete.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20583 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/DataStructure/BottomUpClosure.cpp | 21 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/CompleteBottomUp.cpp | 29 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/EquivClassGraphs.cpp | 27 |
3 files changed, 71 insertions, 6 deletions
diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index 6d3c4b0..ba559bb 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -81,6 +81,27 @@ bool BUDataStructures::runOnModule(Module &M) { // GlobalsGraph->removeTriviallyDeadNodes(); GlobalsGraph->maskIncompleteMarkers(); + + // Merge the globals variables (not the calls) from the globals graph back + // into the main function's graph so that the main function contains all of + // the information about global pools and GV usage in the program. + if (MainFunc) { + DSGraph &MainGraph = getOrCreateGraph(MainFunc); + const DSGraph &GG = *MainGraph.getGlobalsGraph(); + ReachabilityCloner RC(MainGraph, GG, + DSGraph::DontCloneCallNodes | + DSGraph::DontCloneAuxCallNodes); + + // Clone the global nodes into this graph. + for (DSScalarMap::global_iterator I = GG.getScalarMap().global_begin(), + E = GG.getScalarMap().global_end(); I != E; ++I) + if (isa<GlobalVariable>(*I)) + RC.getClonedNH(GG.getNodeForValue(*I)); + + MainGraph.markIncompleteNodes(DSGraph::MarkFormalArgs | + DSGraph::IgnoreGlobals); + } + return false; } diff --git a/lib/Analysis/DataStructure/CompleteBottomUp.cpp b/lib/Analysis/DataStructure/CompleteBottomUp.cpp index 1c9e329..77a5f32 100644 --- a/lib/Analysis/DataStructure/CompleteBottomUp.cpp +++ b/lib/Analysis/DataStructure/CompleteBottomUp.cpp @@ -76,9 +76,10 @@ bool CompleteBUDataStructures::runOnModule(Module &M) { hash_map<DSGraph*, unsigned> ValMap; unsigned NextID = 1; - if (Function *Main = M.getMainFunction()) { - if (!Main->isExternal()) - calculateSCCGraphs(getOrCreateGraph(*Main), Stack, NextID, ValMap); + Function *MainFunc = M.getMainFunction(); + if (MainFunc) { + if (!MainFunc->isExternal()) + calculateSCCGraphs(getOrCreateGraph(*MainFunc), Stack, NextID, ValMap); } else { std::cerr << "CBU-DSA: No 'main' function found!\n"; } @@ -88,6 +89,28 @@ bool CompleteBUDataStructures::runOnModule(Module &M) { calculateSCCGraphs(getOrCreateGraph(*I), Stack, NextID, ValMap); GlobalsGraph->removeTriviallyDeadNodes(); + + + // Merge the globals variables (not the calls) from the globals graph back + // into the main function's graph so that the main function contains all of + // the information about global pools and GV usage in the program. + if (MainFunc) { + DSGraph &MainGraph = getOrCreateGraph(*MainFunc); + const DSGraph &GG = *MainGraph.getGlobalsGraph(); + ReachabilityCloner RC(MainGraph, GG, + DSGraph::DontCloneCallNodes | + DSGraph::DontCloneAuxCallNodes); + + // Clone the global nodes into this graph. + for (DSScalarMap::global_iterator I = GG.getScalarMap().global_begin(), + E = GG.getScalarMap().global_end(); I != E; ++I) + if (isa<GlobalVariable>(*I)) + RC.getClonedNH(GG.getNodeForValue(*I)); + + MainGraph.markIncompleteNodes(DSGraph::MarkFormalArgs | + DSGraph::IgnoreGlobals); + } + return false; } diff --git a/lib/Analysis/DataStructure/EquivClassGraphs.cpp b/lib/Analysis/DataStructure/EquivClassGraphs.cpp index a16d40f..8dc2064 100644 --- a/lib/Analysis/DataStructure/EquivClassGraphs.cpp +++ b/lib/Analysis/DataStructure/EquivClassGraphs.cpp @@ -89,9 +89,9 @@ bool EquivClassGraphs::runOnModule(Module &M) { std::map<DSGraph*, unsigned> ValMap; unsigned NextID = 1; - if (Function *Main = M.getMainFunction()) { - if (!Main->isExternal()) - processSCC(getOrCreateGraph(*Main), Stack, NextID, ValMap); + Function *MainFunc = M.getMainFunction(); + if (MainFunc && !MainFunc->isExternal()) { + processSCC(getOrCreateGraph(*MainFunc), Stack, NextID, ValMap); } else { std::cerr << "Fold Graphs: No 'main' function found!\n"; } @@ -103,6 +103,27 @@ bool EquivClassGraphs::runOnModule(Module &M) { DEBUG(CheckAllGraphs(&M, *this)); getGlobalsGraph().removeTriviallyDeadNodes(); + + // Merge the globals variables (not the calls) from the globals graph back + // into the main function's graph so that the main function contains all of + // the information about global pools and GV usage in the program. + if (MainFunc) { + DSGraph &MainGraph = getOrCreateGraph(*MainFunc); + const DSGraph &GG = *MainGraph.getGlobalsGraph(); + ReachabilityCloner RC(MainGraph, GG, + DSGraph::DontCloneCallNodes | + DSGraph::DontCloneAuxCallNodes); + + // Clone the global nodes into this graph. + for (DSScalarMap::global_iterator I = GG.getScalarMap().global_begin(), + E = GG.getScalarMap().global_end(); I != E; ++I) + if (isa<GlobalVariable>(*I)) + RC.getClonedNH(GG.getNodeForValue(*I)); + + MainGraph.markIncompleteNodes(DSGraph::MarkFormalArgs | + DSGraph::IgnoreGlobals); + } + return false; } |