Skip to content

Commit 408e871

Browse files
committed
MCAssembler: Merge fragmentNeedsRelaxation into relaxInstruction
1 parent fa9cd47 commit 408e871

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

llvm/include/llvm/MC/MCAssembler.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ class MCAssembler {
109109
/// (increased in size, in order to hold its value correctly).
110110
bool fixupNeedsRelaxation(const MCRelaxableFragment &, const MCFixup &) const;
111111

112-
/// Check whether the given fragment needs relaxation.
113-
bool fragmentNeedsRelaxation(const MCRelaxableFragment &) const;
114-
115112
void layoutSection(MCSection &Sec);
116113
/// Perform one layout iteration and return the index of the first stable
117114
/// section for subsequent optimization.

llvm/lib/MC/MCAssembler.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -863,34 +863,24 @@ bool MCAssembler::fixupNeedsRelaxation(const MCRelaxableFragment &F,
863863
Resolved);
864864
}
865865

866-
bool MCAssembler::fragmentNeedsRelaxation(const MCRelaxableFragment &F) const {
867-
assert(getBackendPtr() && "Expected assembler backend");
866+
bool MCAssembler::relaxInstruction(MCRelaxableFragment &F) {
867+
assert(getEmitterPtr() &&
868+
"Expected CodeEmitter defined for relaxInstruction");
868869
// If this inst doesn't ever need relaxation, ignore it. This occurs when we
869870
// are intentionally pushing out inst fragments, or because we relaxed a
870871
// previous instruction to one that doesn't need relaxation.
871872
if (!getBackend().mayNeedRelaxation(F.getInst(), *F.getSubtargetInfo()))
872873
return false;
873874

875+
bool DoRelax = false;
874876
for (const MCFixup &Fixup : F.getFixups())
875-
if (fixupNeedsRelaxation(F, Fixup))
876-
return true;
877-
878-
return false;
879-
}
880-
881-
bool MCAssembler::relaxInstruction(MCRelaxableFragment &F) {
882-
assert(getEmitterPtr() &&
883-
"Expected CodeEmitter defined for relaxInstruction");
884-
if (!fragmentNeedsRelaxation(F))
877+
if ((DoRelax = fixupNeedsRelaxation(F, Fixup)))
878+
break;
879+
if (!DoRelax)
885880
return false;
886881

887882
++stats::RelaxedInstructions;
888883

889-
// FIXME-PERF: We could immediately lower out instructions if we can tell
890-
// they are fully resolved, to avoid retesting on later passes.
891-
892-
// Relax the fragment.
893-
894884
MCInst Relaxed = F.getInst();
895885
getBackend().relaxInstruction(Relaxed, *F.getSubtargetInfo());
896886

0 commit comments

Comments
 (0)