[llvm] 3eef474 - [PPCInstPrinter] Change printBranchOperand(calltarget) to print the target address in hexadecimal form

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 26 08:32:39 PDT 2020


Author: Fangrui Song
Date: 2020-03-26T08:32:29-07:00
New Revision: 3eef47407b7247513f125833abc688cea3a1d218

URL: https://github.com/llvm/llvm-project/commit/3eef47407b7247513f125833abc688cea3a1d218
DIFF: https://github.com/llvm/llvm-project/commit/3eef47407b7247513f125833abc688cea3a1d218.diff

LOG: [PPCInstPrinter] Change printBranchOperand(calltarget) to print the target address in hexadecimal form

```
// llvm-objdump -d output (before)
0: bl .-4
4: bl .+0
8: bl .+4

// llvm-objdump -d output (after) ; GNU objdump -d
0: bl 0xfffffffc / bl 0xfffffffffffffffc
4: bl 0x4
8: bl 0xc
```

Many Operand's are not annotated as OPERAND_PCREL.
They are not affected (e.g. `b .+67108860`). I plan to fix them in future patches.

Modified test/tools/llvm-objdump/ELF/PowerPC/branch-offset.s to test
address space wraparound for powerpc32 and powerpc64.

Reviewed By: sfertile, jhenderson

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

Added: 
    

Modified: 
    lld/test/ELF/ppc32-call-stub-nopic.s
    lld/test/ELF/ppc32-call-stub-pic.s
    lld/test/ELF/ppc32-ifunc-nonpreemptible-nopic.s
    lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s
    lld/test/ELF/ppc32-long-thunk.s
    lld/test/ELF/ppc32-tls-gd.s
    lld/test/ELF/ppc32-tls-ld.s
    lld/test/ELF/ppc32-weak-undef-call.s
    lld/test/ELF/ppc64-bsymbolic-toc-restore.s
    lld/test/ELF/ppc64-call-reach.s
    lld/test/ELF/ppc64-func-entry-points.s
    lld/test/ELF/ppc64-ifunc.s
    lld/test/ELF/ppc64-local-dynamic.s
    lld/test/ELF/ppc64-long-branch-pi.s
    lld/test/ELF/ppc64-long-branch.s
    lld/test/ELF/ppc64-plt-stub.s
    lld/test/ELF/ppc64-rel-calls.s
    lld/test/ELF/ppc64-tls-gd.s
    lld/test/ELF/ppc64-toc-restore-recursive-call.s
    lld/test/ELF/ppc64-toc-restore.s
    lld/test/ELF/ppc64-weak-undef-call.s
    llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
    llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h
    llvm/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll
    llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll
    llvm/test/tools/llvm-objdump/ELF/PowerPC/branch-offset.s

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/ppc32-call-stub-nopic.s b/lld/test/ELF/ppc32-call-stub-nopic.s
index 03ffa5a1e37c..118b52a8db99 100644
--- a/lld/test/ELF/ppc32-call-stub-nopic.s
+++ b/lld/test/ELF/ppc32-call-stub-nopic.s
@@ -20,10 +20,10 @@
 
 ## .got2+0x8000-0x10004 = 0x30000+0x8000-0x10004 = 65536*2+32764
 # CHECK-LABEL: <_start>:
-# CHECK-NEXT:    bl .+16
-# CHECK-NEXT:    bl .+12
-# CHECK-NEXT:    bl .+24
-# CHECK-NEXT:    bl .+20
+# CHECK-NEXT:    bl 0x100101d0
+# CHECK-NEXT:    bl 0x100101d0
+# CHECK-NEXT:    bl 0x100101e0
+# CHECK-NEXT:    bl 0x100101e0
 # CHECK-EMPTY:
 
 ## -fno-PIC call stubs of f and g.

diff  --git a/lld/test/ELF/ppc32-call-stub-pic.s b/lld/test/ELF/ppc32-call-stub-pic.s
index e35367d33686..2c116c596e86 100644
--- a/lld/test/ELF/ppc32-call-stub-pic.s
+++ b/lld/test/ELF/ppc32-call-stub-pic.s
@@ -37,25 +37,34 @@
 # PIE-NEXT:    10210: mflr 30
 # PIE-NEXT:           addis 30, 30, 3
 # PIE-NEXT:           addi 30, 30, -32412
