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 | 2eff970892e495019a0996c0aa8784450697cd2a (patch) | |
tree | 20e98aa2d94fe430088c44682db04ba3515b5f11 /llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp | |
parent | 68c3caccb1c93db1a43deb3eed3059aa64165ceb (diff) | |
download | bcm5719-llvm-2eff970892e495019a0996c0aa8784450697cd2a.tar.gz bcm5719-llvm-2eff970892e495019a0996c0aa8784450697cd2a.zip |
After finishing BU analysis, move all global variables from the globals
graph into main and mark them complete.
llvm-svn: 20583
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp')
-rw-r--r-- | llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp b/llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp index a16d40fbe0f..8dc20648104 100644 --- a/llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp +++ b/llvm/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; } |