summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetMachine.cpp
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2016-10-13 20:54:39 +0000
committerSriraman Tallam <tmsriram@google.com>2016-10-13 20:54:39 +0000
commitf29fa586e1b403e2ee1a845e7f428a8d04215dc3 (patch)
tree22375f3dbc4869421da28220f78fcfd2cb4fd513 /llvm/lib/Target/TargetMachine.cpp
parent606f01f3092da36b761f9df694e8c8eab9dde603 (diff)
downloadbcm5719-llvm-f29fa586e1b403e2ee1a845e7f428a8d04215dc3.tar.gz
bcm5719-llvm-f29fa586e1b403e2ee1a845e7f428a8d04215dc3.zip
New llc option pie-copy-relocations to optimize access to extern globals.
This option indicates copy relocations support is available from the linker when building as PIE and allows accesses to extern globals to avoid the GOT. Differential Revision: https://reviews.llvm.org/D24849 llvm-svn: 284160
Diffstat (limited to 'llvm/lib/Target/TargetMachine.cpp')
-rw-r--r--llvm/lib/Target/TargetMachine.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 43a587ba847..792280af84d 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -115,9 +115,6 @@ static TLSModel::Model getSelectedTLSModel(const GlobalValue *GV) {
llvm_unreachable("invalid TLS model");
}
-// FIXME: make this a proper option
-static bool CanUseCopyRelocWithPIE = false;
-
bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
const GlobalValue *GV) const {
Reloc::Model RM = getRelocationModel();
@@ -154,8 +151,10 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
return true;
bool IsTLS = GV && GV->isThreadLocal();
+ bool IsAccessViaCopyRelocs =
+ Options.MCOptions.MCPIECopyRelocations && GV && isa<GlobalVariable>(GV);
// Check if we can use copy relocations.
- if (!IsTLS && (RM == Reloc::Static || CanUseCopyRelocWithPIE))
+ if (!IsTLS && (RM == Reloc::Static || IsAccessViaCopyRelocs))
return true;
}
OpenPOWER on IntegriCloud