-# SHARED-NEXT: 10230: mflr 30
-# SHARED-NEXT:        addis 30, 30, 3
-# SHARED-NEXT:        addi 30, 30, -32420
-
 ## Two bl 00008000.got2.plt_pic32.f
-# CHECK-NEXT:    bl .+40
-# CHECK-NEXT:    bl .+36
+# PIE-NEXT:           bl 0x10244
+# PIE-NEXT:           bl 0x10244
 ## Two bl 00008000.got2.plt_pic32.g
-# CHECK-NEXT:    bl .+48
-# CHECK-NEXT:    bl .+44
+# PIE-NEXT:           bl 0x10254
+# PIE-NEXT:           bl 0x10254
 ## Two bl 00008000.got2.plt_pic32.h
-# CHECK-NEXT:    bl .+56
-# CHECK-NEXT:    bl .+52
-# CHECK-NEXT:    addis 30, 30, {{.*}}
-# CHECK-NEXT:    addi 30, 30, {{.*}}
+# PIE-NEXT:           bl 0x10264
+# PIE-NEXT:           bl 0x10264
+# PIE-NEXT:           addis 30, 30, {{.*}}
+# PIE-NEXT:           addi 30, 30, {{.*}}
 ## bl 00008000.plt_pic32.f
-# CHECK-NEXT:    bl .+56
+# PIE-NEXT:           bl 0x10274
 ## bl 00008000.plt_pic32.f
-# CHECK-NEXT:    bl .+68
+# PIE-NEXT:           bl 0x10284
+# SHARED-NEXT: 10230: mflr 30
+# SHARED-NEXT:        addis 30, 30, 3
+# SHARED-NEXT:        addi 30, 30, -32420
+# SHARED-NEXT:        bl 0x10264
+# SHARED-NEXT:        bl 0x10264
+# SHARED-NEXT:        bl 0x10274
+# SHARED-NEXT:        bl 0x10274
+# SHARED-NEXT:        bl 0x10284
+# SHARED-NEXT:        bl 0x10284
+# SHARED-NEXT:        addis 30, 30, {{.*}}
+# SHARED-NEXT:        addi 30, 30, {{.*}}
+# SHARED-NEXT:        bl 0x10294
+# SHARED-NEXT:        bl 0x102a4
 # CHECK-EMPTY:
 
 ## -fPIC call stubs of f and g.

diff  --git a/lld/test/ELF/ppc32-ifunc-nonpreemptible-nopic.s b/lld/test/ELF/ppc32-ifunc-nonpreemptible-nopic.s
index 9c2b44558483..179f79efc6ff 100644
--- a/lld/test/ELF/ppc32-ifunc-nonpreemptible-nopic.s
+++ b/lld/test/ELF/ppc32-ifunc-nonpreemptible-nopic.s
@@ -16,7 +16,7 @@
 # CHECK:      <.text>:
 # CHECK-NEXT: 100100e0: blr
 # CHECK:      <_start>:
-# CHECK-NEXT:   bl .+12
+# CHECK-NEXT:   bl 0x100100f0
 # CHECK-NEXT:   lis 9, 4097
 # CHECK-NEXT:   addi 9, 9, 256
 # CHECK-EMPTY:

diff  --git a/lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s b/lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s
index 2e52939642ca..0bb715a191d8 100644
--- a/lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s
+++ b/lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s
@@ -21,7 +21,7 @@
 # CHECK:      <.text>:
 # CHECK-NEXT: 10188: blr
 # CHECK:      <_start>:
-# CHECK-NEXT:   bl .+12
+# CHECK-NEXT:   bl 0x10198
 # CHECK-NEXT:   lis 9, 1
 # CHECK-NEXT:   addi 9, 9, 424
 # CHECK-EMPTY:

diff  --git a/lld/test/ELF/ppc32-long-thunk.s b/lld/test/ELF/ppc32-long-thunk.s
index 21b1eaeff285..57c442f7723d 100644
--- a/lld/test/ELF/ppc32-long-thunk.s
+++ b/lld/test/ELF/ppc32-long-thunk.s
@@ -16,12 +16,12 @@
 # SEC: There are no relocations in this file.
 
 # CHECK:      <_start>:
