diff options
author | Dan Gohman <gohman@apple.com> | 2009-09-12 22:02:17 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-09-12 22:02:17 +0000 |
commit | 4acac62e8d0d90aac3368ae43bab7595c444fac0 (patch) | |
tree | df3219bdc95488f86b255968649a8d6b1a7bf8d2 | |
parent | 349a2ebbb382917bc368ef3b11b9e288c8a1b00c (diff) |
Preserve the inbounds flag, so that the constant folder doesn't
recompute it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81634 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/ConstantsContext.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/VMCore/ConstantsContext.h b/lib/VMCore/ConstantsContext.h index 9785d377b2..4f55502ff9 100644 --- a/lib/VMCore/ConstantsContext.h +++ b/lib/VMCore/ConstantsContext.h @@ -437,8 +437,11 @@ struct ConvertConstantType<ConstantExpr, Type> { case Instruction::GetElementPtr: // Make everyone now use a constant of the new type... std::vector<Value*> Idx(OldC->op_begin()+1, OldC->op_end()); - New = ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0), - &Idx[0], Idx.size()); + New = cast<GEPOperator>(OldC)->isInBounds() ? + ConstantExpr::getInBoundsGetElementPtrTy(NewTy, OldC->getOperand(0), + &Idx[0], Idx.size()) : + ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0), + &Idx[0], Idx.size()); break; } |