diff --git a/lld/test/ELF/ppc32-call-stub-nopic.s b/lld/test/ELF/ppc32-call-stub-nopic.s --- 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 --- 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 --- 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 --- 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 --- 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 @@ blr # PD: 02002008 : -# 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 --- 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 --- 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@dtprel = st_value(a)-0x8000 = 65540-0x8000 = 65536*1-32764 ## b@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@got@tlsld. ## .got - _GLOBAL_OFFSET_TABLE_ = 0 # LD-NEXT: addi 3, 9, 0 -# LD-NEXT: bl .+12 +# LD-NEXT: bl 0x101f8 ## b@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 --- 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 --- 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 @@ # 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 @@ # CHECK-NEXT: : # 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 --- a/lld/test/ELF/ppc64-call-reach.s +++ b/lld/test/ELF/ppc64-call-reach.s @@ -58,15 +58,15 @@ # 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: : -# 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 --- a/lld/test/ELF/ppc64-func-entry-points.s +++ b/lld/test/ELF/ppc64-func-entry-points.s @@ -70,8 +70,8 @@ # 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: : // 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 --- 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 --- a/lld/test/ELF/ppc64-local-dynamic.s +++ b/lld/test/ELF/ppc64-local-dynamic.s @@ -113,7 +113,7 @@ // Dis: : // 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 --- 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+0xc # Need a thunk # CHECK: : -# 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 --- 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 @@ # CHECK-NEXT: : # 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 --- 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 --- a/lld/test/ELF/ppc64-rel-calls.s +++ b/lld/test/ELF/ppc64-rel-calls.s @@ -31,8 +31,8 @@ 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 --- 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 --- 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 : -# 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 --- a/lld/test/ELF/ppc64-toc-restore.s +++ b/lld/test/ELF/ppc64-toc-restore.s @@ -29,9 +29,9 @@ 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 @@ 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 @@ bl foo nop // CHECK-LABEL: : -// 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 --- a/lld/test/ELF/ppc64-weak-undef-call.s +++ b/lld/test/ELF/ppc64-weak-undef-call.s @@ -24,6 +24,6 @@ # 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.h b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h @@ -64,10 +64,10 @@ 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/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp @@ -413,23 +413,30 @@ 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/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll b/llvm/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll --- a/llvm/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll +++ b/llvm/test/CodeGen/PowerPC/aix-user-defined-memcpy.ll @@ -105,7 +105,7 @@ ; 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 --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll @@ -415,7 +415,7 @@ ; 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 --- 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: : -# 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