-# CHECK-NEXT:     2000: bl .+24
-# CHECK-NEXT:           bl .+20
-# CHECK-NEXT:           bl .+16
-# CHECK-NEXT:           bl .+33554428
-# PD-NEXT:              bl .+24
-# PI-NEXT:              bl .+40
+# CHECK-NEXT:     2000: bl 0x2018
+# CHECK-NEXT:           bl 0x2018
+# CHECK-NEXT:           bl 0x2018
+# CHECK-NEXT:           bl 0x2002008
+# PD-NEXT:              bl 0x2028
+# PI-NEXT:              bl 0x2038
 
 ## high = 0x02002008 = 65536*512+8200
 # PD:         <__LongThunk_high>:
@@ -70,8 +70,8 @@ bl .text_high+16  # Need a thunk
 blr
 
 # PD:         02002008 <high>:
-# PD-NEXT:              bl .-33554432
-# PD-NEXT:              bl .+4
+# PD-NEXT:              bl 0x2008
+# PD-NEXT:              bl 0x2002010
 # PD:         <__LongThunk_>:
 # PD-NEXT:     2002010: lis 12, 0
 # PD-NEXT:              addi 12, 12, 8200

diff  --git a/lld/test/ELF/ppc32-tls-gd.s b/lld/test/ELF/ppc32-tls-gd.s
index 847ab83655a4..c3a1ffd36704 100644
--- a/lld/test/ELF/ppc32-tls-gd.s
+++ b/lld/test/ELF/ppc32-tls-gd.s
@@ -31,17 +31,17 @@
 
 ## &DTPMOD(a) - _GLOBAL_OFFSET_TABLE_ = 0x20078 - 0x20078 = 0
 # GD:      addi 3, 31, 0
-# GD-NEXT: bl .+32
+# GD-NEXT: bl 0x1028c
 # GD-NEXT: lwz 3, 0(3)
 
 ## &DTPMOD(b) - _GLOBAL_OFFSET_TABLE_ = 0x20080 - 0x20078 = 8
 # GD-NEXT: addi 3, 31, 8
-# GD-NEXT: bl .+20
+# GD-NEXT: bl 0x1028c
 # GD-NEXT: lwz 3, 0(3)
 
 ## &DTPMOD(c) - _GLOBAL_OFFSET_TABLE_ = 0x20088 - 0x20078 = 16
 # GD-NEXT: addi 3, 9, 16
-# GD-NEXT: bl .+8
+# GD-NEXT: bl 0x1028c
 # GD-NEXT: lwz 3, 0(3)
 
 # NOREL: no relocations

diff  --git a/lld/test/ELF/ppc32-tls-ld.s b/lld/test/ELF/ppc32-tls-ld.s
index de6700bde597..0eda8e95ff20 100644
--- a/lld/test/ELF/ppc32-tls-ld.s
+++ b/lld/test/ELF/ppc32-tls-ld.s
@@ -16,7 +16,7 @@
 
 ## .got - _GLOBAL_OFFSET_TABLE_ = 0
 # LD:      addi 3, 30, 0
-# LD-NEXT: bl .+40
+# LD-NEXT: bl 0x101f8
 ## a at dtprel = st_value(a)-0x8000 = 65540-0x8000 = 65536*1-32764
 ## b at dtprel = st_value(a)-0x8000 = 131080-0x8000 = 65536*2-32760
 # LD-NEXT: addis 9, 3, 1
@@ -30,7 +30,7 @@
 ## It shares In.Got->TlsIndexOff allocated when processing a at got@tlsld.
 ## .got - _GLOBAL_OFFSET_TABLE_ = 0
 # LD-NEXT: addi 3, 9, 0
-# LD-NEXT: bl .+12
+# LD-NEXT: bl 0x101f8
 ## b at dtprel = st_value(a)-0x8000 = 131080-0x8000 = 65536*2-32760
 # LD-NEXT: addis 29, 3, 2
 # LD-NEXT: addi 29, 29, -32760

diff  --git a/lld/test/ELF/ppc32-weak-undef-call.s b/lld/test/ELF/ppc32-weak-undef-call.s
index 3371e429a0c4..dfb45e5fe18c 100644
--- a/lld/test/ELF/ppc32-weak-undef-call.s
+++ b/lld/test/ELF/ppc32-weak-undef-call.s
@@ -9,11 +9,12 @@
 
 ## It does not really matter how we fixup it, but we cannot overflow and
 ## should not generate a call stub (this would waste space).
-# PDE: bl .+0
+# PDE: bl 0x100100b4
 
 ## With -pie or -shared, create a call stub. ld.bfd produces bl .+0
