@@ -902,19 +902,21 @@ 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
+ // If there is no AliasDef and we find a match, we can early exit since
906
+ // there is no need to verify whether there are resources defined for both
907
+ // SchedWrite and its alias.
908
+ if (!AliasDef && SchedWrite.TheDef == WR->getValueAsDef (" WriteType" )) {
907
909
ResDef = WR;
908
910
break ;
909
- }
910
- }
911
-
912
- if (ResDef && AliasDef) {
913
- PrintFatalError (ResDef->getLoc (), " Resources are defined for both "
911
+ } else if (AliasDef == WR->getValueAsDef (" WriteType" )) {
912
+ if (ResDef) {
913
+ PrintFatalError (WR->getLoc (), " Resources are defined for both "
914
914
" SchedWrite and its alias on processor " +
915
915
ProcModel.ModelName );
916
+ }
917
+ ResDef = WR;
918
+ }
916
919
}
917
-
918
920
// TODO: If ProcModel has a base model (previous generation processor),
919
921
// then call FindWriteResources recursively with that model here.
920
922
if (!ResDef) {
@@ -959,18 +961,21 @@ Record *SubtargetEmitter::FindReadAdvance(const CodeGenSchedRW &SchedRead,
959
961
for (Record *RA : ProcModel.ReadAdvanceDefs ) {
960
962
if (!RA->isSubClassOf (" ReadAdvance" ))
961
963
continue ;
962
- if (AliasDef == RA->getValueAsDef (" ReadType" ) ||
963
- SchedRead.TheDef == RA->getValueAsDef (" ReadType" )) {
964
- ResDef = RA;
964
+ // If there is no AliasDef and we find a match, we can early exit since
965
+ // there is no need to verify whether there are resources defined for both
966
+ // SchedWrite and its alias.
967
+ if (!AliasDef && AliasDef == RA->getValueAsDef (" ReadType" )) {
968
+ ResDef = WR;
965
969
break ;
966
- }
967
- }
968
- if (ResDef && AliasDef) {
969
- PrintFatalError (ResDef->getLoc (), " Resources are defined for both "
970
+ } else if (SchedRead.TheDef == RA->getValueAsDef (" ReadType" )) {
971
+ if (ResDef) {
972
+ PrintFatalError (RA->getLoc (), " Resources are defined for both "
970
973
" SchedRead and its alias on processor " +
971
974
ProcModel.ModelName );
975
+ }
976
+ ResDef = RA;
977
+ }
972
978
}
973
-
974
979
// TODO: If ProcModel has a base model (previous generation processor),
975
980
// then call FindReadAdvance recursively with that model here.
976
981
if (!ResDef && SchedRead.TheDef ->getName () != " ReadDefault" ) {
0 commit comments