@@ -3307,6 +3307,10 @@ class GICombinerEmitter final : public GlobalISelMatchTableExecutorEmitter {
3307
3307
// combine rule used to disable/enable it.
3308
3308
std::vector<std::pair<unsigned , std::string>> AllCombineRules;
3309
3309
3310
+ // Keep track of all rules we've seen so far to ensure we don't process
3311
+ // the same rule twice.
3312
+ StringSet<> RulesSeen;
3313
+
3310
3314
MatchTable buildMatchTable (MutableArrayRef<RuleMatcher> Rules);
3311
3315
3312
3316
void emitRuleConfigImpl (raw_ostream &OS);
@@ -3624,27 +3628,37 @@ void GICombinerEmitter::gatherRules(
3624
3628
std::vector<RuleMatcher> &ActiveRules,
3625
3629
const std::vector<Record *> &&RulesAndGroups) {
3626
3630
for (Record *Rec : RulesAndGroups) {
3627
- if (Rec->isValueUnset (" Rules" )) {
3628
- AllCombineRules. emplace_back (NextRuleID , Rec->getName (). str ( ));
3629
- CombineRuleBuilder CRB (Target, SubtargetFeatures, *Rec, NextRuleID++,
3630
- ActiveRules);
3631
+ if (! Rec->isValueUnset (" Rules" )) {
3632
+ gatherRules (ActiveRules , Rec->getValueAsListOfDefs ( " Rules " ));
3633
+ continue ;
3634
+ }
3631
3635
3632
- if (!CRB.parseAll ()) {
3633
- assert (ErrorsPrinted && " Parsing failed without errors!" );
3634
- continue ;
3635
- }
3636
+ StringRef RuleName = Rec->getName ();
3637
+ if (!RulesSeen.insert (RuleName).second ) {
3638
+ PrintWarning (Rec->getLoc (),
3639
+ " skipping rule '" + Rec->getName () +
3640
+ " ' because it has already been processed" );
3641
+ continue ;
3642
+ }
3636
3643
3637
- if (StopAfterParse) {
3638
- CRB.print (outs ());
3639
- continue ;
3640
- }
3644
+ AllCombineRules.emplace_back (NextRuleID, Rec->getName ().str ());
3645
+ CombineRuleBuilder CRB (Target, SubtargetFeatures, *Rec, NextRuleID++,
3646
+ ActiveRules);
3641
3647
3642
- if (!CRB.emitRuleMatchers ()) {
3643
- assert (ErrorsPrinted && " Emission failed without errors!" );
3644
- continue ;
3645
- }
3646
- } else
3647
- gatherRules (ActiveRules, Rec->getValueAsListOfDefs (" Rules" ));
3648
+ if (!CRB.parseAll ()) {
3649
+ assert (ErrorsPrinted && " Parsing failed without errors!" );
3650
+ continue ;
3651
+ }
3652
+
3653
+ if (StopAfterParse) {
3654
+ CRB.print (outs ());
3655
+ continue ;
3656
+ }
3657
+
3658
+ if (!CRB.emitRuleMatchers ()) {
3659
+ assert (ErrorsPrinted && " Emission failed without errors!" );
3660
+ continue ;
3661
+ }
3648
3662
}
3649
3663
}
3650
3664
0 commit comments