Skip to content

Commit eac1a1d

Browse files
committed
MCAssembler: Consistently place MCFragment parameter before MCFixup
... to be consistent with other places, e.g. `recordRelocation`. While here, use references instead of non-null pointers.
1 parent b68e8f1 commit eac1a1d

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

llvm/include/llvm/MC/MCAssembler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,16 @@ class MCAssembler {
101101
/// out.
102102
/// \param RecordReloc Record relocation if needed.
103103
/// relocation.
104-
bool evaluateFixup(const MCFragment *F, const MCFixup &Fixup, MCValue &Target,
104+
bool evaluateFixup(const MCFragment &F, const MCFixup &Fixup, MCValue &Target,
105105
uint64_t &Value, bool RecordReloc,
106106
MutableArrayRef<char> Contents) const;
107107

108108
/// Check whether a fixup can be satisfied, or whether it needs to be relaxed
109109
/// (increased in size, in order to hold its value correctly).
110-
bool fixupNeedsRelaxation(const MCFixup &Fixup, const MCRelaxableFragment *DF) const;
110+
bool fixupNeedsRelaxation(const MCRelaxableFragment &, const MCFixup &) const;
111111

112112
/// Check whether the given fragment needs relaxation.
113-
bool fragmentNeedsRelaxation(const MCRelaxableFragment *IF) const;
113+
bool fragmentNeedsRelaxation(const MCRelaxableFragment &) const;
114114

115115
void layoutSection(MCSection &Sec);
116116
/// Perform one layout iteration and return true if any offsets

llvm/lib/MC/MCAssembler.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ bool MCAssembler::isThumbFunc(const MCSymbol *Symbol) const {
142142
return true;
143143
}
144144

145-
bool MCAssembler::evaluateFixup(const MCFragment *DF, const MCFixup &Fixup,
145+
bool MCAssembler::evaluateFixup(const MCFragment &F, const MCFixup &Fixup,
146146
MCValue &Target, uint64_t &Value,
147147
bool RecordReloc,
148148
MutableArrayRef<char> Contents) const {
@@ -178,7 +178,7 @@ bool MCAssembler::evaluateFixup(const MCFragment *DF, const MCFixup &Fixup,
178178
bool ShouldAlignPC =
179179
FixupFlags & MCFixupKindInfo::FKF_IsAlignedDownTo32Bits;
180180
if (IsPCRel) {
181-
uint64_t Offset = getFragmentOffset(*DF) + Fixup.getOffset();
181+
uint64_t Offset = getFragmentOffset(F) + Fixup.getOffset();
182182

183183
// A number of ARM fixups in Thumb mode require that the effective PC
184184
// address be determined as the 32-bit aligned version of the actual
@@ -189,7 +189,7 @@ bool MCAssembler::evaluateFixup(const MCFragment *DF, const MCFixup &Fixup,
189189

190190
if (Add && !Sub && !Add->isUndefined() && !Add->isAbsolute()) {
191191
IsResolved = getWriter().isSymbolRefDifferenceFullyResolvedImpl(
192-
*Add, *DF, false, true);
192+
*Add, F, false, true);
193193
}
194194
} else {
195195
IsResolved = Target.isAbsolute();
@@ -202,8 +202,8 @@ bool MCAssembler::evaluateFixup(const MCFragment *DF, const MCFixup &Fixup,
202202

203203
if (IsResolved && mc::isRelocRelocation(Fixup.getKind()))
204204
IsResolved = false;
205-
IsResolved = getBackend().addReloc(*DF, Fixup, Target, Value, IsResolved);
206-
getBackend().applyFixup(*DF, Fixup, Target, Contents, Value, IsResolved);
205+
IsResolved = getBackend().addReloc(F, Fixup, Target, Value, IsResolved);
206+
getBackend().applyFixup(F, Fixup, Target, Contents, Value, IsResolved);
207207
return true;
208208
}
209209

@@ -934,7 +934,7 @@ void MCAssembler::layout() {
934934
for (const MCFixup &Fixup : Fixups) {
935935
uint64_t FixedValue;
936936
MCValue Target;
937-
evaluateFixup(&Frag, Fixup, Target, FixedValue,
937+
evaluateFixup(Frag, Fixup, Target, FixedValue,
938938
/*RecordReloc=*/true, Contents);
939939
}
940940
}
@@ -951,27 +951,27 @@ void MCAssembler::Finish() {
951951
assert(PendingErrors.empty());
952952
}
953953

954-
bool MCAssembler::fixupNeedsRelaxation(const MCFixup &Fixup,
955-
const MCRelaxableFragment *DF) const {
954+
bool MCAssembler::fixupNeedsRelaxation(const MCRelaxableFragment &F,
955+
const MCFixup &Fixup) const {
956956
assert(getBackendPtr() && "Expected assembler backend");
957957
MCValue Target;
958958
uint64_t Value;
959-
bool Resolved = evaluateFixup(DF, const_cast<MCFixup &>(Fixup), Target, Value,
959+
bool Resolved = evaluateFixup(F, const_cast<MCFixup &>(Fixup), Target, Value,
960960
/*RecordReloc=*/false, {});
961961
return getBackend().fixupNeedsRelaxationAdvanced(Fixup, Target, Value,
962962
Resolved);
963963
}
964964

965-
bool MCAssembler::fragmentNeedsRelaxation(const MCRelaxableFragment *F) const {
965+
bool MCAssembler::fragmentNeedsRelaxation(const MCRelaxableFragment &F) const {
966966
assert(getBackendPtr() && "Expected assembler backend");
967967
// If this inst doesn't ever need relaxation, ignore it. This occurs when we
968968
// are intentionally pushing out inst fragments, or because we relaxed a
969969
// previous instruction to one that doesn't need relaxation.
970-
if (!getBackend().mayNeedRelaxation(F->getInst(), *F->getSubtargetInfo()))
970+
if (!getBackend().mayNeedRelaxation(F.getInst(), *F.getSubtargetInfo()))
971971
return false;
972972

973-
for (const MCFixup &Fixup : F->getFixups())
974-
if (fixupNeedsRelaxation(Fixup, F))
973+
for (const MCFixup &Fixup : F.getFixups())
974+
if (fixupNeedsRelaxation(F, Fixup))
975975
return true;
976976

977977
return false;
@@ -980,7 +980,7 @@ bool MCAssembler::fragmentNeedsRelaxation(const MCRelaxableFragment *F) const {
980980
bool MCAssembler::relaxInstruction(MCRelaxableFragment &F) {
981981
assert(getEmitterPtr() &&
982982
"Expected CodeEmitter defined for relaxInstruction");
983-
if (!fragmentNeedsRelaxation(&F))
983+
if (!fragmentNeedsRelaxation(F))
984984
return false;
985985

986986
++stats::RelaxedInstructions;

0 commit comments

Comments
 (0)