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

Arushi Aggarwal aggarwa4 at illinois.edu
Thu Sep 23 14:58:23 PDT 2010


Author: aggarwa4
Date: Thu Sep 23 16:58:23 2010
New Revision: 114698

URL: http://llvm.org/viewvc/llvm-project?rev=114698&view=rev
Log:
Change to correctly fold arrays of structs, modulo the size of the struct that they contain, and correcty set the array flag

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=114698&r1=114697&r2=114698&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Thu Sep 23 16:58:23 2010
@@ -426,6 +426,7 @@
 
 
 void GraphBuilder::visitBitCastInst(BitCastInst &I) {
+  
   if (!isa<PointerType>(I.getType())) return; // Only pointers
   DSNodeHandle Ptr = getValueDest(I.getOperand(0));
   if (Ptr.isNull()) return;
@@ -559,9 +560,25 @@
   for (gep_type_iterator I = gep_type_begin(GEP), E = gep_type_end(GEP);
        I != E; ++I)
     if (const StructType *STy = dyn_cast<StructType>(*I)) {
+      // indexing into a structure
+      // next index must be a constant
       const ConstantInt* CUI = cast<ConstantInt>(I.getOperand());
       int FieldNo = CUI->getSExtValue();
+      // increment the offset by the actual byte offset being accessed
       Offset += (unsigned)TD.getStructLayout(STy)->getElementOffset(FieldNo);
+      
+    } else if(isa<ArrayType>(*I)) {
+      // indexing into an array.
+      Value.getNode()->setArrayMarker();
+      
+      // Find if the DSNode belongs to the array
+      // If not fold.
+      if(Value.getOffset() || Offset != 0) {
+        Value.getNode()->foldNodeCompletely();
+        Value.getNode();
+        Offset = 0;
+        break;
+      } 
     } else if (isa<PointerType>(*I)) {
       //
       // Unless we're advancing the pointer by zero bytes via array indexing,
@@ -571,6 +588,7 @@
       // Note that we break out of the loop if we fold the node.  Once
       // something is folded, all values within it are considered to alias.
       //
+      
       if (!isa<Constant>(I.getOperand()) ||
           !cast<Constant>(I.getOperand())->isNullValue()) {
         Value.getNode()->setArrayMarker();





More information about the llvm-commits mailing list