mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134749 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -30,6 +30,14 @@ static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (BinaryOperator *I = dyn_cast<BinaryOperator>(Val)) {
|
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 (ConstantInt *RHS = dyn_cast<ConstantInt>(I->getOperand(1))) {
|
||||||
if (I->getOpcode() == Instruction::Shl) {
|
if (I->getOpcode() == Instruction::Shl) {
|
||||||
// This is a value scaled by '1 << the shift amt'.
|
// 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.
|
// This requires TargetData to get the alloca alignment and size information.
|
||||||
if (!TD) return 0;
|
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());
|
const PointerType *PTy = cast<PointerType>(CI.getType());
|
||||||
|
|
||||||
BuilderTy AllocaBuilder(*Builder);
|
BuilderTy AllocaBuilder(*Builder);
|
||||||
|
Reference in New Issue
Block a user