[llvm] [X86] Fix 32-bit immediate assertion and convert into backend error (PR #123872)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 10 23:51:57 PST 2025
================
@@ -965,11 +965,10 @@ X86RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
}
if (MI.getOperand(FIOperandNum+3).isImm()) {
- // Offset is a 32-bit integer.
- int Imm = (int)(MI.getOperand(FIOperandNum + 3).getImm());
- int Offset = FIOffset + Imm;
- assert((!Is64Bit || isInt<32>((long long)FIOffset + Imm)) &&
- "Requesting 64-bit offset in 32-bit immediate!");
+ int64_t Imm = MI.getOperand(FIOperandNum + 3).getImm();
+ int Offset = FIOffset + (int)Imm;
+ if (!Is64Bit && !isInt<32>((int64_t)FIOffset + Imm))
+ MI.emitGenericError("requesting 64-bit offset in 32-bit immediate");
if (Offset != 0 || !tryOptimizeLEAtoMOV(II))
----------------
RKSimon wrote:
If Imm == -FIOffset wouldn't that mean the operand isn't correctly set to zero?
https://github.com/llvm/llvm-project/pull/123872
More information about the llvm-commits
mailing list