[llvm-commits] [poolalloc] r126983 - /poolalloc/trunk/lib/DSA/TypeSafety.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Thu Mar 3 18:54:20 PST 2011


Author: aggarwa4
Date: Thu Mar  3 20:54:20 2011
New Revision: 126983

URL: http://llvm.org/viewvc/llvm-project?rev=126983&view=rev
Log:
Make sure we do not modify any DSGraphs, when we
use the TypeSafety pass. GetNodeForValue, on a non-
const DSGraph, adds a node if one did not exist earlier.
Modify to first check for existence of node, and then
as for the node.

Modified:
    poolalloc/trunk/lib/DSA/TypeSafety.cpp

Modified: poolalloc/trunk/lib/DSA/TypeSafety.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TypeSafety.cpp?rev=126983&r1=126982&r2=126983&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/TypeSafety.cpp (original)
+++ poolalloc/trunk/lib/DSA/TypeSafety.cpp Thu Mar  3 20:54:20 2011
@@ -19,9 +19,13 @@
 
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Module.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/FormattedStream.h"
 
 static RegisterPass<dsa::TypeSafety<EQTDDataStructures> >
-X ("typesafety", "Find type-safe pointers");
+X ("typesafety-eqtd", "Find type-safe pointers");
+static RegisterPass<dsa::TypeSafety<TDDataStructures> >
+Y ("typesafety-td", "Find type-safe pointers");
 
 // Pass Statistics
 namespace {
@@ -55,8 +59,11 @@
   //
   // Lookup the DSNode for the value in the function's DSGraph.
   //
-  DSGraph * TDG = dsaPass->getDSGraph(*F);
-  DSNodeHandle DSH = TDG->getNodeForValue(V);
+  const DSGraph * TDG = dsaPass->getDSGraph(*F);
+  
+  DSNodeHandle DSH;
+  if(TDG->hasNodeForValue(V))
+    DSH = TDG->getNodeForValue(V);
 
   //
   // If the value wasn't found in the function's DSGraph, then maybe we can
@@ -70,8 +77,10 @@
     // represents all globals in that equivalence class, and then look up the
     // DSNode Handle for *that* global.
     //
-    DSGraph * GlobalsGraph = TDG->getGlobalsGraph ();
-    DSH = GlobalsGraph->getNodeForValue(V);
+    const DSGraph * GlobalsGraph = TDG->getGlobalsGraph ();
+    if(GlobalsGraph->hasNodeForValue(V)) {
+      DSH = GlobalsGraph->getNodeForValue(V);
+    }
     if (DSH.isNull()) {
       //
       // DSA does not currently handle global aliases.
@@ -87,7 +96,6 @@
       }
     }
   }
-
   return DSH;
 }
 
@@ -165,6 +173,7 @@
            ne = TypeSet->end(); ni != ne; ++ni) {
         unsigned field_length = TD->getTypeStoreSize (*ni);
         if ((offset + field_length) > next_offset) {
+          DEBUG(errs() << " Found overlap at " << offset << " with " << next_offset << "\n");
           overlaps = true;
           break;
         }





More information about the llvm-commits mailing list