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

Manuel Jacob via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 17 12:59:32 PST 2016


mjacob added inline comments.

================
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)) {
----------------
Are you sure this is right? I don't think we can assume that `AI` and `OtherPtr` have the same type.

================
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();
 
----------------
Why don't you reuse `EltPtr`?

================
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);
----------------
Why don't you reuse `SrcField`?


http://reviews.llvm.org/D16272





More information about the llvm-commits mailing list