Refactor to use shouldAssumeDSOLocal. NFC.

llvm-svn: 273612
This commit is contained in:
Rafael Espindola 2016-06-23 20:50:42 +00:00
parent f0b3e85f4e
commit 65787a9e01
1 changed files with 14 additions and 10 deletions

View File

@ -15,6 +15,7 @@
#include "PPC.h"
#include "PPCRegisterInfo.h"
#include "PPCTargetMachine.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineScheduler.h"
#include "llvm/IR/Attributes.h"
@ -146,18 +147,21 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
IsLittleEndian = (TargetTriple.getArch() == Triple::ppc64le);
}
/// hasLazyResolverStub - Return true if accesses to the specified global have
/// to go through a dyld lazy resolution stub. This means that an extra load
/// is required to get the address of the global.
/// Return true if accesses to the specified global have to go through a dyld
/// lazy resolution stub. This means that an extra load is required to get the
/// address of the global.
bool PPCSubtarget::hasLazyResolverStub(const GlobalValue *GV) const {
// We never have stubs if HasLazyResolverStubs=false or if in static mode.
if (!HasLazyResolverStubs || TM.getRelocationModel() == Reloc::Static)
if (!HasLazyResolverStubs)
return false;
bool isDecl = GV->isDeclaration();
if (GV->hasHiddenVisibility() && !isDecl && !GV->hasCommonLinkage())
return false;
return GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
GV->hasCommonLinkage() || isDecl;
if (!shouldAssumeDSOLocal(TM.getRelocationModel(), TM.getTargetTriple(),
*GV->getParent(), GV))
return true;
// 32 bit macho has no relocation for a-b if a is undefined, even if b is in
// the section that is being relocated. This means we have to use o load even
// for GVs that are known to be local to the dso.
if (GV->isDeclarationForLinker() || GV->hasCommonLinkage())
return true;
return false;
}
// Embedded cores need aggressive scheduling (and some others also benefit).