[llvm] [X86] Fix 32-bit immediate assertion and convert into backend error (PR #123872)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 19:57:42 PST 2025
================
@@ -965,11 +965,12 @@ 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: " + MF.getName())
+ .str());
----------------
arsenm wrote:
Error messages should be lowercase. This also uses Twine, you don't need the .str(). This should also be testable. Since you are now preventing the formation of the bad indexing, can this be a verifier error? I'm guessing not since you don't know the frame index values before PrologEpilog
https://github.com/llvm/llvm-project/pull/123872
More information about the llvm-commits
mailing list