@@ -863,34 +863,24 @@ bool MCAssembler::fixupNeedsRelaxation(const MCRelaxableFragment &F,
863
863
Resolved);
864
864
}
865
865
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" );
868
869
// If this inst doesn't ever need relaxation, ignore it. This occurs when we
869
870
// are intentionally pushing out inst fragments, or because we relaxed a
870
871
// previous instruction to one that doesn't need relaxation.
871
872
if (!getBackend ().mayNeedRelaxation (F.getInst (), *F.getSubtargetInfo ()))
872
873
return false ;
873
874
875
+ bool DoRelax = false ;
874
876
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)
885
880
return false ;
886
881
887
882
++stats::RelaxedInstructions;
888
883
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
-
894
884
MCInst Relaxed = F.getInst ();
895
885
getBackend ().relaxInstruction (Relaxed, *F.getSubtargetInfo ());
896
886
0 commit comments