[PATCH] D79309: [llvm-objdump] -d: delete spaces among raw instruction bytes

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 3 14:20:58 PDT 2020


MaskRay created this revision.
MaskRay added reviewers: craig.topper, hubert.reinterpretcast, jhenderson, ostannard, psmith.
Herald added subscribers: llvm-commits, rupprecht, hiraditya, kristof.beyls, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

On a disassembly line, the raw bytes are relatively less important.
--no-show-raw-insn can hide them but the option is not the default.
Delete spaces to leave columns to most useful stuff (for example, I plan
to implement visual arrows similar to --visual-jumps added in GNU
objdump 2.34, but I'd take more inspirations from radare2's `pd` command).

Also move the instruction left by 8 columns. This is especially helpful
for targets with x86, which has potentially long instructions.
Before:

  2015c4: ff 15 be 12 00 00             callq   *4798(%rip)  # 202888 <crtstuff.c+0x202888>
  2015ca: f4                            hlt
  2015cb: 0f 1f 44 00 00                nopl    (%rax,%rax)

After (8 columns narrower):

  2015c4: ff15be120000          callq   *4798(%rip)  # 202888 <crtstuff.c+0x202888>
  2015ca: f4                    hlt
  2015cb: 0f1f440000            nopl    (%rax,%rax)

Spaces are not deleted for non-x86 because otherwise the patch would
have to touch ~700 more tests. I may update them based on feedback.
This diff just includes some representative test changes. 40+ test
changes are omitted.

AArch64 instructions are encoded in little-endian and GNU objdump prints
`04030201` for byte sequence `01 02 03 04`. Personally I find the
hexpair order annoying because I prefer the way bytes are presented in a
hex editor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79309

Files:
  llvm/include/llvm/MC/MCInstPrinter.h
  llvm/lib/MC/MCInstPrinter.cpp
  llvm/test/MC/AArch64/inst-directive-other.s
  llvm/test/MC/ARM/inst-directive-other.s
  llvm/test/MC/ELF/relax-arith.s
  llvm/test/tools/llvm-objdump/ELF/ARM/v5t-subarch.s
  llvm/test/tools/llvm-objdump/X86/disassemble-align.s
  llvm/test/tools/llvm-objdump/X86/elf-disassemble.test
  llvm/tools/llvm-objdump/llvm-objdump.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79309.261726.patch
Type: text/x-patch
Size: 15780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200503/573de086/attachment.bin>


More information about the llvm-commits mailing list