[PATCH] D16275: [opaque pointer types] [NFC] GEP: replace get(Pointer)ElementType uses with get{Source, Result}ElementType.
Eduard Burtescu via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 18 14:50:00 PST 2016
eddyb marked an inline comment as done.
================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:697-698
@@ -696,6 +696,4 @@
SmallVector<Value *, 4> Ops(GEPI->idx_begin(), GEPI->idx_begin() + Idx);
- Type *AllocTy = GetElementPtrInst::getIndexedType(
- cast<PointerType>(GEPI->getOperand(0)->getType()->getScalarType())
- ->getElementType(),
- Ops);
+ Type *AllocTy =
+ GetElementPtrInst::getIndexedType(GEPI->getSourceElementType(), Ops);
if (!AllocTy || !AllocTy->isSized())
----------------
mjacob wrote:
> Can we use `getResultElementType()` here?
If `Ops` were to have all of GEPI's indices, then `if (Idx == GEPI->getNumOperands()) return false;` above would've handled it (by returning out of this function).
In other words, `AllocTy` will always stop short of the `ResultElementType`, as less indices will be applied.
http://reviews.llvm.org/D16275
More information about the llvm-commits
mailing list