From f29fa586e1b403e2ee1a845e7f428a8d04215dc3 Mon Sep 17 00:00:00 2001 From: Sriraman Tallam Date: Thu, 13 Oct 2016 20:54:39 +0000 Subject: 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 --- llvm/lib/Target/TargetMachine.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Target/TargetMachine.cpp') 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(GV); // Check if we can use copy relocations. - if (!IsTLS && (RM == Reloc::Static || CanUseCopyRelocWithPIE)) + if (!IsTLS && (RM == Reloc::Static || IsAccessViaCopyRelocs)) return true; } -- cgit v1.2.3