diff options
author | Sriraman Tallam <tmsriram@google.com> | 2017-11-08 00:01:05 +0000 |
---|---|---|
committer | Sriraman Tallam <tmsriram@google.com> | 2017-11-08 00:01:05 +0000 |
commit | 056b3fd6fba58b3a534daaf8a16c5e8af139a9c0 (patch) | |
tree | 1f2a46da4f09a9eb5ff4ab1a6a5e67352adadff1 /llvm/lib | |
parent | 0379d3f84434043ecb814eb2cb473523c5f406a9 (diff) | |
download | bcm5719-llvm-056b3fd6fba58b3a534daaf8a16c5e8af139a9c0.tar.gz bcm5719-llvm-056b3fd6fba58b3a534daaf8a16c5e8af139a9c0.zip |
Attribute nonlazybind should not affect calls to functions with hidden visibility.
Differential Revision: https://reviews.llvm.org/D39625
llvm-svn: 317639
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/TargetMachine.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86Subtarget.cpp | 13 |
2 files changed, 11 insertions, 9 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 5dcb89477a3..b24888fa9cb 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -167,6 +167,13 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M, if (GV && !GV->isDeclarationForLinker()) return true; + // A symbol marked nonlazybind should not be accessed with a plt. If the + // symbol turns out to be external, the linker will convert a direct + // access to an access via the plt, so don't assume it is local. + const Function *F = dyn_cast_or_null<Function>(GV); + if (F && F->hasFnAttribute(Attribute::NonLazyBind)) + return false; + bool IsTLS = GV && GV->isThreadLocal(); bool IsAccessViaCopyRelocs = Options.MCOptions.MCPIECopyRelocations && GV && isa<GlobalVariable>(GV); diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp index 9e060f97df3..66fea1e688f 100644 --- a/llvm/lib/Target/X86/X86Subtarget.cpp +++ b/llvm/lib/Target/X86/X86Subtarget.cpp @@ -144,15 +144,6 @@ X86Subtarget::classifyGlobalFunctionReference(const GlobalValue *GV) const { unsigned char X86Subtarget::classifyGlobalFunctionReference(const GlobalValue *GV, const Module &M) const { - const Function *F = dyn_cast_or_null<Function>(GV); - - // Do not use the PLT when explicitly told to do so for ELF 64-bit - // target. - if (isTargetELF() && is64Bit() && F && - F->hasFnAttribute(Attribute::NonLazyBind) && - GV->isDeclarationForLinker()) - return X86II::MO_GOTPCREL; - if (TM.shouldAssumeDSOLocal(M, GV)) return X86II::MO_NO_FLAG; @@ -162,12 +153,16 @@ X86Subtarget::classifyGlobalFunctionReference(const GlobalValue *GV, return X86II::MO_DLLIMPORT; } + const Function *F = dyn_cast_or_null<Function>(GV); + if (isTargetELF()) { if (is64Bit() && F && (CallingConv::X86_RegCall == F->getCallingConv())) // According to psABI, PLT stub clobbers XMM8-XMM15. // In Regcall calling convention those registers are used for passing // parameters. Thus we need to prevent lazy binding in Regcall. return X86II::MO_GOTPCREL; + if (F && F->hasFnAttribute(Attribute::NonLazyBind) && is64Bit()) + return X86II::MO_GOTPCREL; return X86II::MO_PLT; } |