summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/Analysis.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/Analysis.cpp')
-rw-r--r--llvm/lib/CodeGen/Analysis.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp
index 73bd3d29eae..d3b3a9de110 100644
--- a/llvm/lib/CodeGen/Analysis.cpp
+++ b/llvm/lib/CodeGen/Analysis.cpp
@@ -651,33 +651,32 @@ bool llvm::shouldAssumeDSOLocal(Reloc::Model RM, const Triple &TT,
if (TT.isOSBinFormatCOFF())
return true;
- if (RM == Reloc::Static)
- return true;
-
if (GV && (GV->hasLocalLinkage() || !GV->hasDefaultVisibility()))
return true;
- if (TT.isOSBinFormatELF()) {
- assert(RM != Reloc::DynamicNoPIC);
- // Some linkers can use copy relocations with pie executables.
- if (M.getPIELevel() != PIELevel::Default) {
- if (CanUseCopyRelocWithPIE)
- return true;
+ if (TT.isOSBinFormatMachO()) {
+ if (RM == Reloc::Static)
+ return true;
+ return GV && GV->isStrongDefinitionForLinker();
+ }
- // If the symbol is defined, it cannot be preempted.
- if (GV && !GV->isDeclarationForLinker())
- return true;
- return false;
- }
+ assert(TT.isOSBinFormatELF());
+ assert(RM != Reloc::DynamicNoPIC);
- // ELF supports preemption of other symbols.
- return false;
- }
+ bool IsExecutable =
+ RM == Reloc::Static || M.getPIELevel() != PIELevel::Default;
+ if (IsExecutable) {
+ // If the symbol is defined, it cannot be preempted.
+ if (GV && !GV->isDeclarationForLinker())
+ return true;
- assert(TT.isOSBinFormatMachO());
- if (GV && GV->isStrongDefinitionForLinker())
- return true;
+ bool IsTLS = GV && GV->isThreadLocal();
+ // Check if we can use copy relocations.
+ if (!IsTLS && (RM == Reloc::Static || CanUseCopyRelocWithPIE))
+ return true;
+ }
+ // ELF supports preemption of other symbols.
return false;
}
OpenPOWER on IntegriCloud