@@ -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