aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/DataStructure/BottomUpClosure.cpp')
-rw-r--r--lib/Analysis/DataStructure/BottomUpClosure.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp
index 6d3c4b0a1a..ba559bb0e6 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;
}