mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
When lowering an inbounds gep, the intermediate adds can have
unsigned overflow (e.g. due to a negative array index), but the scales on array size multiplications are known to not sign wrap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125409 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -420,8 +420,7 @@ Value *InstCombiner::EmitGEPOffset(User *GEP) {
|
|||||||
|
|
||||||
if (Size)
|
if (Size)
|
||||||
Result = Builder->CreateAdd(Result, ConstantInt::get(IntPtrTy, Size),
|
Result = Builder->CreateAdd(Result, ConstantInt::get(IntPtrTy, Size),
|
||||||
GEP->getName()+".offs",
|
GEP->getName()+".offs");
|
||||||
isInBounds /*NUW*/);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,8 +429,7 @@ Value *InstCombiner::EmitGEPOffset(User *GEP) {
|
|||||||
ConstantExpr::getIntegerCast(OpC, IntPtrTy, true /*SExt*/);
|
ConstantExpr::getIntegerCast(OpC, IntPtrTy, true /*SExt*/);
|
||||||
Scale = ConstantExpr::getMul(OC, Scale, isInBounds/*NUW*/);
|
Scale = ConstantExpr::getMul(OC, Scale, isInBounds/*NUW*/);
|
||||||
// Emit an add instruction.
|
// Emit an add instruction.
|
||||||
Result = Builder->CreateAdd(Result, Scale, GEP->getName()+".offs",
|
Result = Builder->CreateAdd(Result, Scale, GEP->getName()+".offs");
|
||||||
isInBounds /*NUW*/);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Convert to correct type.
|
// Convert to correct type.
|
||||||
@@ -444,8 +442,7 @@ Value *InstCombiner::EmitGEPOffset(User *GEP) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Emit an add instruction.
|
// Emit an add instruction.
|
||||||
Result = Builder->CreateAdd(Op, Result, GEP->getName()+".offs",
|
Result = Builder->CreateAdd(Op, Result, GEP->getName()+".offs");
|
||||||
isInBounds /*NUW*/);
|
|
||||||
}
|
}
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user