Skip to content

Commit 0dd16eb

Browse files
committed
[X86] Fix 32-bit immediate assertion and convert into backend error
The assertion previously did not work correctly because the operand was being truncated to an `int` prior to comparison.
1 parent 3f0ac46 commit 0dd16eb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/Target/X86/X86RegisterInfo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -965,11 +965,12 @@ X86RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
965965
}
966966

967967
if (MI.getOperand(FIOperandNum+3).isImm()) {
968-
// Offset is a 32-bit integer.
969-
int Imm = (int)(MI.getOperand(FIOperandNum + 3).getImm());
970-
int Offset = FIOffset + Imm;
971-
assert((!Is64Bit || isInt<32>((long long)FIOffset + Imm)) &&
972-
"Requesting 64-bit offset in 32-bit immediate!");
968+
int64_t Imm = MI.getOperand(FIOperandNum + 3).getImm();
969+
int Offset = FIOffset + (int)Imm;
970+
if (!Is64Bit && !isInt<32>((int64_t)FIOffset + Imm))
971+
MI.emitGenericError(
972+
("Requesting 64-bit offset in 32-bit immediate: " + MF.getName())
973+
.str());
973974
if (Offset != 0 || !tryOptimizeLEAtoMOV(II))
974975
MI.getOperand(FIOperandNum + 3).ChangeToImmediate(Offset);
975976
} else {

0 commit comments

Comments
 (0)