1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[AArch64InstPrinter] Change printAlignedLabel to print the target address in hexadecimal form

Similar to D76580 (x86) and D76591 (PPC).

```
// llvm-objdump -d output (before)
10000: 08 00 00 94                   bl      #32
10004: 08 00 00 94                   bl      #32

// llvm-objdump -d output (after)
10000: 08 00 00 94                   bl      0x10020
10004: 08 00 00 94                   bl      0x10024

// GNU objdump -d. The lack of 0x is not ideal due to ambiguity.
10000:       94000008        bl      10020 <bar+0x18>
10004:       94000008        bl      10024 <bar+0x1c>
```

The new output makes it easier to find the jump target.

Differential Revision: https://reviews.llvm.org/D77853
This commit is contained in:
Fangrui Song 2020-04-09 18:46:35 -07:00
parent 5274132056
commit 290d634505
4 changed files with 13 additions and 9 deletions

View File

@ -1356,7 +1356,11 @@ void AArch64InstPrinter::printAlignedLabel(const MCInst *MI, uint64_t Address,
// If the label has already been resolved to an immediate offset (say, when
// we're running the disassembler), just print the immediate.
if (Op.isImm()) {
O << "#" << formatImm(Op.getImm() * 4);
int64_t Offset = Op.getImm() * 4;
if (PrintBranchImmAsAddress)
O << formatHex(Address + Offset);
else
O << "#" << formatImm(Offset);
return;
}

View File

@ -9,9 +9,9 @@
; CHECK-LABEL: <test1>:
; CHECK-LABEL: <$d.1>:
; CHECK-LABEL: <$x.2>:
; CHECK-NEXT: b #16 <$x.4+0x4>
; CHECK-NEXT: b 0x30 <$x.4+0x4>
; CHECK-LABEL: <$x.4>:
; CHECK-NEXT: b #4 <$x.4+0x4>
; CHECK-NEXT: b 0x30 <$x.4+0x4>
; CHECK-NEXT: mov w0, wzr
; CHECK-NEXT: ldr x30, [sp], #16
; CHECK-NEXT: ret
@ -41,10 +41,10 @@ declare dso_local i32 @g(...) local_unnamed_addr
declare dso_local i32 @i(...) local_unnamed_addr
; CHECK-LABEL: <test2>:
; CHECK: bl #0 <test2+0x18>
; CHECK: bl {{.*}} <test2+0x18>
; CHECK-LABEL: <$d.5>:
; CHECK-LABEL: <$x.6>:
; CHECK-NEXT: b #-20 <test2+0x18>
; CHECK-NEXT: b {{.*}} <test2+0x18>
define hidden i32 @test2() local_unnamed_addr {
%1 = load i32, i32* @l, align 4
%2 = icmp eq i32 %1, 0
@ -73,9 +73,9 @@ define hidden i32 @test2() local_unnamed_addr {
; CHECK-LABEL: <test3>:
; CHECK-LABEL: <$d.9>:
; CHECK-LABEL: <$x.10>:
; CHECK-NEXT: b #-20 <test3+0x18>
; CHECK-NEXT: b {{.*}} <test3+0x18>
; CHECK-LABEL: <$x.12>:
; CHECK-NEXT: b #4 <$x.12+0x4>
; CHECK-NEXT: b {{.*}} <$x.12+0x4>
; CHECK-NEXT: mov w0, wzr
; CHECK-NEXT: ldr x30, [sp], #16
; CHECK-NEXT: ret

View File

@ -13,7 +13,7 @@ entry:
ret i32 %0
}
; CHECK-LABEL: <bar>:
; CHECK: 40 00 00 58 ldr x0, #8
; CHECK: 40 00 00 58 ldr x0, 0x10
; CHECK: c0 03 5f d6 ret
; Make sure the constant pool entry comes after the return
; CHECK-LABEL: <$d.1>:

View File

@ -1,3 +1,3 @@
// RUN: llvm-objdump -d %p/Inputs/kextbundle.macho-aarch64 | FileCheck %s
CHECK: 4008: 03 00 00 94 bl #12 <_bar.stub>
CHECK: 4008: 03 00 00 94 bl 0x4014 <_bar.stub>