[PATCH] D143345: [RFC][RISCV] Don't disassemble `addi`s with relocations as `mv`s
Luís Marques via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 5 07:50:46 PST 2023
luismarques created this revision.
luismarques added reviewers: asb, reames, craig.topper, jrtc27, kito-cheng.
Herald added subscribers: luke, VincentWu, vkmr, frasercrmck, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a project: All.
luismarques requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD.
Herald added a project: LLVM.
A RISC-V `mv rd, rs` instruction is an alias/pseudoinstruction for `addi rd, rs, 0`.
When disassembling object files we'll commonly encounter many (arguably) spurious `mv`s: `addi`s with unresolved relocations. The immediate operand isn't actually zero, though that is obscured by the relocation, so IMO it shouldn't be disassembled as a `mv`. I'd argue that even if such a relocation happens to resolve to zero it's still semantically not a `mv`, but that is a minor point.
This patch tries to address that situation by detecting when those `addi`s have relocations and not printing them as `mv`s.
Please let me know if you agree with (1) my reasoning and (2) the overall approach of this patch.
If there is a rough agreement I'll further improve the patch, including optimizing the search for the relocations and not introducing a separate `printInst` method.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143345
Files:
llvm/include/llvm/MC/MCInstPrinter.h
llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h
llvm/test/MC/RISCV/rvi-aliases-valid.s
llvm/tools/llvm-objdump/llvm-objdump.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143345.494909.patch
Type: text/x-patch
Size: 4364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230205/5e62b4e3/attachment.bin>
More information about the llvm-commits
mailing list