-# PIC: bl .+4
-# PIC: <00000000.plt_pic32.foo>:
+# PIC:       bl 0x[[PLT:[0-9a-f]+]]
+# PIC-EMPTY:
+# PIC-NEXT:  000[[PLT]] <00000000.plt_pic32.foo>:
 
 .weak foo
 bl foo

diff  --git a/lld/test/ELF/ppc64-bsymbolic-toc-restore.s b/lld/test/ELF/ppc64-bsymbolic-toc-restore.s
index 1e3148e24392..a8f821ec9d16 100644
--- a/lld/test/ELF/ppc64-bsymbolic-toc-restore.s
+++ b/lld/test/ELF/ppc64-bsymbolic-toc-restore.s
@@ -3,13 +3,13 @@
 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-bsymbolic-local-def.s  -o %t2.o
 # RUN: ld.lld -Bsymbolic -shared %t1.o %t2.o -o %t
-# RUN: llvm-objdump -d -r %t | FileCheck %s
+# RUN: llvm-objdump -d -r --no-show-raw-insn %t | FileCheck %s
 # RUN: not ld.lld -shared %t1.o %t2.o -o /dev/null 2>&1 | FileCheck --check-prefix=FAIL %s
 
 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-bsymbolic-local-def.s  -o %t2.o
 # RUN: ld.lld -Bsymbolic -shared %t1.o %t2.o -o %t
-# RUN: llvm-objdump -d -r %t | FileCheck %s
+# RUN: llvm-objdump -d -r --no-show-raw-insn %t | FileCheck %s
 # RUN: not ld.lld -shared %t1.o %t2.o -o /dev/null 2>&1 | FileCheck --check-prefix=FAIL %s
 
 # FAIL: call to def lacks nop, can't restore toc
@@ -51,9 +51,9 @@ caller:
 # being called.
 
 # CHECK-LABEL: caller
-# CHECK:         bl .+44
+# CHECK:         bl 0x[[DEF:[0-9a-f]+]]
 # CHECK-NEXT:    mr 31, 3
-# CHECK-NEXT:    bl .+44
+# CHECK-NEXT:    bl 0x[[NOT_DEFINED:[0-9a-f]+]]
 # CHECK-NEXT:    ld 2, 24(1)
 # CHECK-NEXT:    add 3, 3, 31
 # CHECK-NEXT:    addi 1, 1, 32
@@ -64,5 +64,7 @@ caller:
 # CHECK-NEXT:  <def>:
 # CHECK-NEXT:    addis 2, 12, 2
 # CHECK-NEXT:    addi 2, 2, -32456
-# CHECK-NEXT:    li 3, 55
+# CHECK-NEXT:    [[DEF]]: li 3, 55
 # CHECK-NEXT:    blr
+# CHECK-EMPTY:
+# CHECK-NEXT:  00000000000[[NOT_DEFINED]] <__plt_not_defined>:

diff  --git a/lld/test/ELF/ppc64-call-reach.s b/lld/test/ELF/ppc64-call-reach.s
index c54bb051ff3c..b88b146d5528 100644
--- a/lld/test/ELF/ppc64-call-reach.s
+++ b/lld/test/ELF/ppc64-call-reach.s
@@ -58,15 +58,15 @@ test:
 # Check that we are branching to the definitions, and not range-extending
 # thunks.
 # CHECK-LABEL: test
-# CHECK:  10010014:       bl .+33554428
+# CHECK:  10010014:       bl 0x12010010
 # CHECK:  10010024:       b  .+33554428
 
 # NEGOFFSET-LABEL: test
-# NEGOFFSET:  10010014:       bl .-33554432
+# NEGOFFSET:  10010014:       bl 0xe010014
 # NEGOFFSET:  10010024:       b  .+33554432
 
 # THUNK-LABEL: <test>:
-# THUNK: 10010014:       bl .+20
+# THUNK: 10010014:       bl 0x10010028
 # THUNK: 10010024:       b .+20
 
 # .branch_lt[0]

diff  --git a/lld/test/ELF/ppc64-func-entry-points.s b/lld/test/ELF/ppc64-func-entry-points.s
index 30336afa6c8f..4bdea4f359f4 100644
--- a/lld/test/ELF/ppc64-func-entry-points.s
+++ b/lld/test/ELF/ppc64-func-entry-points.s
@@ -70,8 +70,8 @@ glob:
 # point and we branch to start of foo_external_same.
 
 // CHECK-LABEL: <_start>:
