diff options
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index f84fe79..5fa56d3 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -2280,7 +2280,8 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C, // check for the "inbounds" property. if (!Unknown && !InBounds) if (auto *GV = dyn_cast<GlobalVariable>(C)) - if (!GV->hasExternalWeakLinkage() && isInBoundsIndices(Idxs)) + if (!GV->hasExternalWeakLinkage() && GV->getValueType() == PointeeTy && + isInBoundsIndices(Idxs)) return ConstantExpr::getGetElementPtr(PointeeTy, C, Idxs, /*InBounds=*/true, InRangeIndex); |