Skip to content

Commit 9ee950b

Browse files
committed
MCValue: Simplify code with getSubSym
The MCValue::SymB MCSymbolRefExpr member might be replaced with a MCSymbol in the future. Reduce direct access.
1 parent 473b059 commit 9ee950b

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

llvm/lib/MC/MCAssembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF,
175175
bool IsPCRel = FixupFlags & MCFixupKindInfo::FKF_IsPCRel;
176176
bool IsResolved = false;
177177
if (IsPCRel) {
178-
if (Target.getSymB()) {
178+
if (Target.getSubSym()) {
179179
IsResolved = false;
180180
} else if (!Target.getSymA()) {
181181
IsResolved = false;

llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ void AArch64MachObjectWriter::recordRelocation(
222222
// Ltmp0:
223223
// ... _foo@got - Ltmp0
224224
if (Target.getSymA()->getKind() == MCSymbolRefExpr::VK_GOT &&
225-
Target.getSymB()->getKind() == MCSymbolRefExpr::VK_None &&
226225
Asm.getSymbolOffset(*B) ==
227226
Asm.getFragmentOffset(*Fragment) + Fixup.getOffset()) {
228227
// SymB is the PC, so use a PC-rel pointer-to-GOT relocation.
@@ -233,8 +232,7 @@ void AArch64MachObjectWriter::recordRelocation(
233232
MRE.r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
234233
Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
235234
return;
236-
} else if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
237-
Target.getSymB()->getKind() != MCSymbolRefExpr::VK_None) {
235+
} else if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None) {
238236
// Otherwise, neither symbol can be modified.
239237
Asm.getContext().reportError(Fixup.getLoc(),
240238
"unsupported relocation of modified symbol");
@@ -411,7 +409,7 @@ void AArch64MachObjectWriter::recordRelocation(
411409
return;
412410
}
413411

414-
if (Target.getSymB()) {
412+
if (Target.getSubSym()) {
415413
Asm.getContext().reportError(
416414
Fixup.getLoc(),
417415
"invalid auth relocation, can't reference two symbols");

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,20 @@ void ARMMachObjectWriter::recordARMScatteredRelocation(
272272
FixedValue += SecAddr;
273273
uint32_t Value2 = 0;
274274

275-
if (const MCSymbolRefExpr *B = Target.getSymB()) {
275+
if (const MCSymbol *SB = Target.getSubSym()) {
276276
assert(Type == MachO::ARM_RELOC_VANILLA && "invalid reloc for 2 symbols");
277-
const MCSymbol *SB = &B->getSymbol();
278277

279278
if (!SB->getFragment()) {
280-
Asm.getContext().reportError(Fixup.getLoc(),
281-
"symbol '" + B->getSymbol().getName() +
282-
"' can not be undefined in a subtraction expression");
279+
Asm.getContext().reportError(
280+
Fixup.getLoc(),
281+
"symbol '" + SB->getName() +
282+
"' can not be undefined in a subtraction expression");
283283
return;
284284
}
285285

286286
// Select the appropriate difference relocation type.
287287
Type = MachO::ARM_RELOC_SECTDIFF;
288-
Value2 = Writer->getSymbolAddress(B->getSymbol(), Asm);
288+
Value2 = Writer->getSymbolAddress(*SB, Asm);
289289
FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
290290
}
291291

0 commit comments

Comments
 (0)