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

Arushi Aggarwal aggarwa4 at illinois.edu
Sun Nov 7 09:54:08 PST 2010


Author: aggarwa4
Date: Sun Nov  7 11:54:08 2010
New Revision: 118380

URL: http://llvm.org/viewvc/llvm-project?rev=118380&view=rev
Log:
Correct offset calculation for InsertValue/ExtractValue inst.

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=118380&r1=118379&r2=118380&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Sun Nov  7 11:54:08 2010
@@ -440,9 +440,16 @@
 
   // Mark that the node is written to...
   Dest.getNode()->setModifiedMarker();
+  unsigned Offset = 0;
+  const Type* STy = I.getAggregateOperand()->getType();
+  for (llvm::ExtractValueInst::idx_iterator i = I.idx_begin(), e = I.idx_end(); i != e; i++) {
+    const StructLayout *SL = TD.getStructLayout(cast<StructType>(STy));
+    Offset += SL->getElementOffset(*i);
+    STy = (cast<StructType>(STy))->getTypeAtIndex(*i);
+  }
 
   // Ensure a type-record exists...
-  Dest.getNode()->mergeTypeInfo(StoredTy, I.getInsertedValueOperandIndex()); 
+  Dest.getNode()->mergeTypeInfo(StoredTy, Offset); 
 
   // Avoid adding edges from null, or processing non-"pointer" stores
   if (isa<PointerType>(StoredTy))
@@ -454,9 +461,16 @@
 
   // Make that the node is read from...
   Ptr.getNode()->setReadMarker();
-
+  unsigned Offset = 0;
+  const Type* STy = I.getAggregateOperand()->getType();
+  for (llvm::ExtractValueInst::idx_iterator i = I.idx_begin(), e = I.idx_end(); i != e; i++) {
+    const StructLayout *SL = TD.getStructLayout(cast<StructType>(STy));
+    Offset += SL->getElementOffset(*i);
+    STy = (cast<StructType>(STy))->getTypeAtIndex(*i);
+  }
+  
   // Ensure a typerecord exists...
-  Ptr.getNode()->mergeTypeInfo(I.getType(), I.getAggregateOperandIndex());
+  Ptr.getNode()->mergeTypeInfo(I.getType(), Offset);
 
   if (isa<PointerType>(I.getType()))
     setDestTo(I, getLink(Ptr));





More information about the llvm-commits mailing list