diff options
author | Fangrui Song <maskray@google.com> | 2020-01-01 00:15:28 -0800 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2020-01-01 00:50:18 -0800 |
commit | d2bb8c16e711602481c8b33d0e2ccc9994eb6641 (patch) | |
tree | 01f3e95e28811a0253d6b4a206d25edd8edee125 /llvm/lib/Target/TargetMachine.cpp | |
parent | 47e3d3ec0c5607ae3bc6181537c0622080f3af27 (diff) | |
download | bcm5719-llvm-d2bb8c16e711602481c8b33d0e2ccc9994eb6641.tar.gz bcm5719-llvm-d2bb8c16e711602481c8b33d0e2ccc9994eb6641.zip |
[MC][TargetMachine] Delete MCTargetOptions::MCPIECopyRelocations
clang/lib/CodeGen/CodeGenModule performs the -mpie-copy-relocations
check and sets dso_local on applicable global variables. We don't need
to duplicate the work in TargetMachine shouldAssumeDSOLocal.
Verified that -mpie-copy-relocations can still emit PC relative
relocations for external variable accesses.
clang -target x86_64 -fpie -mpie-copy-relocations -c => R_X86_64_PC32
clang -target aarch64 -fpie -mpie-copy-relocations -c => R_AARCH64_ADR_PREL_PG_HI21+R_AARCH64_LDST64_ABS_LO12_NC
Diffstat (limited to 'llvm/lib/Target/TargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/TargetMachine.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 51991840506..97a1eb2f190 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -184,15 +184,14 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M, const Function *F = dyn_cast_or_null<Function>(GV); if (F && F->hasFnAttribute(Attribute::NonLazyBind)) return false; - - bool IsTLS = GV && GV->isThreadLocal(); - bool IsAccessViaCopyRelocs = - GV && Options.MCOptions.MCPIECopyRelocations && isa<GlobalVariable>(GV); Triple::ArchType Arch = TT.getArch(); - bool IsPPC = - Arch == Triple::ppc || Arch == Triple::ppc64 || Arch == Triple::ppc64le; - // Check if we can use copy relocations. PowerPC has no copy relocations. - if (!IsTLS && !IsPPC && (RM == Reloc::Static || IsAccessViaCopyRelocs)) + + // PowerPC prefers avoiding copy relocations. + if (Arch == Triple::ppc || TT.isPPC64()) + return false; + + // Check if we can use copy relocations. + if (!(GV && GV->isThreadLocal()) && RM == Reloc::Static) return true; } |