Skip to content

Commit 8405fcf

Browse files
committed
Move isGVIndirectSymbol to ARMTargetMachine
1 parent 4c265a5 commit 8405fcf

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

llvm/lib/Target/ARM/ARMAsmPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,8 @@ MCSymbol *ARMAsmPrinter::GetARMGVSymbol(const GlobalValue *GV,
886886
unsigned char TargetFlags) {
887887
const Triple &TT = TM.getTargetTriple();
888888
if (TT.isOSBinFormatMachO()) {
889-
bool IsIndirect = (TargetFlags & ARMII::MO_NONLAZY) &&
890-
ARMSubtarget::isGVIndirectSymbol(TM, GV);
889+
bool IsIndirect =
890+
(TargetFlags & ARMII::MO_NONLAZY) && getTM().isGVIndirectSymbol(GV);
891891

892892
if (!IsIndirect)
893893
return getSymbol(GV);

llvm/lib/Target/ARM/ARMSubtarget.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -317,23 +317,8 @@ bool ARMSubtarget::isRWPI() const {
317317
TM.getRelocationModel() == Reloc::ROPI_RWPI;
318318
}
319319

320-
bool ARMSubtarget::isGVIndirectSymbol(const TargetMachine &TM,
321-
const GlobalValue *GV) {
322-
if (!TM.shouldAssumeDSOLocal(GV))
323-
return true;
324-
325-
// 32 bit macho has no relocation for a-b if a is undefined, even if b is in
326-
// the section that is being relocated. This means we have to use o load even
327-
// for GVs that are known to be local to the dso.
328-
if (TM.getTargetTriple().isOSBinFormatMachO() && TM.isPositionIndependent() &&
329-
(GV->isDeclarationForLinker() || GV->hasCommonLinkage()))
330-
return true;
331-
332-
return false;
333-
}
334-
335320
bool ARMSubtarget::isGVIndirectSymbol(const GlobalValue *GV) const {
336-
return isGVIndirectSymbol(TM, GV);
321+
return TM.isGVIndirectSymbol(GV);
337322
}
338323

339324
bool ARMSubtarget::isGVInGOT(const GlobalValue *GV) const {

llvm/lib/Target/ARM/ARMSubtarget.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,6 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
464464
}
465465

466466
/// True if the GV will be accessed via an indirect symbol.
467-
static bool isGVIndirectSymbol(const TargetMachine &TM,
468-
const GlobalValue *GV);
469467
bool isGVIndirectSymbol(const GlobalValue *GV) const;
470468

471469
/// Returns the constant pool modifier needed to access the GV.

llvm/lib/Target/ARM/ARMTargetMachine.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ class ARMBaseTargetMachine : public CodeGenTargetMachineImpl {
9898
return true;
9999
}
100100

101+
bool isGVIndirectSymbol(const GlobalValue *GV) const {
102+
if (!shouldAssumeDSOLocal(GV))
103+
return true;
104+
105+
// 32 bit macho has no relocation for a-b if a is undefined, even if b is in
106+
// the section that is being relocated. This means we have to use o load
107+
// even for GVs that are known to be local to the dso.
108+
if (getTargetTriple().isOSBinFormatMachO() && isPositionIndependent() &&
109+
(GV->isDeclarationForLinker() || GV->hasCommonLinkage()))
110+
return true;
111+
112+
return false;
113+
}
114+
101115
yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override;
102116
yaml::MachineFunctionInfo *
103117
convertFuncInfoToYAML(const MachineFunction &MF) const override;

0 commit comments

Comments
 (0)