[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp CompleteBottomUp.cpp EquivClassGraphs.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Mar 13 12:15:22 PST 2005



Changes in directory llvm/lib/Analysis/DataStructure:

BottomUpClosure.cpp updated: 1.93 -> 1.94
CompleteBottomUp.cpp updated: 1.17 -> 1.18
EquivClassGraphs.cpp updated: 1.22 -> 1.23
---
Log message:

After finishing BU analysis, move all global variables from the globals
graph into main and mark them complete.


---
Diffs of the changes:  (+71 -6)

 BottomUpClosure.cpp  |   21 +++++++++++++++++++++
 CompleteBottomUp.cpp |   29 ++++++++++++++++++++++++++---
 EquivClassGraphs.cpp |   27 ++++++++++++++++++++++++---
 3 files changed, 71 insertions(+), 6 deletions(-)


Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.93 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.94
--- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.93	Mon Feb  7 10:09:15 2005
+++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp	Sun Mar 13 14:15:06 2005
@@ -81,6 +81,27 @@
   // 
   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;
 }
 


Index: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp
diff -u llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.17 llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.18
--- llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.17	Sun Jan 30 18:10:58 2005
+++ llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp	Sun Mar 13 14:15:06 2005
@@ -76,9 +76,10 @@
   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 @@
       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;
 }
 


Index: llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp
diff -u llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.22 llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.23
--- llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.22	Sun Mar 13 13:51:24 2005
+++ llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp	Sun Mar 13 14:15:06 2005
@@ -89,9 +89,9 @@
   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 @@
   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;
 }
 






More information about the llvm-commits mailing list