[MC][Mips] Fix wrong assumption about Immediate operand.#119056
[MC][Mips] Fix wrong assumption about Immediate operand.#119056romainthomas wants to merge 1 commit intollvm:mainfrom
Immediate operand.#119056Conversation
While trying to evaluate the branch of this MIPS (EL) non-branch instruction: `ldxc1 $f2, $4($7)` the function fails on the assert: `assert(isImm() && ...)`. This commit ensures that the operand is an immediate before accessing the value. - Triple: `mipsel-unknown-linux-gnu-elf` with '+mips32r2' - Instruction: `ldxc1 $f2, $4($7)` - Raw instruction: `0x81, 0x0, 0xe4, 0x4c`
You can test this locally with the following command:git-clang-format --diff a9eb8f0e3dbaf16b6bd83eecb960b6ea8ecaa8c3 d0b9d784e2e1257eeab6c8a52f4845a10ae151f6 --extensions cpp -- llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cppView the diff from clang-format here.diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
index 4b38ce70c3..eaf4de9d37 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
@@ -143,7 +143,7 @@ public:
switch (Info->get(Inst.getOpcode()).operands()[NumOps - 1].OperandType) {
case MCOI::OPERAND_UNKNOWN:
case MCOI::OPERAND_IMMEDIATE: {
- const MCOperand& Op = Inst.getOperand(NumOps - 1);
+ const MCOperand &Op = Inst.getOperand(NumOps - 1);
if (!Op.isImm())
return false;
// j, jal, jalx, jals
|
|
Test? |
|
From what I understand, most of the logic of Mips disassembler testing is done in I don't think we could exercise this code path with a lit test1 using Who should own this bootstrapping? Me in this PR? Me in a different PR? The Mips code owners? Footnotes
|
I think you can do that using |
|
Can you give out a test case for it? |
|
Feel free to re-open this PR if you think it is relevant and when there is a clear status about Mips testing in LLVM (c.f. #119056 (comment)) |
While trying to evaluate the branch of this MIPS (EL) non-branch instruction:
ldxc1 $f2, $4($7)the function fails on the assert:assert(isImm() && ...).This commit ensures that the operand is an immediate before accessing the value.
mipsel-unknown-linux-gnu-elfwith+mips32r2ldxc1 $f2, $4($7)0x81, 0x0, 0xe4, 0x4c