summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/Analysis.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-06-27 20:19:14 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-06-27 20:19:14 +0000
commit8121becac31168d7540f6915a6bc33473dcb3e36 (patch)
tree47d0a97395d8456dc776e076202863b90b905930 /llvm/lib/CodeGen/Analysis.cpp
parentca5170e3e46a1ae878408c68a1a0d90e67ad58e4 (diff)
downloadbcm5719-llvm-8121becac31168d7540f6915a6bc33473dcb3e36.tar.gz
bcm5719-llvm-8121becac31168d7540f6915a6bc33473dcb3e36.zip
Teach shouldAssumeDSOLocal about tls.
Fixes a fixme about handling other visibilities. llvm-svn: 273921
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