[opaque pointer types] Pass value type to GetElementPtr creation.
This cleans up all GetElementPtr creation in LLVM to explicitly pass a
value type rather than deriving it from the pointer's element-type.
Differential Revision: https://reviews.llvm.org/D57173
llvm-svn: 352913
diff --git a/llvm/lib/Transforms/Utils/Evaluator.cpp b/llvm/lib/Transforms/Utils/Evaluator.cpp
index f49fba5..4a8ec43 100644
--- a/llvm/lib/Transforms/Utils/Evaluator.cpp
+++ b/llvm/lib/Transforms/Utils/Evaluator.cpp
@@ -343,18 +343,18 @@
// into a pointer to its first member.
// FIXME: This could be extended to support arrays as well.
if (StructType *STy = dyn_cast<StructType>(NewTy)) {
- NewTy = STy->getTypeAtIndex(0U);
IntegerType *IdxTy = IntegerType::get(NewTy->getContext(), 32);
Constant *IdxZero = ConstantInt::get(IdxTy, 0, false);
Constant * const IdxList[] = {IdxZero, IdxZero};
- Ptr = ConstantExpr::getGetElementPtr(nullptr, Ptr, IdxList);
+ Ptr = ConstantExpr::getGetElementPtr(NewTy, Ptr, IdxList);
if (auto *FoldedPtr = ConstantFoldConstant(Ptr, DL, TLI))
Ptr = FoldedPtr;
+ NewTy = STy->getTypeAtIndex(0U);
- // If we can't improve the situation by introspecting NewTy,
- // we have to give up.
+ // If we can't improve the situation by introspecting NewTy,
+ // we have to give up.
} else {
LLVM_DEBUG(dbgs() << "Failed to bitcast constant ptr, can not "
"evaluate.\n");