-// CHECK:         100101f0: bl .+144
-// CHECK:         10010204: bl .+84
+// CHECK:         100101f0: bl 0x10010280
+// CHECK:         10010204: bl 0x10010258
 // CHECK-LABEL: <foo_external_
diff >:
 // CHECK-NEXT:    10010250: addis 2, 12, 2
 // CHECK-NEXT:    10010254: addi 2, 2, -32696

diff  --git a/lld/test/ELF/ppc64-ifunc.s b/lld/test/ELF/ppc64-ifunc.s
index 804b991990dd..75a3e1072e06 100644
--- a/lld/test/ELF/ppc64-ifunc.s
+++ b/lld/test/ELF/ppc64-ifunc.s
@@ -27,9 +27,9 @@
 # CHECK: <_start>:
 # CHECK-NEXT:                 addis 2, 12, 2
 # CHECK-NEXT:                 addi 2, 2, -32636
-# CHECK-NEXT: 1001021c:       bl .+32
+# CHECK-NEXT: 1001021c:       bl 0x1001023c
 # CHECK-NEXT:                 ld 2, 24(1)
-# CHECK-NEXT: 10010224:       bl .+44
+# CHECK-NEXT: 10010224:       bl 0x10010250
 # CHECK-NEXT:                 ld 2, 24(1)
 # CHECK-NEXT:                 addis 3, 2, -2
 # CHECK-NEXT:                 addi 3, 3, 32748

diff  --git a/lld/test/ELF/ppc64-local-dynamic.s b/lld/test/ELF/ppc64-local-dynamic.s
index 884e9c158393..d7013ee6d192 100644
--- a/lld/test/ELF/ppc64-local-dynamic.s
+++ b/lld/test/ELF/ppc64-local-dynamic.s
@@ -113,7 +113,7 @@ k:
 // Dis:     <test>:
 // Dis:        addis 3, 2, 0
 // Dis-NEXT:   addi 3, 3, -32760
-// Dis-NEXT:   bl .+60
+// Dis-NEXT:   bl 0x10058
 // Dis-NEXT:   ld 2, 24(1)
 // Dis-NEXT:   addis 3, 3, 0
 // Dis-NEXT:   lwa 3, -32768(3)

diff  --git a/lld/test/ELF/ppc64-long-branch-pi.s b/lld/test/ELF/ppc64-long-branch-pi.s
index f49b09ef8f81..dca63878c0e7 100644
--- a/lld/test/ELF/ppc64-long-branch-pi.s
+++ b/lld/test/ELF/ppc64-long-branch-pi.s
@@ -30,10 +30,10 @@
 # RELOC-NEXT: }
 
 # CHECK:      <_start>:
-# CHECK-NEXT:     2000:       bl .+16
-# CHECK-NEXT:                 bl .+33554428
-# CHECK-NEXT:                 bl .+24
-# CHECK-NEXT:                 bl .+36
+# CHECK-NEXT:     2000:       bl 0x2010
+# CHECK-NEXT:                 bl 0x2002000
+# CHECK-NEXT:                 bl 0x2020
+# CHECK-NEXT:                 bl 0x2030
 
 ## &.branch_lt[0] - .TOC. = .branch_lt - (.got+0x8000) = -32752
 # CHECK:      <__long_branch_>:
@@ -65,9 +65,9 @@ bl .text_high+8   # Need a thunk
 bl .text_high+0xc # Need a thunk
 
 # CHECK:      <high_target>:
-# CHECK-NEXT:  2002000:   bl .-33554428
-# CHECK-NEXT:             bl .-33554432
-# CHECK-NEXT:             bl .+8
+# CHECK-NEXT:  2002000:   bl 0x2004
+# CHECK-NEXT:             bl 0x2004
+# CHECK-NEXT:             bl 0x2002010
 
 ## &.branch_lt[3] - .TOC. = .branch_lt - (.got+0x8000) = -32728
 # CHECK:      <__long_branch_>:

diff  --git a/lld/test/ELF/ppc64-long-branch.s b/lld/test/ELF/ppc64-long-branch.s
index c6979e70e1da..35286e101587 100644
--- a/lld/test/ELF/ppc64-long-branch.s
+++ b/lld/test/ELF/ppc64-long-branch.s
@@ -29,10 +29,10 @@
 # BRANCH-BE-NEXT: 0x02002040 00000000 00002008
 
 # CHECK:      <_start>:
