mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Move -fno-semantic-interposition dso_local logic from TargetMachine to Clang CodeGenModule
This simplifies TargetMachine::shouldAssumeDSOLocal and and gives frontend the decision to use dso_local. For LLVM synthesized functions/globals, they may lose inferred dso_local but such optimizations are probably not very useful. Note: the hasComdat() condition in canBenefitFromLocalAlias (D77429) may be dead now. (llvm/CodeGen/X86/semantic-interposition-comdat.ll) (Investigate whether we need test coverage when Fuchsia C++ ABI is clearer)
This commit is contained in:
parent
14a409567f
commit
28b6140818
@ -163,14 +163,6 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
|
|||||||
// If the symbol is defined, it cannot be preempted.
|
// If the symbol is defined, it cannot be preempted.
|
||||||
if (!GV->isDeclarationForLinker())
|
if (!GV->isDeclarationForLinker())
|
||||||
return true;
|
return true;
|
||||||
} else if (TT.isOSBinFormatELF()) {
|
|
||||||
// If dso_local allows AsmPrinter::getSymbolPreferLocal to use a local
|
|
||||||
// alias, set the flag. We cannot set dso_local for other global values,
|
|
||||||
// because otherwise direct accesses to a probably interposable symbol (even
|
|
||||||
// if the codegen assumes not) will be rejected by the linker.
|
|
||||||
if (!GV->canBenefitFromLocalAlias())
|
|
||||||
return false;
|
|
||||||
return TT.isX86() && M.noSemanticInterposition();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ELF & wasm support preemption of other symbols.
|
// ELF & wasm support preemption of other symbols.
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
; RUN: llc -mtriple=x86_64 -relocation-model=pic < %s | FileCheck %s
|
|
||||||
|
|
||||||
$comdat_func = comdat any
|
|
||||||
|
|
||||||
; CHECK-LABEL: func2:
|
|
||||||
; CHECK-NOT: .Lfunc2$local
|
|
||||||
|
|
||||||
declare void @func()
|
|
||||||
|
|
||||||
define hidden void @func2() {
|
|
||||||
entry:
|
|
||||||
call void @func()
|
|
||||||
ret void
|
|
||||||
}
|
|
||||||
|
|
||||||
; CHECK: comdat_func:
|
|
||||||
; CHECK-NOT: .Lcomdat_func$local
|
|
||||||
|
|
||||||
define hidden void @comdat_func() comdat {
|
|
||||||
entry:
|
|
||||||
call void @func()
|
|
||||||
ret void
|
|
||||||
}
|
|
||||||
|
|
||||||
!llvm.module.flags = !{!0, !1}
|
|
||||||
|
|
||||||
!0 = !{i32 1, !"SemanticInterposition", i32 0}
|
|
||||||
!1 = !{i32 7, !"PIC Level", i32 2}
|
|
@ -1,46 +0,0 @@
|
|||||||
; RUN: llc -mtriple=x86_64 -relocation-model=pic < %s | FileCheck %s
|
|
||||||
|
|
||||||
;; With a module flag SemanticInterposition=0, infer dso_local flags even if PIC.
|
|
||||||
;; Local aliases will be generated for applicable variables and functions.
|
|
||||||
|
|
||||||
@var = global i32 0, align 4
|
|
||||||
|
|
||||||
@ifunc = ifunc i32 (), bitcast (i32 ()* ()* @ifunc_resolver to i32 ()*)
|
|
||||||
|
|
||||||
define i32 @ifunc_impl() {
|
|
||||||
entry:
|
|
||||||
ret i32 0
|
|
||||||
}
|
|
||||||
|
|
||||||
define i32 ()* @ifunc_resolver() {
|
|
||||||
entry:
|
|
||||||
ret i32 ()* @ifunc_impl
|
|
||||||
}
|
|
||||||
|
|
||||||
declare i32 @external()
|
|
||||||
|
|
||||||
define i32 @func() {
|
|
||||||
ret i32 0
|
|
||||||
}
|
|
||||||
|
|
||||||
;; Don't set dso_local on declarations or ifuncs.
|
|
||||||
define i32 @foo() {
|
|
||||||
; CHECK: movl .Lvar$local(%rip), %ebp
|
|
||||||
; CHECK: callq external@PLT
|
|
||||||
; CHECK: callq ifunc@PLT
|
|
||||||
; CHECK: callq .Lfunc$local{{$}}
|
|
||||||
entry:
|
|
||||||
%0 = load i32, i32* @var, align 4
|
|
||||||
%call = tail call i32 @external()
|
|
||||||
%add = add nsw i32 %call, %0
|
|
||||||
%call1 = tail call i32 @ifunc()
|
|
||||||
%add2 = add nsw i32 %add, %call1
|
|
||||||
%call2 = tail call i32 @func()
|
|
||||||
%add3 = add nsw i32 %add, %call2
|
|
||||||
ret i32 %add3
|
|
||||||
}
|
|
||||||
|
|
||||||
!llvm.module.flags = !{!0, !1}
|
|
||||||
|
|
||||||
!0 = !{i32 1, !"SemanticInterposition", i32 0}
|
|
||||||
!1 = !{i32 7, !"PIC Level", i32 2}
|
|
Loading…
Reference in New Issue
Block a user