[llvm] 71c1282 - [Mips] Fix inst `sc` disassemble assert when configured -mattr=+ptr64 (#158253)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 15 19:24:16 PDT 2025
Author: yingopq
Date: 2025-09-16T10:24:12+08:00
New Revision: 71c128232b994d1470f5cc2bae7049d68b5b5635
URL: https://github.com/llvm/llvm-project/commit/71c128232b994d1470f5cc2bae7049d68b5b5635
DIFF: https://github.com/llvm/llvm-project/commit/71c128232b994d1470f5cc2bae7049d68b5b5635.diff
LOG: [Mips] Fix inst `sc` disassemble assert when configured -mattr=+ptr64 (#158253)
When mips disassembler process `DecodeMem`, does not consider
Mips::SC64, leading to `Operands.size() = 3`.
And the right `Size` value is 4, when printMemOperand would occur
asserts: `assert(idx < size());`
Fix #157508.
Added:
llvm/test/MC/Disassembler/Mips/mips64/sc-ptr64.txt
Modified:
llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp b/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
index fa6cc0e3f0187..c22b8f61b12dc 100644
--- a/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
+++ b/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
@@ -1003,7 +1003,7 @@ static DecodeStatus DecodeMem(MCInst &Inst, unsigned Insn, uint64_t Address,
Reg = getReg(Decoder, Mips::GPR32RegClassID, Reg);
Base = getReg(Decoder, Mips::GPR32RegClassID, Base);
- if (Inst.getOpcode() == Mips::SC ||
+ if (Inst.getOpcode() == Mips::SC || Inst.getOpcode() == Mips::SC64 ||
Inst.getOpcode() == Mips::SCD)
Inst.addOperand(MCOperand::createReg(Reg));
diff --git a/llvm/test/MC/Disassembler/Mips/mips64/sc-ptr64.txt b/llvm/test/MC/Disassembler/Mips/mips64/sc-ptr64.txt
new file mode 100644
index 0000000000000..3964301b0827e
--- /dev/null
+++ b/llvm/test/MC/Disassembler/Mips/mips64/sc-ptr64.txt
@@ -0,0 +1,3 @@
+# RUN: llvm-mc -triple=mips64el-unknown-linux -disassemble -mattr=+ptr64 -mcpu=mips3 %s | FileCheck %s
+
+0xd8 0x49 0x6f 0xe2 # CHECK: sc $15, 18904($19)
More information about the llvm-commits
mailing list