diff options
author | Jeff Cohen <jeffc@jolt-lang.org> | 2007-04-04 16:58:57 +0000 |
---|---|---|
committer | Jeff Cohen <jeffc@jolt-lang.org> | 2007-04-04 16:58:57 +0000 |
commit | 86796bec503a0002a6587597e9ee6b6d3048a322 (patch) | |
tree | 6a250025a8eb207b90210ffd90e3be1d24d008f1 | |
parent | 451994334d28fb68dcdc80f0242231c9cc59b5cc (diff) | |
download | external_llvm-86796bec503a0002a6587597e9ee6b6d3048a322.tar.gz external_llvm-86796bec503a0002a6587597e9ee6b6d3048a322.tar.bz2 external_llvm-86796bec503a0002a6587597e9ee6b6d3048a322.zip |
Fix 2007-04-04-BadFoldBitcastIntoMalloc.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35665 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index a76152804a..d217fca889 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -5901,7 +5901,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, /// X*Scale+Offset. /// static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale, - unsigned &Offset) { + int &Offset) { assert(Val->getType() == Type::Int32Ty && "Unexpected allocation size type!"); if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) { Offset = CI->getZExtValue(); @@ -5985,7 +5985,8 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI, // See if we can satisfy the modulus by pulling a scale out of the array // size argument. - unsigned ArraySizeScale, ArrayOffset; + unsigned ArraySizeScale; + int ArrayOffset; Value *NumElements = // See if the array size is a decomposable linear expr. DecomposeSimpleLinearExpr(AI.getOperand(0), ArraySizeScale, ArrayOffset); @@ -6010,8 +6011,8 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI, } } - if (unsigned Offset = (AllocElTySize*ArrayOffset)/CastElTySize) { - Value *Off = ConstantInt::get(Type::Int32Ty, Offset); + if (int Offset = (AllocElTySize*ArrayOffset)/CastElTySize) { + Value *Off = ConstantInt::get(Type::Int32Ty, Offset, true); Instruction *Tmp = BinaryOperator::createAdd(Amt, Off, "tmp"); Amt = InsertNewInstBefore(Tmp, AI); } |