[PATCH] D16272: [opaque pointer types] Alloca: use getAllocatedType() instead of getType()->getElementType().

Eduard Burtescu via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 17 13:11:37 PST 2016


eddyb marked 2 inline comments as done.

================
Comment at: lib/Transforms/Scalar/ScalarReplAggregates.cpp:2237
@@ -2237,4 +2236,3 @@
       uint64_t EltOffset;
-      PointerType *OtherPtrTy = cast<PointerType>(OtherPtr->getType());
-      Type *OtherTy = OtherPtrTy->getElementType();
+      Type *OtherTy = AI->getAllocatedType();
       if (StructType *ST = dyn_cast<StructType>(OtherTy)) {
----------------
mjacob wrote:
> Are you sure this is right? I don't think we can assume that `AI` and `OtherPtr` have the same type.
`OtherPtr` is ensured above to have the type `PointerType::get(AI->getAllocatedType(), AddrSpace)`.

================
Comment at: lib/Transforms/Scalar/ScalarReplAggregates.cpp:2254
@@ -2255,3 +2253,3 @@
     Value *EltPtr = NewElts[i];
-    Type *EltTy = cast<PointerType>(EltPtr->getType())->getElementType();
+    Type *EltTy = NewElts[i]->getAllocatedType();
 
----------------
mjacob wrote:
> Why don't you reuse `EltPtr`?
Wrong type, `NewElts` is an array of `AllocaInst*`, and I believe `EltPtr` is assigned something that is not an `AllocaInst*` (or used to, looking again at it doesn't seem to be the case atm).

================
Comment at: lib/Transforms/Scalar/ScalarReplAggregates.cpp:2486
@@ -2487,4 +2485,3 @@
     Value *SrcField = NewElts[i];
-    Type *FieldTy =
-      cast<PointerType>(SrcField->getType())->getElementType();
+    Type *FieldTy = NewElts[i]->getAllocatedType();
     uint64_t FieldSizeBits = DL.getTypeSizeInBits(FieldTy);
----------------
mjacob wrote:
> Why don't you reuse `SrcField`?
See previous comment. In this case, `SrcField` *does* get assigned, so I can't change its type to `AllocaInst*`.


http://reviews.llvm.org/D16272





More information about the llvm-commits mailing list