diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-06-04 07:01:56 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-06-04 07:01:56 +0000 |
commit | 38eb9f46db418ff8a75ef95841097a2ab6ebbc41 (patch) | |
tree | 3363028f84c80e039739eac29f382cdc83bd23d0 /llvm/lib/IR/ConstantFold.cpp | |
parent | 214335d703197bdb2f7f06bcce8c31fe2112b94e (diff) | |
download | llvm-38eb9f46db418ff8a75ef95841097a2ab6ebbc41.zip llvm-38eb9f46db418ff8a75ef95841097a2ab6ebbc41.tar.gz llvm-38eb9f46db418ff8a75ef95841097a2ab6ebbc41.tar.bz2 |
[ConstantFold] Don't skip the first gep index when folding geps
We neglected to check if the first index made the GEP ineligible for
'inbounds'.
This fixes PR23753.
llvm-svn: 239015
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 3f64c43..2efc6124 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -2165,9 +2165,9 @@ static Constant *ConstantFoldGetElementPtrImpl(Type *PointeeTy, Constant *C, // factored out into preceding dimensions. bool Unknown = false; SmallVector<Constant *, 8> NewIdxs; - Type *Ty = PointeeTy; - Type *Prev = C->getType(); - for (unsigned i = 1, e = Idxs.size(); i != e; + Type *Ty = C->getType(); + Type *Prev = nullptr; + for (unsigned i = 0, e = Idxs.size(); i != e; Prev = Ty, Ty = cast<CompositeType>(Ty)->getTypeAtIndex(Idxs[i]), ++i) { if (ConstantInt *CI = dyn_cast<ConstantInt>(Idxs[i])) { if (isa<ArrayType>(Ty) || isa<VectorType>(Ty)) |