diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-01-26 15:02:31 +0000 | 
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-01-26 15:02:31 +0000 | 
| commit | 82149a1aa961a7870c2cb8f6bad6fb4f1dc9a29a (patch) | |
| tree | 23bdf08183d90600f7d6d8547b50c1fa6992cd92 /llvm/lib | |
| parent | a98b5fd999bda84b6585875a92d5f31da2b371af (diff) | |
| download | bcm5719-llvm-82149a1aa961a7870c2cb8f6bad6fb4f1dc9a29a.tar.gz bcm5719-llvm-82149a1aa961a7870c2cb8f6bad6fb4f1dc9a29a.zip  | |
Use shouldAssumeDSOLocal in classifyGlobalReference.
And teach shouldAssumeDSOLocal that ppc has no copy relocations.
The resulting code handle a few more case than before. For example, it
knows that a weak symbol can be resolved to another .o file, but it
will still be in the main executable.
llvm-svn: 293180
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCSubtarget.cpp | 24 | ||||
| -rw-r--r-- | llvm/lib/Target/TargetMachine.cpp | 7 | 
2 files changed, 10 insertions, 21 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp index e8a87e7f443..ccf0f80c336 100644 --- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp +++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp @@ -220,8 +220,8 @@ bool PPCSubtarget::enableSubRegLiveness() const {    return UseSubRegLiveness;  } -unsigned char PPCSubtarget::classifyGlobalReference( -    const GlobalValue *GV) const { +unsigned char +PPCSubtarget::classifyGlobalReference(const GlobalValue *GV) const {    // Note that currently we don't generate non-pic references.    // If a caller wants that, this will have to be updated. @@ -229,23 +229,9 @@ unsigned char PPCSubtarget::classifyGlobalReference(    if (TM.getCodeModel() == CodeModel::Large)      return PPCII::MO_PIC_FLAG | PPCII::MO_NLP_FLAG; -  unsigned char flags = PPCII::MO_PIC_FLAG; - -  // Only if the relocation mode is PIC do we have to worry about -  // interposition. In all other cases we can use a slightly looser standard to -  // decide how to access the symbol. -  if (TM.getRelocationModel() == Reloc::PIC_) { -    // If it's local, or it's non-default, it can't be interposed. -    if (!GV->hasLocalLinkage() && -        GV->hasDefaultVisibility()) { -      flags |= PPCII::MO_NLP_FLAG; -    } -    return flags; -  } - -  if (GV->isStrongDefinitionForLinker()) -    return flags; -  return flags | PPCII::MO_NLP_FLAG; +  if (TM.shouldAssumeDSOLocal(*GV->getParent(), GV)) +    return PPCII::MO_PIC_FLAG; +  return PPCII::MO_PIC_FLAG | PPCII::MO_NLP_FLAG;  }  bool PPCSubtarget::isELFv2ABI() const { return TM.isELFv2ABI(); } diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 438c62dd5ae..4beecb4dbb6 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -163,8 +163,11 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,      bool IsTLS = GV && GV->isThreadLocal();      bool IsAccessViaCopyRelocs =          Options.MCOptions.MCPIECopyRelocations && GV && isa<GlobalVariable>(GV); -    // Check if we can use copy relocations. -    if (!IsTLS && (RM == Reloc::Static || IsAccessViaCopyRelocs)) +    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))        return true;    }  | 