-# CHECK-NEXT:     2000:       bl .+24
-# CHECK-NEXT:                 bl .+20
-# CHECK-NEXT:                 bl .+16
-# CHECK-NEXT:                 bl .+33554428
+# CHECK-NEXT:     2000:       bl 0x2018
+# CHECK-NEXT:                 bl 0x2018
+# CHECK-NEXT:                 bl 0x2018
+# CHECK-NEXT:                 bl 0x2002008
 
 ## &.branch_lt[0] - .TOC. = .branch_lt - (.got+0x8000) = -32760
 # CHECK:      <__long_branch_high>:
@@ -63,8 +63,8 @@ blr
 # CHECK-NEXT: <high>:
 # CHECK-NEXT:  2002000:       addis 2, 12, 1
 # CHECK-NEXT:                 addi 2, 2, -32728
-# CHECK-NEXT:                 bl .-33554432
-# CHECK-NEXT:                 bl .+8
+# CHECK-NEXT:                 bl 0x2008
+# CHECK-NEXT:                 bl 0x2002014
 # CHECK:      <__long_branch_>:
 # CHECK-NEXT:  2002014:       addis 12, 2, 0
 # CHECK-NEXT:                 ld 12, -32744(12)

diff  --git a/lld/test/ELF/ppc64-plt-stub.s b/lld/test/ELF/ppc64-plt-stub.s
index 9f89d731f2fb..d21ddbfc7566 100644
--- a/lld/test/ELF/ppc64-plt-stub.s
+++ b/lld/test/ELF/ppc64-plt-stub.s
@@ -24,7 +24,7 @@
 # RELOC: 0x10030010 R_PPC64_JMP_SLOT foo 0x0
 
 # CHECK:      <_start>:
-# CHECK:      10010298: bl .+16
+# CHECK:      10010298: bl 0x100102a8
 
 # CHECK-LABEL: 00000000100102a8 <__plt_foo>:
 # CHECK-NEXT:      std 2, 24(1)

diff  --git a/lld/test/ELF/ppc64-rel-calls.s b/lld/test/ELF/ppc64-rel-calls.s
index 9969239d8e65..366db77197cf 100644
--- a/lld/test/ELF/ppc64-rel-calls.s
+++ b/lld/test/ELF/ppc64-rel-calls.s
@@ -31,8 +31,8 @@ bar:
   nop
   blr
 
-# CHECK:      10010164: bl .-12
+# CHECK:      10010164: bl 0x10010158
 # CHECK-NEXT:           nop
-# CHECK-NEXT: 1001016c: bl .-20
+# CHECK-NEXT: 1001016c: bl 0x10010158
 # CHECK-NEXT:           nop
 # CHECK-NEXT:           blr

diff  --git a/lld/test/ELF/ppc64-tls-gd.s b/lld/test/ELF/ppc64-tls-gd.s
index bb90a7f3943f..90047331762f 100644
--- a/lld/test/ELF/ppc64-tls-gd.s
+++ b/lld/test/ELF/ppc64-tls-gd.s
@@ -27,18 +27,18 @@
 ## &DTPMOD(a) - .TOC. = &.got[0] - (.got+0x8000) = -32768
 # GD:      addis 3, 2, 0
 # GD-NEXT: addi 3, 3, -32768
-# GD-NEXT: bl .+36
+# GD-NEXT: bl 0x103f4
 # GD-NEXT: ld 2, 24(1)
 
 ## &DTPMOD(b) - .TOC. = &.got[2] - (.got+0x8000) = -32752
 # GD-NEXT: addis 3, 2, 0
 # GD-NEXT: addi 3, 3, -32752
-# GD-NEXT: bl .+20
+# GD-NEXT: bl 0x103f4
 # GD-NEXT: ld 2, 24(1)
 
 ## &DTPMOD(b) - .TOC. = &.got[4] - (.got+0x8000) = -32736
 # GD-NEXT: li 3, -32736
-# GD-NEXT: bl .+8
+# GD-NEXT: bl 0x103f4
 # GD-NEXT: ld 2, 24(1)
 
 # NOREL: no relocations

