2019-08-30 10:57:33 +08:00
|
|
|
; RUN: llc -relocation-model=static -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
|
|
|
|
; RUN: -O0 < %s -mcpu=ppc64 | FileCheck -check-prefix=OPT0 %s
|
|
|
|
; RUN: llc -relocation-model=static -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
|
|
|
|
; RUN: -O1 < %s -mcpu=ppc64 | FileCheck -check-prefix=OPT1 %s
|
2017-08-02 06:20:41 +08:00
|
|
|
; RUN: llc -verify-machineinstrs -O0 < %s -mtriple=ppc32-- -mcpu=ppc | FileCheck -check-prefix=OPT0-PPC32 %s
|
2019-04-25 06:12:22 +08:00
|
|
|
; RUN: llc -relocation-model=pic -verify-machineinstrs -O0 < %s -mtriple=ppc32-- -mcpu=ppc | FileCheck -check-prefix=OPT0-PPC32-PIC %s
|
2012-06-05 01:36:38 +08:00
|
|
|
|
|
|
|
@a = thread_local global i32 0, align 4
|
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
;OPT0-LABEL: localexec:
|
|
|
|
;OPT1-LABEL: localexec:
|
2012-06-05 01:36:38 +08:00
|
|
|
define i32 @localexec() nounwind {
|
|
|
|
entry:
|
2013-02-26 00:44:35 +08:00
|
|
|
;OPT0: addis [[REG1:[0-9]+]], 13, a@tprel@ha
|
2018-10-30 04:10:42 +08:00
|
|
|
;OPT0-NEXT: addi [[REG2:[0-9]+]], [[REG1]], a@tprel@l
|
|
|
|
;OPT0-NEXT: li [[REG3:[0-9]+]], 42
|
|
|
|
;OPT0: stw [[REG3]], 0([[REG2]])
|
2013-02-26 00:44:35 +08:00
|
|
|
;OPT1: addis [[REG1:[0-9]+]], 13, a@tprel@ha
|
2018-10-30 04:10:42 +08:00
|
|
|
;OPT1-NEXT: li [[REG3:[0-9]+]], 42
|
|
|
|
;OPT1: stw [[REG3]], a@tprel@l([[REG1]])
|
2012-06-05 01:36:38 +08:00
|
|
|
store i32 42, i32* @a, align 4
|
|
|
|
ret i32 0
|
|
|
|
}
|
2013-12-12 06:25:39 +08:00
|
|
|
|
|
|
|
; Test correct assembly code generation for thread-local storage
|
|
|
|
; using the initial-exec model.
|
|
|
|
|
2019-04-25 06:12:22 +08:00
|
|
|
@a2 = external thread_local(initialexec) global i32
|
2013-12-12 06:25:39 +08:00
|
|
|
|
|
|
|
define signext i32 @main2() nounwind {
|
|
|
|
entry:
|
|
|
|
%retval = alloca i32, align 4
|
|
|
|
store i32 0, i32* %retval
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* @a2, align 4
|
2013-12-12 06:25:39 +08:00
|
|
|
ret i32 %0
|
|
|
|
}
|
|
|
|
|
|
|
|
; OPT1-LABEL: main2:
|
|
|
|
; OPT1: addis [[REG1:[0-9]+]], 2, a2@got@tprel@ha
|
|
|
|
; OPT1: ld [[REG2:[0-9]+]], a2@got@tprel@l([[REG1]])
|
|
|
|
; OPT1: add {{[0-9]+}}, [[REG2]], a2@tls
|
|
|
|
|
2013-12-21 02:08:54 +08:00
|
|
|
;OPT0-PPC32-LABEL: main2:
|
|
|
|
;OPT0-PPC32: li [[REG1:[0-9]+]], _GLOBAL_OFFSET_TABLE_@l
|
|
|
|
;OPT0-PPC32: addis [[REG1]], [[REG1]], _GLOBAL_OFFSET_TABLE_@ha
|
[PPC32] Emit R_PPC_GOT_TPREL16 instead R_PPC_GOT_TPREL16_LO
Unlike ppc64, which has ADDISgotTprelHA+LDgotTprelL pairs,
ppc32 just uses LDgotTprelL32, so it does not make lots of sense to use
_LO without a paired _HA.
Emit R_PPC_GOT_TPREL16 instead R_PPC_GOT_TPREL16_LO to match GCC, and
get better linker relocation check. Note, R_PPC_GOT_TPREL16_{HA,LO}
don't have good linker support:
(a) lld does not support R_PPC_GOT_TPREL16_{HA,LO}.
(b) Top of tree ld.bfd does not support R_PPC_GOT_REL16_HA Initial-Exec -> Local-Exec relaxation:
// a.o
addis 3, 3, tsd_tls@got@tprel@ha
lwz 3, tsd_tls@got@tprel@l(3)
add 3, 3, tsd_tls@tls
// b.o
.section .tdata,"awT"; .globl tsd_tls; tsd_tls:
// ld/ld-new a.o b.o
internal error, aborting at ../../bfd/elf32-ppc.c:7952 in ppc_elf_relocate_section
Reviewed By: adalava
Differential Revision: https://reviews.llvm.org/D66925
llvm-svn: 370426
2019-08-30 10:20:49 +08:00
|
|
|
;OPT0-PPC32: lwz [[REG2:[0-9]+]], a2@got@tprel([[REG1]])
|
2013-12-21 02:08:54 +08:00
|
|
|
;OPT0-PPC32: add 3, [[REG2]], a2@tls
|
2019-04-25 06:12:22 +08:00
|
|
|
|
|
|
|
;OPT0-PPC32-PIC-LABEL: main2:
|
|
|
|
;OPT0-PPC32-PIC: .long _GLOBAL_OFFSET_TABLE_-{{.*}}
|
|
|
|
;OPT0-PPC32-PIC-NOT: li {{[0-9]+}}, _GLOBAL_OFFSET_TABLE_@l
|
|
|
|
;OPT0-PPC32-PIC-NOT: addis {{[0-9]+}}, {{[0-9+]}}, _GLOBAL_OFFSET_TABLE_@ha
|
|
|
|
;OPT0-PPC32-PIC-NOT: bl __tls_get_addr(a2@tlsgd)@PLT
|
[PPC32] Emit R_PPC_GOT_TPREL16 instead R_PPC_GOT_TPREL16_LO
Unlike ppc64, which has ADDISgotTprelHA+LDgotTprelL pairs,
ppc32 just uses LDgotTprelL32, so it does not make lots of sense to use
_LO without a paired _HA.
Emit R_PPC_GOT_TPREL16 instead R_PPC_GOT_TPREL16_LO to match GCC, and
get better linker relocation check. Note, R_PPC_GOT_TPREL16_{HA,LO}
don't have good linker support:
(a) lld does not support R_PPC_GOT_TPREL16_{HA,LO}.
(b) Top of tree ld.bfd does not support R_PPC_GOT_REL16_HA Initial-Exec -> Local-Exec relaxation:
// a.o
addis 3, 3, tsd_tls@got@tprel@ha
lwz 3, tsd_tls@got@tprel@l(3)
add 3, 3, tsd_tls@tls
// b.o
.section .tdata,"awT"; .globl tsd_tls; tsd_tls:
// ld/ld-new a.o b.o
internal error, aborting at ../../bfd/elf32-ppc.c:7952 in ppc_elf_relocate_section
Reviewed By: adalava
Differential Revision: https://reviews.llvm.org/D66925
llvm-svn: 370426
2019-08-30 10:20:49 +08:00
|
|
|
;OPT0-PPC32-PIC: lwz {{[0-9]+}}, a2@got@tprel({{[0-9]+}})
|