[llvm-commits] [poolalloc] r115794 - in /poolalloc/trunk: include/dsa/DataStructure.h lib/DSA/EquivClassGraphs.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Wed Oct 6 09:43:32 PDT 2010


Author: aggarwa4
Date: Wed Oct  6 11:43:32 2010
New Revision: 115794

URL: http://llvm.org/viewvc/llvm-project?rev=115794&view=rev
Log:
Added checking to assert that at the end of EQBU, all functions that are in the same global Equivalence Class, have their graphs merged.


Modified:
    poolalloc/trunk/include/dsa/DataStructure.h
    poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp

Modified: poolalloc/trunk/include/dsa/DataStructure.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=115794&r1=115793&r2=115794&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Wed Oct  6 11:43:32 2010
@@ -302,6 +302,8 @@
 ///
 class EquivBUDataStructures : public CompleteBUDataStructures {
   void mergeGraphsByGlobalECs();
+  void verifyMerging();
+
 public:
   static char ID;
   EquivBUDataStructures()

Modified: poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp?rev=115794&r1=115793&r2=115794&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp (original)
+++ poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp Wed Oct  6 11:43:32 2010
@@ -26,13 +26,14 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/EquivalenceClasses.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/FormattedStream.h"
+#include <fstream>
 using namespace llvm;
 
 namespace {
   RegisterPass<EquivBUDataStructures> X("dsa-eq",
                     "Equivalence-class Bottom-up Data Structure Analysis");
 }
-
 char EquivBUDataStructures::ID = 0;
 
 // runOnModule - Calculate the bottom up data structure graphs for each function
@@ -42,13 +43,43 @@
   init(&getAnalysis<CompleteBUDataStructures>(), false, true, false, true);
 
   //update the EQ class from indirect calls
+  bool result = false;
   buildIndirectFunctionSets();
-
   mergeGraphsByGlobalECs();
-
-  return runOnModuleInternal(M);
+  result = runOnModuleInternal(M);
+  
+  verifyMerging();
+  
+  return result;
 }
 
+void
+EquivBUDataStructures::verifyMerging() {
+  
+  EquivalenceClasses<const GlobalValue*>::iterator EQSI = GlobalECs.begin();
+  EquivalenceClasses<const GlobalValue*>::iterator EQSE = GlobalECs.end();
+  for (;EQSI != EQSE; ++EQSI) {
+    if (!EQSI->isLeader()) continue;
+    EquivalenceClasses<const GlobalValue*>::member_iterator MI;
+    bool first = true;
+    DSGraph *firstG = 0;
+    for (MI = GlobalECs.member_begin(EQSI); MI != GlobalECs.member_end(); ++MI){
+      if (const Function* F = dyn_cast<Function>(*MI)){
+        if (F->isDeclaration())
+          continue;
+          
+          if(first) {
+            firstG = getOrCreateGraph(F);
+            first = false;
+          } 
+          DSGraph *G = getOrCreateGraph(F);
+          if( G != firstG) {
+            assert(G == firstG && "all functions in a Global EC do not have a merged graph"); 
+          }
+      }
+    }
+  }
+}
 
 //
 // Method: mergeGraphsByGlobalECs()
@@ -69,6 +100,7 @@
   // For each leader, we scan through all of its members and merge the DSGraphs
   // for members which are functions.
   //
+ 
   EquivalenceClasses<const GlobalValue*>::iterator EQSI = GlobalECs.begin();
   EquivalenceClasses<const GlobalValue*>::iterator EQSE = GlobalECs.end();
   for (;EQSI != EQSE; ++EQSI) {





More information about the llvm-commits mailing list