diff  --git a/lld/test/ELF/ppc64-toc-restore-recursive-call.s b/lld/test/ELF/ppc64-toc-restore-recursive-call.s
index aae4a75e909c..a49705a2b654 100644
--- a/lld/test/ELF/ppc64-toc-restore-recursive-call.s
+++ b/lld/test/ELF/ppc64-toc-restore-recursive-call.s
@@ -15,7 +15,7 @@
 # with non-recursive calls.
 
 # CHECK-LABEL: 0000000000010290 <recursive_func>:
-# CHECK:       102b8:       bl .+32
+# CHECK:       102b8:       bl 0x102d8
 # CHECK-NEXT:               ld 2, 24(1)
 
 # CHECK-LABEL: 00000000000102d8 <__plt_recursive_func>:

diff  --git a/lld/test/ELF/ppc64-toc-restore.s b/lld/test/ELF/ppc64-toc-restore.s
index 4db8358e1268..ca5df74f2893 100644
--- a/lld/test/ELF/ppc64-toc-restore.s
+++ b/lld/test/ELF/ppc64-toc-restore.s
@@ -29,9 +29,9 @@ _start:
   nop
   bl bar_local
 // CHECK-LABEL: <_start>:
-// CHECK-NEXT:  100102c8:       bl .+60
+// CHECK-NEXT:  100102c8:       bl 0x10010304
 // CHECK-NEXT:  100102cc:       ld 2, 24(1)
-// CHECK-NEXT:  100102d0:       bl .-16
+// CHECK-NEXT:  100102d0:       bl 0x100102c0
 // CHECK-EMPTY:
 
 # Calling a function in another object file which will have same
@@ -43,8 +43,8 @@ _
diff _object:
   bl foo_not_shared
   nop
 // CHECK-LABEL: <_
diff _object>:
-// CHECK-NEXT:  100102d4:       bl .+28
-// CHECK-NEXT:  100102d8:       bl .+24
+// CHECK-NEXT:  100102d4:       bl 0x100102f0
+// CHECK-NEXT:  100102d8:       bl 0x100102f0
 // CHECK-NEXT:  100102dc:       nop
 
 # Branching to a local function does not need a nop
@@ -61,5 +61,5 @@ last:
   bl foo
   nop
 // CHECK-LABEL: <last>:
-// CHECK-NEXT:  100102e4:       bl .+32
+// CHECK-NEXT:  100102e4:       bl 0x10010304
 // CHECK-NEXT:  100102e8:       ld 2, 24(1)

diff  --git a/lld/test/ELF/ppc64-weak-undef-call.s b/lld/test/ELF/ppc64-weak-undef-call.s
index 018bc7e6a25e..1f6869311708 100644
--- a/lld/test/ELF/ppc64-weak-undef-call.s
+++ b/lld/test/ELF/ppc64-weak-undef-call.s
@@ -24,6 +24,6 @@ _start:
 # be unreachable. But, we should link successfully. We should not, however,
 # generate a .plt entry (this would be wasted space). For now, we do nothing
 # (leaving the zero relative offset present in the input).
-# CHECK: 10010158:       bl .+0
+# CHECK: 10010158:       bl 0x10010158
 # CHECK: 1001015c:       nop
 # CHECK: 10010160:       blr

diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
index 4dc2b3579d4b..c3685e8a4886 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
@@ -413,23 +413,30 @@ void PPCInstPrinter::printU16ImmOperand(const MCInst *MI, unsigned OpNo,
     printOperand(MI, OpNo, O);
 }
 
