[PATCH] D159114: [llvm-objdump][RISCV] Print target of auipc+jalr calls

Job Noorman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 29 08:35:10 PDT 2023


jobnoorman created this revision.
jobnoorman added reviewers: MaskRay, jhenderson, kito-cheng.
Herald added subscribers: asb, luke, sunshaoce, pmatos, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson, emaste.
Herald added a project: All.
jobnoorman requested review of this revision.
Herald added subscribers: llvm-commits, wangpc, eopXD.
Herald added a project: LLVM.

Currently, the targets of auipc+jalr calls are not printed because
`MCInstrAnalysis` fails to analyze them. This patch implements this as
follows:

- Add a new `MCInstrAnalysis::evaluateBranch` overload that takes two consecutive instructions as arguments. This allows the RISC-V backend to detect auipc+jalr sequences.
- While disassembling in llvm-objdump, keep track of the previous instruction and if analyzing the current one fails, call the new `evaluateBranch` overload.

Note that the new `evaluateBranch` feels a bit hacky since it's the only
`MCInstrAnalysis` method that doesn't work on a single `MCInst`.
However, I don't see a nicer alternative so suggestions are very
welcome.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159114

Files:
  llvm/include/llvm/MC/MCInstrAnalysis.h
  llvm/lib/MC/MCInstrAnalysis.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
  llvm/test/tools/llvm-objdump/ELF/RISCV/branches.s
  llvm/tools/llvm-objdump/llvm-objdump.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159114.554370.patch
Type: text/x-patch
Size: 4183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230829/6973b533/attachment.bin>


More information about the llvm-commits mailing list