@@ -902,14 +902,19 @@ SubtargetEmitter::FindWriteResources(const CodeGenSchedRW &SchedWrite,
902
902
for (Record *WR : ProcModel.WriteResDefs ) {
903
903
if (!WR->isSubClassOf (" WriteRes" ))
904
904
continue ;
905
- if (AliasDef == WR->getValueAsDef (" WriteType" ) ||
906
- SchedWrite.TheDef == WR-> getValueAsDef ( " WriteType " ) ) {
905
+ Record *WRDef = WR->getValueAsDef (" WriteType" );
906
+ if (AliasDef == WRDef || SchedWrite.TheDef == WRDef ) {
907
907
if (ResDef) {
908
908
PrintFatalError (WR->getLoc (), " Resources are defined for both "
909
909
" SchedWrite and its alias on processor " +
910
910
ProcModel.ModelName );
911
911
}
912
912
ResDef = WR;
913
+ // If there is no AliasDef and we find a match, we can early exit since
914
+ // there is no need to verify whether there are resources defined for both
915
+ // SchedWrite and its alias.
916
+ if (!AliasDef)
917
+ break ;
913
918
}
914
919
}
915
920
// TODO: If ProcModel has a base model (previous generation processor),
@@ -956,14 +961,19 @@ Record *SubtargetEmitter::FindReadAdvance(const CodeGenSchedRW &SchedRead,
956
961
for (Record *RA : ProcModel.ReadAdvanceDefs ) {
957
962
if (!RA->isSubClassOf (" ReadAdvance" ))
958
963
continue ;
959
- if (AliasDef == RA->getValueAsDef (" ReadType" ) ||
960
- SchedRead.TheDef == RA-> getValueAsDef ( " ReadType " ) ) {
964
+ Record *RADef = RA->getValueAsDef (" ReadType" );
965
+ if (AliasDef == RADef || SchedRead.TheDef == RADef ) {
961
966
if (ResDef) {
962
967
PrintFatalError (RA->getLoc (), " Resources are defined for both "
963
968
" SchedRead and its alias on processor " +
964
969
ProcModel.ModelName );
965
970
}
966
971
ResDef = RA;
972
+ // If there is no AliasDef and we find a match, we can early exit since
973
+ // there is no need to verify whether there are resources defined for both
974
+ // SchedRead and its alias.
975
+ if (!AliasDef)
976
+ break ;
967
977
}
968
978
}
969
979
// TODO: If ProcModel has a base model (previous generation processor),
0 commit comments