-void PPCInstPrinter::printBranchOperand(const MCInst *MI, unsigned OpNo,
-                                        raw_ostream &O) {
+void PPCInstPrinter::printBranchOperand(const MCInst *MI, uint64_t Address,
+                                        unsigned OpNo, raw_ostream &O,
+                                        bool RelativeForm) {
   if (!MI->getOperand(OpNo).isImm())
     return printOperand(MI, OpNo, O);
-
-  // Branches can take an immediate operand. This is used by the branch
-  // selection pass to print, for example `.+8` (for ELF) or `$+8` (for AIX) to
-  // express an eight byte displacement from the program counter.
-  if (!TT.isOSAIX())
-    O << ".";
-  else
-    O << "$";
-
   int32_t Imm = SignExtend32<32>((unsigned)MI->getOperand(OpNo).getImm() << 2);
-  if (Imm >= 0)
-    O << "+";
-  O << Imm;
+  if (PrintBranchImmAsAddress && !RelativeForm) {
+    uint64_t Target = Address + Imm;
+    if (!TT.isPPC64())
+      Target &= 0xffffffff;
+    O << formatHex(Target);
+  } else {
+    // Branches can take an immediate operand. This is used by the branch
+    // selection pass to print, for example `.+8` (for ELF) or `$+8` (for AIX)
+    // to express an eight byte displacement from the program counter.
+    if (!TT.isOSAIX())
+      O << ".";
+    else
+      O << "$";
+
+    if (Imm >= 0)
+      O << "+";
+    O << Imm;
+  }
 }
 
 void PPCInstPrinter::printAbsBranchOperand(const MCInst *MI, unsigned OpNo,

diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h
index 93ac2ce30467..6339a425e622 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h
@@ -64,10 +64,10 @@ class PPCInstPrinter : public MCInstPrinter {
   void printS34ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
   void printU16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
   void printImmZeroOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
-  void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
-  void printBranchOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNo,
-                          raw_ostream &O) {
-    printBranchOperand(MI, OpNo, O);
+  void printBranchOperand(const MCInst *MI, uint64_t Address, unsigned OpNo,
+                          raw_ostream &O, bool RelativeForm = false);
+  void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
+    printBranchOperand(MI, 0, OpNo, O, true);
   }
   void printAbsBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
   void printTLSCall(const MCInst *MI, unsigned OpNo, raw_ostream &O);

diff  --git a/llvm/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll b/llvm/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll
index bafda1ca889c..f1850cb3cb9a 100644
--- a/llvm/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll
@@ -105,7 +105,7 @@ declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture r
 ; 32-DIS-NEXT:       10: 7c 08 02 a6                   mflr 0
 ; 32-DIS-NEXT:       14: 90 01 00 08                   stw 0, 8(1)
 ; 32-DIS-NEXT:       18: 94 21 ff c0                   stwu 1, -64(1)
-; 32-DIS-NEXT:       1c: 4b ff ff e5                   bl .-28
+; 32-DIS-NEXT:       1c: 4b ff ff e5                   bl 0x0
 ; 32-DIS-NEXT:       20: 60 00 00 00                   nop
 ; 32-DIS-NEXT:       24: 38 21 00 40                   addi 1, 1, 64
 ; 32-DIS-NEXT:       28: 80 01 00 08                   lwz 0, 8(1)

diff  --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll
index c68017e3150d..25358328b46d 100644
--- a/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll
@@ -415,7 +415,7 @@ declare i32 @bar(i32)
 ; DIS-NEXT:        4: 90 01 00 08                   stw 0, 8(1)
 ; DIS-NEXT:        8: 94 21 ff c0                   stwu 1, -64(1)
 ; DIS-NEXT:        c: 38 60 00 01                   li 3, 1
-; DIS-NEXT:       10: 4b ff ff f1                   bl .-16
+; DIS-NEXT:       10: 4b ff ff f1                   bl 0x0
 ; DIS-NEXT:       14: 60 00 00 00                   nop
 ; DIS-NEXT:       18: 80 82 00 00                   lwz 4, 0(2)
 ; DIS-NEXT:       1c: 80 a2 00 04                   lwz 5, 4(2)

diff  --git a/llvm/test/tools/llvm-objdump/ELF/PowerPC/branch-offset.s b/llvm/test/tools/llvm-objdump/ELF/PowerPC/branch-offset.s
index e78e4c16eab5..73e3a68c6d9c 100644
--- a/llvm/test/tools/llvm-objdump/ELF/PowerPC/branch-offset.s
+++ b/llvm/test/tools/llvm-objdump/ELF/PowerPC/branch-offset.s
@@ -8,10 +8,10 @@
 # RUN: llvm-objdump -d --no-show-raw-insn %t.64.o | FileCheck --check-prefixes=ELF64,CHECK %s
 
 # CHECK-LABEL: <bl>:
-# ELF32-NEXT:   bl .-4
-# ELF64-NEXT:   bl .-4
-# CHECK-NEXT:   bl .+0
-# CHECK-NEXT:   bl .+4
+# ELF32-NEXT:   bl 0xfffffffc
+# ELF64-NEXT:   bl 0xfffffffffffffffc
+# CHECK-NEXT:   bl 0x4
+# CHECK-NEXT:   bl 0xc
 
 bl:
   bl .-4


        


More information about the llvm-commits mailing list