diff options
| author | Bob Wilson <bob.wilson@apple.com> | 2011-07-08 22:09:33 +0000 | 
|---|---|---|
| committer | Bob Wilson <bob.wilson@apple.com> | 2011-07-08 22:09:33 +0000 | 
| commit | 3c68b626e71e01adf189d9792b119795848abf8c (patch) | |
| tree | 076d90b717322ea59d7b28a55f42a44101414324 /llvm/lib/Transforms | |
| parent | 7471937ad7d1d5263db0bb992bb96b6aa1bd6237 (diff) | |
| download | bcm5719-llvm-3c68b626e71e01adf189d9792b119795848abf8c.tar.gz bcm5719-llvm-3c68b626e71e01adf189d9792b119795848abf8c.zip | |
Reapply a fixed version of r133285.
This tightens up checking for overflow in alloca sizes, based on feedback
from Duncan and John about the change in r132926.
llvm-svn: 134749
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 13 | 
1 files changed, 8 insertions, 5 deletions
| diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 601d9b42f31..036f0d33678 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -30,6 +30,14 @@ static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale,    }    if (BinaryOperator *I = dyn_cast<BinaryOperator>(Val)) { +    // Cannot look past anything that might overflow. +    OverflowingBinaryOperator *OBI = dyn_cast<OverflowingBinaryOperator>(Val); +    if (OBI && !OBI->hasNoUnsignedWrap()) { +      Scale = 1; +      Offset = 0; +      return Val; +    } +      if (ConstantInt *RHS = dyn_cast<ConstantInt>(I->getOperand(1))) {        if (I->getOpcode() == Instruction::Shl) {          // This is a value scaled by '1 << the shift amt'. @@ -71,11 +79,6 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,    // This requires TargetData to get the alloca alignment and size information.    if (!TD) return 0; -  // Insist that the amount-to-allocate not overflow. -  OverflowingBinaryOperator *OBI = -    dyn_cast<OverflowingBinaryOperator>(AI.getOperand(0)); -  if (OBI && !(OBI->hasNoSignedWrap() || OBI->hasNoUnsignedWrap())) return 0; -    const PointerType *PTy = cast<PointerType>(CI.getType());    BuilderTy AllocaBuilder(*Builder); | 

