Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 805aa9b

Browse files
committed
Refactor to use shouldAssumeDSOLocal. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273612 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 8bbe924 commit 805aa9b

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

lib/Target/PowerPC/PPCSubtarget.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "PPC.h"
1616
#include "PPCRegisterInfo.h"
1717
#include "PPCTargetMachine.h"
18+
#include "llvm/CodeGen/Analysis.h"
1819
#include "llvm/CodeGen/MachineFunction.h"
1920
#include "llvm/CodeGen/MachineScheduler.h"
2021
#include "llvm/IR/Attributes.h"
@@ -146,18 +147,21 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
146147
IsLittleEndian = (TargetTriple.getArch() == Triple::ppc64le);
147148
}
148149

149-
/// hasLazyResolverStub - Return true if accesses to the specified global have
150-
/// to go through a dyld lazy resolution stub. This means that an extra load
151-
/// is required to get the address of the global.
150+
/// Return true if accesses to the specified global have to go through a dyld
151+
/// lazy resolution stub. This means that an extra load is required to get the
152+
/// address of the global.
152153
bool PPCSubtarget::hasLazyResolverStub(const GlobalValue *GV) const {
153-
// We never have stubs if HasLazyResolverStubs=false or if in static mode.
154-
if (!HasLazyResolverStubs || TM.getRelocationModel() == Reloc::Static)
154+
if (!HasLazyResolverStubs)
155155
return false;
156-
bool isDecl = GV->isDeclaration();
157-
if (GV->hasHiddenVisibility() && !isDecl && !GV->hasCommonLinkage())
158-
return false;
159-
return GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
160-
GV->hasCommonLinkage() || isDecl;
156+
if (!shouldAssumeDSOLocal(TM.getRelocationModel(), TM.getTargetTriple(),
157+
*GV->getParent(), GV))
158+
return true;
159+
// 32 bit macho has no relocation for a-b if a is undefined, even if b is in
160+
// the section that is being relocated. This means we have to use o load even
161+
// for GVs that are known to be local to the dso.
162+
if (GV->isDeclarationForLinker() || GV->hasCommonLinkage())
163+
return true;
164+
return false;
161165
}
162166

163167
// Embedded cores need aggressive scheduling (and some others also benefit).

0 commit comments

Comments
 (0)