[llvm-commits] [poolalloc] r125107 - /poolalloc/trunk/lib/DSA/Local.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Tue Feb 8 11:30:32 PST 2011


Author: aggarwa4
Date: Tue Feb  8 13:30:32 2011
New Revision: 125107

URL: http://llvm.org/viewvc/llvm-project?rev=125107&view=rev
Log:
Offset calculated for a GEP Instruction might be
negative.

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

Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=125107&r1=125106&r2=125107&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Tue Feb  8 13:30:32 2011
@@ -553,7 +553,7 @@
   // indexed.
   //
  
-  unsigned Offset = 0;
+  int Offset = 0;
 
   if(TypeInferenceOptimize) {
   // Trying to special case constant index GEPs
@@ -568,7 +568,7 @@
             }
             Value.setOffset(Value.getOffset()+Offset);
             DSNode *N = Value.getNode();
-            if((int)Offset < 0)
+            if(((int)Value.getOffset() + Offset) < 0)
               N->foldNodeCompletely();
             setDestTo(GEP, Value);
             return;
@@ -589,7 +589,7 @@
             Value.getNode()->growSize(Value.getOffset() + O+1);
           Value.setOffset(Value.getOffset()+O);
           DSNode *N = Value.getNode();
-          if(O < 0)
+          if(((int)Value.getOffset() + O) < 0)
             N->foldNodeCompletely();
           setDestTo(GEP, Value);
           ++NumUglyGep1;
@@ -598,6 +598,7 @@
       }
     }
   }
+  
   // FIXME: I am not sure if the code below is completely correct (especially
   //        if we start doing fancy analysis on non-constant array indices).
   //        What if the array is indexed using a larger index than its declared
@@ -711,7 +712,7 @@
       !N->isNodeCompletelyFolded() &&
       (N->getSize() != 0 || Offset != 0) &&
       !N->isForwarding()) {
-    if ((Offset >= N->getSize()) || int(Offset) < 0) {
+    if ((Offset >= (int)N->getSize()) || Offset < 0) {
       // Accessing offsets out of node size range
       // This is seen in the "magic" struct in named (from bind), where the
       // fourth field is an array of length 0, presumably used to create struct





More information about the llvm-commits mailing list