[all-commits] [llvm/llvm-project] 87de9a: [X86InstPrinter] Change printPCRelImm to print the...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Mar 26 08:29:11 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 87de9a0786d922a1b52db6cd8b12f642d1d00d85
      https://github.com/llvm/llvm-project/commit/87de9a0786d922a1b52db6cd8b12f642d1d00d85
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-03-26 (Thu, 26 Mar 2020)

  Changed paths:
    M lld/test/COFF/delayimports32.test
    M lld/test/COFF/imports.test
    M lld/test/COFF/lto-comdat.ll
    M lld/test/COFF/lto.ll
    M lld/test/ELF/comdat.s
    M lld/test/ELF/gnu-ifunc-i386.s
    M lld/test/ELF/gnu-ifunc-noplt-i386.s
    M lld/test/ELF/gnu-ifunc-noplt.s
    M lld/test/ELF/gnu-ifunc-plt-i386.s
    M lld/test/ELF/gnu-ifunc-plt.s
    M lld/test/ELF/gnu-ifunc-shared.s
    M lld/test/ELF/gnu-ifunc.s
    M lld/test/ELF/i386-feature-cet.s
    M lld/test/ELF/i386-plt.s
    M lld/test/ELF/i386-reloc-large-addend.s
    M lld/test/ELF/i386-reloc-range.s
    M lld/test/ELF/i386-retpoline-nopic-linkerscript.s
    M lld/test/ELF/i386-retpoline-nopic.s
    M lld/test/ELF/i386-retpoline-pic-linkerscript.s
    M lld/test/ELF/i386-retpoline-pic.s
    M lld/test/ELF/i386-tls-dynamic.s
    M lld/test/ELF/local-got-pie.s
    M lld/test/ELF/local-got-shared.s
    M lld/test/ELF/local-got.s
    M lld/test/ELF/lto/linker-script-symbols-ipo.ll
    M lld/test/ELF/no-inhibit-exec.s
    M lld/test/ELF/pre_init_fini_array_missing.s
    M lld/test/ELF/relocation-i686.s
    M lld/test/ELF/relocation.s
    M lld/test/ELF/startstop.s
    M lld/test/ELF/x86-64-feature-cet.s
    M lld/test/ELF/x86-64-gotpc-relax.s
    M lld/test/ELF/x86-64-plt.s
    M lld/test/ELF/x86-64-retpoline-linkerscript.s
    M lld/test/ELF/x86-64-retpoline-znow-linkerscript.s
    M lld/test/ELF/x86-64-retpoline-znow-static-iplt.s
    M lld/test/ELF/x86-64-retpoline-znow.s
    M lld/test/ELF/x86-64-retpoline.s
    M llvm/include/llvm/MC/MCInstPrinter.h
    M llvm/lib/Target/X86/MCTargetDesc/X86InstPrinterCommon.cpp
    M llvm/test/CodeGen/X86/callbr-asm-obj-file.ll
    M llvm/test/LTO/Resolution/X86/not-prevailing.ll
    M llvm/test/MC/COFF/cv-inline-linetable-unlikely.s
    M llvm/test/MC/COFF/cv-loc-unreachable-2.s
    M llvm/test/MC/COFF/cv-loc-unreachable.s
    M llvm/test/MC/X86/AlignedBundling/misaligned-bundle-group.s
    M llvm/test/MC/X86/AlignedBundling/single-inst-bundling.s
    M llvm/test/MC/X86/align-via-padding.s
    M llvm/test/MC/X86/align-via-relaxation.s
    M llvm/test/MC/X86/x86-branch-relaxation.s
    M llvm/test/Object/X86/objdump-disassembly-inline-relocations.test
    M llvm/test/Object/X86/objdump-trivial-object.test
    M llvm/test/tools/llvm-objdump/ELF/call-absolute-symbol.test
    M llvm/test/tools/llvm-objdump/MachO/hex-displacement.test
    M llvm/test/tools/llvm-objdump/X86/coff-disassemble-export.test
    M llvm/test/tools/llvm-objdump/X86/demangle.s
    M llvm/test/tools/llvm-objdump/X86/elf-disassemble-no-symtab.test
    M llvm/test/tools/llvm-objdump/X86/elf-disassemble-relocs.test
    M llvm/test/tools/llvm-objdump/X86/elf-disassemble-symbol-references.yaml
    M llvm/test/tools/llvm-objdump/X86/section-filter-relocs.test
    M llvm/tools/llvm-objdump/llvm-objdump.cpp

  Log Message:
  -----------
  [X86InstPrinter] Change printPCRelImm to print the target address in hexadecimal form

```
// llvm-objdump -d output (before)
400000: e8 0b 00 00 00   callq 11
400005: e8 0b 00 00 00   callq 11

// llvm-objdump -d output (after)
400000: e8 0b 00 00 00  callq 0x400010
400005: e8 0b 00 00 00  callq 0x400015

// GNU objdump -d. The lack of 0x is not ideal because the result cannot be re-assembled
400000: e8 0b 00 00 00  callq 400010
400005: e8 0b 00 00 00  callq 400015
```

In llvm-objdump, we pass the address of the next MCInst. Ideally we
should just thread the address of the current address, unfortunately we
cannot call X86MCCodeEmitter::encodeInstruction (X86MCCodeEmitter
requires MCInstrInfo and MCContext) to get the length of the MCInst.

MCInstPrinter::printInst has other callers (e.g llvm-mc -filetype=asm, llvm-mca) which set Address to 0.
They leave MCInstPrinter::PrintBranchImmAsAddress as false and this change is a no-op for them.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D76580




More information about the All-commits mailing list