2017-08-02 08:28:10 +08:00
|
|
|
; RUN: llc < %s -emulated-tls -mtriple=i386-linux-gnu | FileCheck -check-prefix=X32 %s
|
|
|
|
; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=X64 %s
|
|
|
|
; RUN: llc < %s -emulated-tls -mtriple=i386-linux-android | FileCheck -check-prefix=X32 %s
|
|
|
|
; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s
|
2015-07-29 00:24:05 +08:00
|
|
|
|
2018-03-01 01:48:55 +08:00
|
|
|
; RUN: llc < %s -mtriple=i386-linux-gnu | FileCheck -check-prefix=NoEMU %s
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=NoEMU %s
|
|
|
|
; RUN: llc < %s -mtriple=i386-linux-android | FileCheck -check-prefix=X32 %s
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s
|
|
|
|
|
2015-07-29 00:24:05 +08:00
|
|
|
; Copied from tls.ll; emulated TLS model is not implemented
|
2018-03-01 01:48:55 +08:00
|
|
|
; for *-pc-win32 and *-pc-windows targets yet.
|
|
|
|
|
|
|
|
; NoEMU-NOT: __emutls
|
2015-07-29 00:24:05 +08:00
|
|
|
|
|
|
|
; Use my_emutls_get_address like __emutls_get_address.
|
|
|
|
@my_emutls_v_xyz = external global i8*, align 4
|
|
|
|
declare i8* @my_emutls_get_address(i8*)
|
|
|
|
|
|
|
|
define i32 @my_get_xyz() {
|
|
|
|
; X32-LABEL: my_get_xyz:
|
|
|
|
; X32: movl $my_emutls_v_xyz, (%esp)
|
|
|
|
; X32-NEXT: calll my_emutls_get_address
|
|
|
|
; X32-NEXT: movl (%eax), %eax
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
2020-04-03 22:15:17 +08:00
|
|
|
;
|
2015-07-29 00:24:05 +08:00
|
|
|
; X64-LABEL: my_get_xyz:
|
|
|
|
; X64: movl $my_emutls_v_xyz, %edi
|
|
|
|
; X64-NEXT: callq my_emutls_get_address
|
|
|
|
; X64-NEXT: movl (%rax), %eax
|
2015-11-24 06:17:44 +08:00
|
|
|
; X64-NEXT: popq %rcx
|
2018-04-24 18:32:08 +08:00
|
|
|
; X64-NEXT: .cfi_def_cfa_offset 8
|
2015-07-29 00:24:05 +08:00
|
|
|
; X64-NEXT: retq
|
|
|
|
entry:
|
|
|
|
%call = call i8* @my_emutls_get_address(i8* bitcast (i8** @my_emutls_v_xyz to i8*))
|
|
|
|
%0 = bitcast i8* %call to i32*
|
|
|
|
%1 = load i32, i32* %0, align 4
|
|
|
|
ret i32 %1
|
|
|
|
}
|
|
|
|
|
|
|
|
@i1 = thread_local global i32 15
|
|
|
|
@i2 = external thread_local global i32
|
|
|
|
@i3 = internal thread_local global i32 15
|
|
|
|
@i4 = hidden thread_local global i32 15
|
|
|
|
@i5 = external hidden thread_local global i32
|
|
|
|
@s1 = thread_local global i16 15
|
|
|
|
@b1 = thread_local global i8 0
|
|
|
|
|
|
|
|
define i32 @f1() {
|
|
|
|
; X32-LABEL: f1:
|
|
|
|
; X32: movl $__emutls_v.i1, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: movl (%eax), %eax
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
2020-04-03 22:15:17 +08:00
|
|
|
;
|
2015-07-29 00:24:05 +08:00
|
|
|
; X64-LABEL: f1:
|
|
|
|
; X64: movl $__emutls_v.i1, %edi
|
|
|
|
; X64-NEXT: callq __emutls_get_address
|
|
|
|
; X64-NEXT: movl (%rax), %eax
|
2015-11-24 06:17:44 +08:00
|
|
|
; X64-NEXT: popq %rcx
|
2018-04-24 18:32:08 +08:00
|
|
|
; X64-NEXT: .cfi_def_cfa_offset 8
|
2015-07-29 00:24:05 +08:00
|
|
|
; X64-NEXT: retq
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i32, i32* @i1
|
|
|
|
ret i32 %tmp1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32* @f2() {
|
|
|
|
; X32-LABEL: f2:
|
|
|
|
; X32: movl $__emutls_v.i1, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
2020-04-03 22:15:17 +08:00
|
|
|
;
|
2015-07-29 00:24:05 +08:00
|
|
|
; X64-LABEL: f2:
|
|
|
|
; X64: movl $__emutls_v.i1, %edi
|
|
|
|
; X64-NEXT: callq __emutls_get_address
|
2015-11-24 06:17:44 +08:00
|
|
|
; X64-NEXT: popq %rcx
|
2018-04-24 18:32:08 +08:00
|
|
|
; X64-NEXT: .cfi_def_cfa_offset 8
|
2015-07-29 00:24:05 +08:00
|
|
|
; X64-NEXT: retq
|
|
|
|
entry:
|
|
|
|
ret i32* @i1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @f3() nounwind {
|
|
|
|
; X32-LABEL: f3:
|
|
|
|
; X32: movl $__emutls_v.i2, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: movl (%eax), %eax
|
|
|
|
; X32-NEXT: addl $12, %esp
|
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i32, i32* @i2
|
|
|
|
ret i32 %tmp1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32* @f4() {
|
|
|
|
; X32-LABEL: f4:
|
|
|
|
; X32: movl $__emutls_v.i2, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
ret i32* @i2
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @f5() nounwind {
|
|
|
|
; X32-LABEL: f5:
|
|
|
|
; X32: movl $__emutls_v.i3, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: movl (%eax), %eax
|
|
|
|
; X32-NEXT: addl $12, %esp
|
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i32, i32* @i3
|
|
|
|
ret i32 %tmp1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32* @f6() {
|
|
|
|
; X32-LABEL: f6:
|
|
|
|
; X32: movl $__emutls_v.i3, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
ret i32* @i3
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @f7() {
|
|
|
|
; X32-LABEL: f7:
|
2020-01-23 04:27:17 +08:00
|
|
|
; X32: movl $.L__emutls_v.i4$local, (%esp)
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: movl (%eax), %eax
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i32, i32* @i4
|
|
|
|
ret i32 %tmp1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32* @f8() {
|
|
|
|
; X32-LABEL: f8:
|
2020-01-23 04:27:17 +08:00
|
|
|
; X32: movl $.L__emutls_v.i4$local, (%esp)
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
ret i32* @i4
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @f9() {
|
|
|
|
; X32-LABEL: f9:
|
|
|
|
; X32: movl $__emutls_v.i5, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: movl (%eax), %eax
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i32, i32* @i5
|
|
|
|
ret i32 %tmp1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32* @f10() {
|
|
|
|
; X32-LABEL: f10:
|
|
|
|
; X32: movl $__emutls_v.i5, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
ret i32* @i5
|
|
|
|
}
|
|
|
|
|
|
|
|
define i16 @f11() {
|
|
|
|
; X32-LABEL: f11:
|
|
|
|
; X32: movl $__emutls_v.s1, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: movzwl (%eax), %eax
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i16, i16* @s1
|
|
|
|
ret i16 %tmp1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @f12() {
|
|
|
|
; X32-LABEL: f12:
|
|
|
|
; X32: movl $__emutls_v.s1, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: movswl (%eax), %eax
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i16, i16* @s1
|
|
|
|
%tmp2 = sext i16 %tmp1 to i32
|
|
|
|
ret i32 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
define i8 @f13() {
|
|
|
|
; X32-LABEL: f13:
|
|
|
|
; X32: movl $__emutls_v.b1, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: movb (%eax), %al
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i8, i8* @b1
|
|
|
|
ret i8 %tmp1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @f14() {
|
|
|
|
; X32-LABEL: f14:
|
|
|
|
; X32: movl $__emutls_v.b1, (%esp)
|
|
|
|
; X32-NEXT: calll __emutls_get_address
|
|
|
|
; X32-NEXT: movsbl (%eax), %eax
|
|
|
|
; X32-NEXT: addl $12, %esp
|
2018-04-24 18:32:08 +08:00
|
|
|
; X32-NEXT: .cfi_def_cfa_offset 4
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%tmp1 = load i8, i8* @b1
|
|
|
|
%tmp2 = sext i8 %tmp1 to i32
|
|
|
|
ret i32 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;; 32-bit __emutls_v. and __emutls_t.
|
|
|
|
|
|
|
|
; X32 .section .data.rel.local,
|
|
|
|
; X32-LABEL: __emutls_v.i1:
|
|
|
|
; X32-NEXT: .long 4
|
|
|
|
; X32-NEXT: .long 4
|
|
|
|
; X32-NEXT: .long 0
|
|
|
|
; X32-NEXT: .long __emutls_t.i1
|
|
|
|
|
|
|
|
; X32 .section .rodata,
|
|
|
|
; X32-LABEL: __emutls_t.i1:
|
|
|
|
; X32-NEXT: .long 15
|
|
|
|
|
|
|
|
; X32-NOT: __emutls_v.i2
|
|
|
|
|
|
|
|
; X32 .section .data.rel.local,
|
|
|
|
; X32-LABEL: __emutls_v.i3:
|
|
|
|
; X32-NEXT: .long 4
|
|
|
|
; X32-NEXT: .long 4
|
|
|
|
; X32-NEXT: .long 0
|
|
|
|
; X32-NEXT: .long __emutls_t.i3
|
|
|
|
|
|
|
|
; X32 .section .rodata,
|
|
|
|
; X32-LABEL: __emutls_t.i3:
|
|
|
|
; X32-NEXT: .long 15
|
|
|
|
|
|
|
|
; X32 .section .data.rel.local,
|
|
|
|
; X32-LABEL: __emutls_v.i4:
|
[AsmPrinter][ELF] Define local aliases (.Lfoo$local) for GlobalObjects
For `MC_GlobalAddress` operands referencing **certain** GlobalObjects,
we can lower them to STB_LOCAL aliases to avoid costs brought by
assembler/linker's conservative decisions about symbol interposition:
* An assembler conservatively assumes a global default visibility symbol interposable (ELF
semantics). So relocations in object files are needed even if the code generator assumed
the definition exact and non-interposable.
* The relocations can cause the creation of PLT entries on some targets for -shared links.
A linker conservatively assumes a global default visibility symbol interposable (if not
otherwise constrained by -Bsymbolic/--dynamic-list/VER_NDX_LOCAL/etc).
"certain" refers to GlobalObjects in the intersection of
`hasExactDefinition() and !isInterposable()`: `external`, `appending`, `internal`, `private`.
Local linkages (`internal` and `private`) cannot be interposed. `appending` is for very
few objects LLVM interpret specially. So the set just includes `external`.
This patch emits STB_LOCAL aliases (.Lfoo$local) for such GlobalObjects, so that targets can lower
MC_GlobalAddress operands to STB_LOCAL aliases if applicable.
We may extend the scope and include GlobalAlias in the future.
LLVM's existing -fno-semantic-interposition behaviors give us license to do such optimizations:
* Various optimizations (ipconstprop, inliner, sccp, sroa, etc) treat normal ExternalLinkage
GlobalObjects as non-interposable.
* Before D72197, MC resolved a PC-relative VK_None fixup to a non-local symbol at assembly time (no
outstanding relocation), if the target is defined in the same section. Put it simply, even if IR
optimizations failed to optimize and allowed interposition for the function call in
`void foo() {} void bar() { foo(); }`, the assembler would disallow it.
This patch sets up AsmPrinter infrastructure to make -fno-semantic-interposition more so.
With and without the patch, the object file output should be identical:
`.Lfoo$local` does not take a symbol table entry.
Reviewed By: sfertile
Differential Revision: https://reviews.llvm.org/D73228
2020-01-23 04:26:04 +08:00
|
|
|
; X32-NEXT: .L__emutls_v.i4$local:
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: .long 4
|
|
|
|
; X32-NEXT: .long 4
|
|
|
|
; X32-NEXT: .long 0
|
|
|
|
; X32-NEXT: .long __emutls_t.i4
|
|
|
|
|
|
|
|
; X32 .section .rodata,
|
|
|
|
; X32-LABEL: __emutls_t.i4:
|
[AsmPrinter][ELF] Define local aliases (.Lfoo$local) for GlobalObjects
For `MC_GlobalAddress` operands referencing **certain** GlobalObjects,
we can lower them to STB_LOCAL aliases to avoid costs brought by
assembler/linker's conservative decisions about symbol interposition:
* An assembler conservatively assumes a global default visibility symbol interposable (ELF
semantics). So relocations in object files are needed even if the code generator assumed
the definition exact and non-interposable.
* The relocations can cause the creation of PLT entries on some targets for -shared links.
A linker conservatively assumes a global default visibility symbol interposable (if not
otherwise constrained by -Bsymbolic/--dynamic-list/VER_NDX_LOCAL/etc).
"certain" refers to GlobalObjects in the intersection of
`hasExactDefinition() and !isInterposable()`: `external`, `appending`, `internal`, `private`.
Local linkages (`internal` and `private`) cannot be interposed. `appending` is for very
few objects LLVM interpret specially. So the set just includes `external`.
This patch emits STB_LOCAL aliases (.Lfoo$local) for such GlobalObjects, so that targets can lower
MC_GlobalAddress operands to STB_LOCAL aliases if applicable.
We may extend the scope and include GlobalAlias in the future.
LLVM's existing -fno-semantic-interposition behaviors give us license to do such optimizations:
* Various optimizations (ipconstprop, inliner, sccp, sroa, etc) treat normal ExternalLinkage
GlobalObjects as non-interposable.
* Before D72197, MC resolved a PC-relative VK_None fixup to a non-local symbol at assembly time (no
outstanding relocation), if the target is defined in the same section. Put it simply, even if IR
optimizations failed to optimize and allowed interposition for the function call in
`void foo() {} void bar() { foo(); }`, the assembler would disallow it.
This patch sets up AsmPrinter infrastructure to make -fno-semantic-interposition more so.
With and without the patch, the object file output should be identical:
`.Lfoo$local` does not take a symbol table entry.
Reviewed By: sfertile
Differential Revision: https://reviews.llvm.org/D73228
2020-01-23 04:26:04 +08:00
|
|
|
; X32-NEXT: .L__emutls_t.i4$local:
|
2015-07-29 00:24:05 +08:00
|
|
|
; X32-NEXT: .long 15
|
|
|
|
|
|
|
|
; X32-NOT: __emutls_v.i5:
|
|
|
|
; X32 .hidden __emutls_v.i5
|
|
|
|
; X32-NOT: __emutls_v.i5:
|
|
|
|
|
|
|
|
; X32 .section .data.rel.local,
|
|
|
|
; X32-LABEL: __emutls_v.s1:
|
|
|
|
; X32-NEXT: .long 2
|
|
|
|
; X32-NEXT: .long 2
|
|
|
|
; X32-NEXT: .long 0
|
|
|
|
; X32-NEXT: .long __emutls_t.s1
|
|
|
|
|
|
|
|
; X32 .section .rodata,
|
|
|
|
; X32-LABEL: __emutls_t.s1:
|
|
|
|
; X32-NEXT: .short 15
|
|
|
|
|
|
|
|
; X32 .section .data.rel.local,
|
|
|
|
; X32-LABEL: __emutls_v.b1:
|
|
|
|
; X32-NEXT: .long 1
|
|
|
|
; X32-NEXT: .long 1
|
|
|
|
; X32-NEXT: .long 0
|
|
|
|
; X32-NEXT: .long 0
|
|
|
|
|
|
|
|
; X32-NOT: __emutls_t.b1
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;; 64-bit __emutls_v. and __emutls_t.
|
|
|
|
|
|
|
|
; X64 .section .data.rel.local,
|
|
|
|
; X64-LABEL: __emutls_v.i1:
|
|
|
|
; X64-NEXT: .quad 4
|
|
|
|
; X64-NEXT: .quad 4
|
|
|
|
; X64-NEXT: .quad 0
|
|
|
|
; X64-NEXT: .quad __emutls_t.i1
|
|
|
|
|
|
|
|
; X64 .section .rodata,
|
|
|
|
; X64-LABEL: __emutls_t.i1:
|
|
|
|
; X64-NEXT: .long 15
|
|
|
|
|
|
|
|
; X64-NOT: __emutls_v.i2
|
|
|
|
|
|
|
|
; X64 .section .data.rel.local,
|
|
|
|
; X64-LABEL: __emutls_v.i3:
|
|
|
|
; X64-NEXT: .quad 4
|
|
|
|
; X64-NEXT: .quad 4
|
|
|
|
; X64-NEXT: .quad 0
|
|
|
|
; X64-NEXT: .quad __emutls_t.i3
|
|
|
|
|
|
|
|
; X64 .section .rodata,
|
|
|
|
; X64-LABEL: __emutls_t.i3:
|
|
|
|
; X64-NEXT: .long 15
|
|
|
|
|
|
|
|
; X64 .section .data.rel.local,
|
|
|
|
; X64-LABEL: __emutls_v.i4:
|
[AsmPrinter][ELF] Define local aliases (.Lfoo$local) for GlobalObjects
For `MC_GlobalAddress` operands referencing **certain** GlobalObjects,
we can lower them to STB_LOCAL aliases to avoid costs brought by
assembler/linker's conservative decisions about symbol interposition:
* An assembler conservatively assumes a global default visibility symbol interposable (ELF
semantics). So relocations in object files are needed even if the code generator assumed
the definition exact and non-interposable.
* The relocations can cause the creation of PLT entries on some targets for -shared links.
A linker conservatively assumes a global default visibility symbol interposable (if not
otherwise constrained by -Bsymbolic/--dynamic-list/VER_NDX_LOCAL/etc).
"certain" refers to GlobalObjects in the intersection of
`hasExactDefinition() and !isInterposable()`: `external`, `appending`, `internal`, `private`.
Local linkages (`internal` and `private`) cannot be interposed. `appending` is for very
few objects LLVM interpret specially. So the set just includes `external`.
This patch emits STB_LOCAL aliases (.Lfoo$local) for such GlobalObjects, so that targets can lower
MC_GlobalAddress operands to STB_LOCAL aliases if applicable.
We may extend the scope and include GlobalAlias in the future.
LLVM's existing -fno-semantic-interposition behaviors give us license to do such optimizations:
* Various optimizations (ipconstprop, inliner, sccp, sroa, etc) treat normal ExternalLinkage
GlobalObjects as non-interposable.
* Before D72197, MC resolved a PC-relative VK_None fixup to a non-local symbol at assembly time (no
outstanding relocation), if the target is defined in the same section. Put it simply, even if IR
optimizations failed to optimize and allowed interposition for the function call in
`void foo() {} void bar() { foo(); }`, the assembler would disallow it.
This patch sets up AsmPrinter infrastructure to make -fno-semantic-interposition more so.
With and without the patch, the object file output should be identical:
`.Lfoo$local` does not take a symbol table entry.
Reviewed By: sfertile
Differential Revision: https://reviews.llvm.org/D73228
2020-01-23 04:26:04 +08:00
|
|
|
; X64-NEXT: .L__emutls_v.i4$local:
|
2015-07-29 00:24:05 +08:00
|
|
|
; X64-NEXT: .quad 4
|
|
|
|
; X64-NEXT: .quad 4
|
|
|
|
; X64-NEXT: .quad 0
|
|
|
|
; X64-NEXT: .quad __emutls_t.i4
|
|
|
|
|
|
|
|
; X64 .section .rodata,
|
|
|
|
; X64-LABEL: __emutls_t.i4:
|
[AsmPrinter][ELF] Define local aliases (.Lfoo$local) for GlobalObjects
For `MC_GlobalAddress` operands referencing **certain** GlobalObjects,
we can lower them to STB_LOCAL aliases to avoid costs brought by
assembler/linker's conservative decisions about symbol interposition:
* An assembler conservatively assumes a global default visibility symbol interposable (ELF
semantics). So relocations in object files are needed even if the code generator assumed
the definition exact and non-interposable.
* The relocations can cause the creation of PLT entries on some targets for -shared links.
A linker conservatively assumes a global default visibility symbol interposable (if not
otherwise constrained by -Bsymbolic/--dynamic-list/VER_NDX_LOCAL/etc).
"certain" refers to GlobalObjects in the intersection of
`hasExactDefinition() and !isInterposable()`: `external`, `appending`, `internal`, `private`.
Local linkages (`internal` and `private`) cannot be interposed. `appending` is for very
few objects LLVM interpret specially. So the set just includes `external`.
This patch emits STB_LOCAL aliases (.Lfoo$local) for such GlobalObjects, so that targets can lower
MC_GlobalAddress operands to STB_LOCAL aliases if applicable.
We may extend the scope and include GlobalAlias in the future.
LLVM's existing -fno-semantic-interposition behaviors give us license to do such optimizations:
* Various optimizations (ipconstprop, inliner, sccp, sroa, etc) treat normal ExternalLinkage
GlobalObjects as non-interposable.
* Before D72197, MC resolved a PC-relative VK_None fixup to a non-local symbol at assembly time (no
outstanding relocation), if the target is defined in the same section. Put it simply, even if IR
optimizations failed to optimize and allowed interposition for the function call in
`void foo() {} void bar() { foo(); }`, the assembler would disallow it.
This patch sets up AsmPrinter infrastructure to make -fno-semantic-interposition more so.
With and without the patch, the object file output should be identical:
`.Lfoo$local` does not take a symbol table entry.
Reviewed By: sfertile
Differential Revision: https://reviews.llvm.org/D73228
2020-01-23 04:26:04 +08:00
|
|
|
; X64-NEXT: .L__emutls_t.i4$local:
|
2015-07-29 00:24:05 +08:00
|
|
|
; X64-NEXT: .long 15
|
|
|
|
|
|
|
|
; X64-NOT: __emutls_v.i5:
|
|
|
|
; X64 .hidden __emutls_v.i5
|
|
|
|
; X64-NOT: __emutls_v.i5:
|
|
|
|
|
|
|
|
; X64 .section .data.rel.local,
|
|
|
|
; X64-LABEL: __emutls_v.s1:
|
|
|
|
; X64-NEXT: .quad 2
|
|
|
|
; X64-NEXT: .quad 2
|
|
|
|
; X64-NEXT: .quad 0
|
|
|
|
; X64-NEXT: .quad __emutls_t.s1
|
|
|
|
|
|
|
|
; X64 .section .rodata,
|
|
|
|
; X64-LABEL: __emutls_t.s1:
|
|
|
|
; X64-NEXT: .short 15
|
|
|
|
|
|
|
|
; X64 .section .data.rel.local,
|
|
|
|
; X64-LABEL: __emutls_v.b1:
|
|
|
|
; X64-NEXT: .quad 1
|
|
|
|
; X64-NEXT: .quad 1
|
|
|
|
; X64-NEXT: .quad 0
|
|
|
|
; X64-NEXT: .quad 0
|
|
|
|
|
|
|
|
; X64-NOT: __emutls_t.b1
|