diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-05-26 12:42:55 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-05-26 12:42:55 +0000 |
commit | a224de06bc816812a5918c146b351c92b05d6ed8 (patch) | |
tree | 97896ec7bf30ba9cca506e29428292f18708b258 /llvm/lib/CodeGen/Analysis.cpp | |
parent | 8437bb70fdc582b64e3fb0a02033684a2ae386bc (diff) | |
download | llvm-a224de06bc816812a5918c146b351c92b05d6ed8.zip llvm-a224de06bc816812a5918c146b351c92b05d6ed8.tar.gz llvm-a224de06bc816812a5918c146b351c92b05d6ed8.tar.bz2 |
Use shouldAssumeDSOLocal on AArch64.
This reduces code duplication and now AArch64 also handles PIE.
llvm-svn: 270844
Diffstat (limited to 'llvm/lib/CodeGen/Analysis.cpp')
-rw-r--r-- | llvm/lib/CodeGen/Analysis.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp index 292142b..ef40548 100644 --- a/llvm/lib/CodeGen/Analysis.cpp +++ b/llvm/lib/CodeGen/Analysis.cpp @@ -650,6 +650,49 @@ bool llvm::canBeOmittedFromSymbolTable(const GlobalValue *GV) { return !GS.IsCompared; } +// FIXME: make this a proper option +static bool CanUseCopyRelocWithPIE = false; + +bool llvm::shouldAssumeDSOLocal(Reloc::Model RM, const Triple &TT, + const Module &M, const GlobalValue *GV) { + // DLLImport explicitly marks the GV as external. + if (GV && GV->hasDLLImportStorageClass()) + return false; + + // Every other GV is local on COFF + if (TT.isOSBinFormatCOFF()) + return true; + + if (RM == Reloc::Static) + return true; + + if (GV && (GV->hasLocalLinkage() || !GV->hasDefaultVisibility())) + return true; + + if (TT.isOSBinFormatELF()) { + assert(RM != Reloc::DynamicNoPIC); + // Some linkers can use copy relocations with pie executables. + if (M.getPIELevel() != PIELevel::Default) { + if (CanUseCopyRelocWithPIE) + return true; + + // If the symbol is defined, it cannot be preempted. + if (GV && !GV->isDeclarationForLinker()) + return true; + return false; + } + + // ELF supports preemption of other symbols. + return false; + } + + assert(TT.isOSBinFormatMachO()); + if (GV && GV->isStrongDefinitionForLinker()) + return true; + + return false; +} + static void collectFuncletMembers( DenseMap<const MachineBasicBlock *, int> &FuncletMembership, int Funclet, const MachineBasicBlock *MBB) { |