1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[TargetMachine] Drop implied dso_local for definitions in ELF static relocation model/PIE

TargetMachine::shouldAssumeDSOLocal currently implies dso_local for such definitions.

Since clang -fno-pic add the dso_local specifier, we don't need to special case.
This commit is contained in:
Fangrui Song 2020-12-30 16:57:50 -08:00
parent 92d413a192
commit 9b494cc6bf
4 changed files with 21 additions and 33 deletions

View File

@ -156,16 +156,6 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
assert(TT.isOSBinFormatELF() || TT.isOSBinFormatWasm());
assert(RM != Reloc::DynamicNoPIC);
bool IsExecutable =
RM == Reloc::Static || M.getPIELevel() != PIELevel::Default;
if (IsExecutable) {
// If the symbol is defined, it cannot be preempted.
if (!GV->isDeclarationForLinker())
return true;
}
// ELF & wasm support preemption of other symbols.
return false;
}

View File

@ -61,8 +61,8 @@ define void @t2() nounwind ssp {
; ARM-ELF: movw [[REG1:r[0-9]+]], :lower16:temp
; ARM-ELF: movt [[REG1]], :upper16:temp
; ARM-ELF: add r0, [[REG1]], #4
; ARM-ELF-NEXT: add r1, [[REG1]], #16
; ARM-ELF: add [[REG1]], r1, #4
; ARM-ELF-NEXT: add r1, r1, #16
; ARM: movw r2, #17
; ARM: bl {{_?}}memcpy
@ -106,7 +106,7 @@ define void @t3() nounwind ssp {
; ARM-ELF: movw [[REG0:r[0-9]+]], :lower16:temp
; ARM-ELF: movt [[REG0]], :upper16:temp
; ARM-ELF: add r0, [[REG0]], #4
; ARM-ELF: add [[REG0]], r1, #4
; ARM-ELF-NEXT: add r1, r1, #16
; ARM: movw r2, #10

View File

@ -3,8 +3,8 @@
@default = global i32 55
define dso_local i32* @get_default_global() {
; CHECK-LABEL: get_default_global:
; CHECK: addis 3, 2, default@toc@ha
; CHECK-NEXT: addi 3, 3, default@toc@l
; CHECK: addis 3, 2, .LC{{.*}}@toc@ha
; CHECK-NEXT: ld 3, .LC{{.*}}@toc@l(3)
; CHECK-NEXT: blr
ret i32* @default
}
@ -21,8 +21,8 @@ define dso_local i32* @get_local_global() {
@preemptable_global = dso_preemptable global i32 42
define dso_local i32* @get_preemptable_global() {
; CHECK-LABEL: get_preemptable_global:
; CHECK: addis 3, 2, preemptable_global@toc@ha
; CHECK-NEXT: addi 3, 3, preemptable_global@toc@l
; CHECK: addis 3, 2, .LC{{.*}}@toc@ha
; CHECK-NEXT: ld 3, .LC{{.*}}@toc@l(3)
; CHECK-NEXT: blr
ret i32* @preemptable_global
}
@ -63,8 +63,7 @@ define signext i32 @default_function(i32 %i) {
define dso_local signext i32 @default_function_caller(i32 %i) {
; CHECK-LABEL: default_function_caller:
; CHECK: bl default_function
; CHECK-NOT: nop
; CHECK: blr
; CHECK-NEXT: nop
%call = notail call signext i32 @default_function(i32 signext %i)
ret i32 %call
}
@ -87,8 +86,7 @@ define dso_preemptable signext i32 @preemptable_function(i32 %i) {
define dso_local signext i32 @preemptable_function_caller(i32 %i) {
; CHECK-LABEL: preemptable_function_caller:
; CHECK: bl preemptable_function
; CHECK-NOT: nop
; CHECK: blr
; CHECK-NEXT: nop
%call = notail call signext i32 @preemptable_function(i32 signext %i)
ret i32 %call
}

View File

@ -17,7 +17,7 @@ define i32* @get_strong_default_global() {
ret i32* @strong_default_global
}
; CHECK: movq strong_default_global@GOTPCREL(%rip), %rax
; STATIC: movl $strong_default_global, %eax
; STATIC: movq strong_default_global@GOTPCREL(%rip), %rax
; CHECK32: movl strong_default_global@GOT(%eax), %eax
@strong_hidden_global = hidden global i32 42
@ -33,7 +33,7 @@ define i32* @get_weak_default_global() {
ret i32* @weak_default_global
}
; CHECK: movq weak_default_global@GOTPCREL(%rip), %rax
; STATIC: movl $weak_default_global, %eax
; STATIC: movq weak_default_global@GOTPCREL(%rip), %rax
; CHECK32: movl weak_default_global@GOT(%eax), %eax
@external_default_global = external global i32
@ -74,7 +74,7 @@ define i32* @get_strong_preemptable_global() {
ret i32* @strong_preemptable_global
}
; CHECK: movq strong_preemptable_global@GOTPCREL(%rip), %rax
; STATIC: movl $strong_preemptable_global, %eax
; STATIC: movq strong_preemptable_global@GOTPCREL(%rip), %rax
; CHECK32: movl strong_preemptable_global@GOT(%eax), %eax
@weak_preemptable_global = weak dso_preemptable global i32 42
@ -82,7 +82,7 @@ define i32* @get_weak_preemptable_global() {
ret i32* @weak_preemptable_global
}
; CHECK: movq weak_preemptable_global@GOTPCREL(%rip), %rax
; STATIC: movl $weak_preemptable_global, %eax
; STATIC: movq weak_preemptable_global@GOTPCREL(%rip), %rax
; CHECK32: movl weak_preemptable_global@GOT(%eax), %eax
@external_preemptable_global = external dso_preemptable global i32
@ -101,7 +101,7 @@ define i32* @get_strong_default_alias() {
ret i32* @strong_default_alias
}
; CHECK: movq strong_default_alias@GOTPCREL(%rip), %rax
; STATIC: movl $strong_default_alias, %eax
; STATIC: movq strong_default_alias@GOTPCREL(%rip), %rax
; CHECK32: movl strong_default_alias@GOT(%eax), %eax
@strong_hidden_alias = hidden alias i32, i32* @aliasee
@ -117,7 +117,7 @@ define i32* @get_weak_default_alias() {
ret i32* @weak_default_alias
}
; CHECK: movq weak_default_alias@GOTPCREL(%rip), %rax
; STATIC: movl $weak_default_alias, %eax
; STATIC: movq weak_default_alias@GOTPCREL(%rip), %rax
; CHECK32: movl weak_default_alias@GOT(%eax), %eax
@strong_local_alias = dso_local alias i32, i32* @aliasee
@ -142,7 +142,7 @@ define i32* @get_strong_preemptable_alias() {
ret i32* @strong_preemptable_alias
}
; CHECK: movq strong_preemptable_alias@GOTPCREL(%rip), %rax
; STATIC: movl $strong_preemptable_alias, %eax
; STATIC: movq strong_preemptable_alias@GOTPCREL(%rip), %rax
; CHECK32: movl strong_preemptable_alias@GOT(%eax), %eax
@weak_preemptable_alias = weak dso_preemptable alias i32, i32* @aliasee
@ -150,7 +150,7 @@ define i32* @get_weak_preemptable_alias() {
ret i32* @weak_preemptable_alias
}
; CHECK: movq weak_preemptable_alias@GOTPCREL(%rip), %rax
; STATIC: movl $weak_preemptable_alias, %eax
; STATIC: movq weak_preemptable_alias@GOTPCREL(%rip), %rax
; CHECK32: movl weak_preemptable_alias@GOT(%eax), %eax
; functions
@ -162,7 +162,7 @@ define void()* @get_strong_default_function() {
ret void()* @strong_default_function
}
; CHECK: movq strong_default_function@GOTPCREL(%rip), %rax
; STATIC: movl $strong_default_function, %eax
; STATIC: movq strong_default_function@GOTPCREL(%rip), %rax
; CHECK32: movl strong_default_function@GOT(%eax), %eax
define hidden void @strong_hidden_function() {
@ -182,7 +182,7 @@ define void()* @get_weak_default_function() {
ret void()* @weak_default_function
}
; CHECK: movq weak_default_function@GOTPCREL(%rip), %rax
; STATIC: movl $weak_default_function, %eax
; STATIC: movq weak_default_function@GOTPCREL(%rip), %rax
; CHECK32: movl weak_default_function@GOT(%eax), %eax
declare void @external_default_function()
@ -231,7 +231,7 @@ define void()* @get_strong_preemptable_function() {
ret void()* @strong_preemptable_function
}
; CHECK: movq strong_preemptable_function@GOTPCREL(%rip), %rax
; STATIC: movl $strong_preemptable_function, %eax
; STATIC: movq strong_preemptable_function@GOTPCREL(%rip), %rax
; CHECK32: movl strong_preemptable_function@GOT(%eax), %eax
define weak dso_preemptable void @weak_preemptable_function() {
@ -241,7 +241,7 @@ define void()* @get_weak_preemptable_function() {
ret void()* @weak_preemptable_function
}
; CHECK: movq weak_preemptable_function@GOTPCREL(%rip), %rax
; STATIC: movl $weak_preemptable_function, %eax
; STATIC: movq weak_preemptable_function@GOTPCREL(%rip), %rax
; CHECK32: movl weak_preemptable_function@GOT(%eax), %eax
declare dso_preemptable void @external_preemptable_function()