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

Commit 4599a3a

Browse files
committed
Reuse existing variables. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306586 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5383c7c commit 4599a3a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ bool X86MachObjectWriter::recordScatteredRelocation(MachObjectWriter *Writer,
396396
if (!SB->getFragment()) {
397397
Asm.getContext().reportError(
398398
Fixup.getLoc(),
399-
"symbol '" + B->getSymbol().getName() +
399+
"symbol '" + SB->getName() +
400400
"' can not be undefined in a subtraction expression");
401401
return false;
402402
}
@@ -408,7 +408,7 @@ bool X86MachObjectWriter::recordScatteredRelocation(MachObjectWriter *Writer,
408408
// pedantic compatibility with 'as'.
409409
Type = A->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF
410410
: (unsigned)MachO::GENERIC_RELOC_LOCAL_SECTDIFF;
411-
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
411+
Value2 = Writer->getSymbolAddress(*SB, Layout);
412412
FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
413413
}
414414

@@ -468,8 +468,8 @@ void X86MachObjectWriter::recordTLVPRelocation(MachObjectWriter *Writer,
468468
const MCFixup &Fixup,
469469
MCValue Target,
470470
uint64_t &FixedValue) {
471-
assert(Target.getSymA()->getKind() == MCSymbolRefExpr::VK_TLVP &&
472-
!is64Bit() &&
471+
const MCSymbolRefExpr *SymA = Target.getSymA();
472+
assert(SymA->getKind() == MCSymbolRefExpr::VK_TLVP && !is64Bit() &&
473473
"Should only be called with a 32-bit TLVP relocation!");
474474

475475
unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind());
@@ -480,15 +480,14 @@ void X86MachObjectWriter::recordTLVPRelocation(MachObjectWriter *Writer,
480480
// subtraction from the picbase. For 32-bit pic the addend is the difference
481481
// between the picbase and the next address. For 32-bit static the addend is
482482
// zero.
483-
if (Target.getSymB()) {
483+
if (auto *SymB = Target.getSymB()) {
484484
// If this is a subtraction then we're pcrel.
485485
uint32_t FixupAddress =
486486
Writer->getFragmentAddress(Fragment, Layout) + Fixup.getOffset();
487487
IsPCRel = 1;
488-
FixedValue =
489-
FixupAddress -
490-
Writer->getSymbolAddress(Target.getSymB()->getSymbol(), Layout) +
491-
Target.getConstant();
488+
FixedValue = FixupAddress -
489+
Writer->getSymbolAddress(SymB->getSymbol(), Layout) +
490+
Target.getConstant();
492491
FixedValue += 1ULL << Log2Size;
493492
} else {
494493
FixedValue = 0;
@@ -499,8 +498,7 @@ void X86MachObjectWriter::recordTLVPRelocation(MachObjectWriter *Writer,
499498
MRE.r_word0 = Value;
500499
MRE.r_word1 =
501500
(IsPCRel << 24) | (Log2Size << 25) | (MachO::GENERIC_RELOC_TLV << 28);
502-
Writer->addRelocation(&Target.getSymA()->getSymbol(), Fragment->getParent(),
503-
MRE);
501+
Writer->addRelocation(&SymA->getSymbol(), Fragment->getParent(), MRE);
504502
}
505503

506504
void X86MachObjectWriter::RecordX86Relocation(MachObjectWriter *Writer,

0 commit comments

Comments
 (0)