mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 05:22:04 +00:00
Fix integer undefined behavior due to signed left shift overflow in LLVM.
Reviewed offline by chandlerc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162623 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1475,10 +1475,9 @@ static const MCExpr *LowerConstant(const Constant *CV, AsmPrinter &AP) {
|
||||
return Base;
|
||||
|
||||
// Truncate/sext the offset to the pointer size.
|
||||
if (TD.getPointerSizeInBits() != 64) {
|
||||
int SExtAmount = 64-TD.getPointerSizeInBits();
|
||||
Offset = (Offset << SExtAmount) >> SExtAmount;
|
||||
}
|
||||
unsigned Width = TD.getPointerSizeInBits();
|
||||
if (Width < 64)
|
||||
Offset = SignExtend64(Offset, Width);
|
||||
|
||||
return MCBinaryExpr::CreateAdd(Base, MCConstantExpr::Create(Offset, Ctx),
|
||||
Ctx);
|
||||
|
||||
Reference in New Issue
Block a user