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 | |
| 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')
| -rw-r--r-- | llvm/lib/MC/MCTargetOptions.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Target/TargetMachine.cpp | 15 |
2 files changed, 9 insertions, 10 deletions
diff --git a/llvm/lib/MC/MCTargetOptions.cpp b/llvm/lib/MC/MCTargetOptions.cpp index 96bb094134f..5848e3ecadb 100644 --- a/llvm/lib/MC/MCTargetOptions.cpp +++ b/llvm/lib/MC/MCTargetOptions.cpp @@ -15,8 +15,8 @@ MCTargetOptions::MCTargetOptions() : MCRelaxAll(false), MCNoExecStack(false), MCFatalWarnings(false), MCNoWarn(false), MCNoDeprecatedWarn(false), MCSaveTempLabels(false), MCUseDwarfDirectory(false), MCIncrementalLinkerCompatible(false), - MCPIECopyRelocations(false), ShowMCEncoding(false), ShowMCInst(false), - AsmVerbose(false), PreserveAsmComments(true) {} + ShowMCEncoding(false), ShowMCInst(false), AsmVerbose(false), + PreserveAsmComments(true) {} StringRef MCTargetOptions::getABIName() const { return ABIName; 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; } |

