Skip to content

Commit f8f9be3

Browse files
committed
[ARM,MC] Replace getSymA()->getSymbol() with getAddSym. NFC
We will replace the MCSymbolRefExpr member in MCValue with MCSymbol. This change reduces dependence on MCSymbolRefExpr.
1 parent 590d2a3 commit f8f9be3

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,9 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm,
460460
// Other relocation types don't want this bit though (branches couldn't encode
461461
// it if it *was* present, and no other relocations exist) and it can
462462
// interfere with checking valid expressions.
463-
if (const MCSymbolRefExpr *A = Target.getSymA()) {
464-
if (A->hasSubsectionsViaSymbols() && Asm.isThumbFunc(&A->getSymbol()) &&
465-
A->getSymbol().isExternal() &&
463+
bool IsMachO = Asm.getContext().getObjectFileType() == MCContext::IsMachO;
464+
if (const auto *SA = Target.getAddSym()) {
465+
if (IsMachO && Asm.isThumbFunc(SA) && SA->isExternal() &&
466466
(Kind == FK_Data_4 || Kind == ARM::fixup_arm_movw_lo16 ||
467467
Kind == ARM::fixup_arm_movt_hi16 || Kind == ARM::fixup_t2_movw_lo16 ||
468468
Kind == ARM::fixup_t2_movt_hi16))
@@ -958,8 +958,7 @@ bool ARMAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
958958
const MCFixup &Fixup,
959959
const MCValue &Target,
960960
const MCSubtargetInfo *STI) {
961-
const MCSymbolRefExpr *A = Target.getSymA();
962-
const MCSymbol *Sym = A ? &A->getSymbol() : nullptr;
961+
const MCSymbol *Sym = Target.getAddSym();
963962
const unsigned FixupKind = Fixup.getKind();
964963
if (FixupKind == ARM::fixup_arm_thumb_bl) {
965964
assert(Sym && "How did we resolve this?");
@@ -989,10 +988,10 @@ bool ARMAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
989988
// We must always generate a relocation for BL/BLX instructions if we have
990989
// a symbol to reference, as the linker relies on knowing the destination
991990
// symbol's thumb-ness to get interworking right.
992-
if (A && (FixupKind == ARM::fixup_arm_thumb_blx ||
993-
FixupKind == ARM::fixup_arm_blx ||
994-
FixupKind == ARM::fixup_arm_uncondbl ||
995-
FixupKind == ARM::fixup_arm_condbl))
991+
if (Sym && (FixupKind == ARM::fixup_arm_thumb_blx ||
992+
FixupKind == ARM::fixup_arm_blx ||
993+
FixupKind == ARM::fixup_arm_uncondbl ||
994+
FixupKind == ARM::fixup_arm_condbl))
996995
return true;
997996
return false;
998997
}

llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target,
122122
"invalid fixup for 4-byte pc-relative data relocation");
123123
return ELF::R_ARM_NONE;
124124
case ARMMCExpr::VK_None: {
125-
if (const MCSymbolRefExpr *SymRef = Target.getSymA()) {
125+
if (const auto *SA = Target.getAddSym()) {
126126
// For GNU AS compatibility expressions such as
127127
// _GLOBAL_OFFSET_TABLE_ - label emit a R_ARM_BASE_PREL relocation.
128-
if (SymRef->getSymbol().getName() == "_GLOBAL_OFFSET_TABLE_")
128+
if (SA->getName() == "_GLOBAL_OFFSET_TABLE_")
129129
return ELF::R_ARM_BASE_PREL;
130130
}
131131
return ELF::R_ARM_REL32;

llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,7 @@ void ARMMachObjectWriter::recordRelocation(MachObjectWriter *Writer,
386386
}
387387

388388
// Get the symbol data, if any.
389-
const MCSymbol *A = nullptr;
390-
if (Target.getSymA())
391-
A = Target.getAddSym();
389+
const MCSymbol *A = Target.getAddSym();
392390

393391
// FIXME: For other platforms, we need to use scattered relocations for
394392
// internal relocations with offsets. If this is an internal relocation with

0 commit comments

Comments
 (0)