Skip to content

[TableGen][SubtargetEmitter] Early exit from loop in FindWriteResources and FindReadAdvance #92202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
18 changes: 14 additions & 4 deletions llvm/utils/TableGen/SubtargetEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,19 @@ SubtargetEmitter::FindWriteResources(const CodeGenSchedRW &SchedWrite,
for (Record *WR : ProcModel.WriteResDefs) {
if (!WR->isSubClassOf("WriteRes"))
continue;
if (AliasDef == WR->getValueAsDef("WriteType") ||
SchedWrite.TheDef == WR->getValueAsDef("WriteType")) {
Record *WRDef = WR->getValueAsDef("WriteType");
if (AliasDef == WRDef || SchedWrite.TheDef == WRDef) {
if (ResDef) {
PrintFatalError(WR->getLoc(), "Resources are defined for both "
"SchedWrite and its alias on processor " +
ProcModel.ModelName);
}
ResDef = WR;
// If there is no AliasDef and we find a match, we can early exit since
// there is no need to verify whether there are resources defined for both
// SchedWrite and its alias.
if (!AliasDef)
break;
}
}
// TODO: If ProcModel has a base model (previous generation processor),
Expand Down Expand Up @@ -956,14 +961,19 @@ Record *SubtargetEmitter::FindReadAdvance(const CodeGenSchedRW &SchedRead,
for (Record *RA : ProcModel.ReadAdvanceDefs) {
if (!RA->isSubClassOf("ReadAdvance"))
continue;
if (AliasDef == RA->getValueAsDef("ReadType") ||
SchedRead.TheDef == RA->getValueAsDef("ReadType")) {
Record *RADef = RA->getValueAsDef("ReadType");
if (AliasDef == RADef || SchedRead.TheDef == RADef) {
if (ResDef) {
PrintFatalError(RA->getLoc(), "Resources are defined for both "
"SchedRead and its alias on processor " +
ProcModel.ModelName);
}
ResDef = RA;
// If there is no AliasDef and we find a match, we can early exit since
// there is no need to verify whether there are resources defined for both
// SchedRead and its alias.
if (!AliasDef)
break;
}
}
// TODO: If ProcModel has a base model (previous generation processor),
Expand Down
Loading