[llvm] r328459 - [SchedModel] Remove instregex entries that don't match any instructions

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 25 12:20:08 PDT 2018


Author: rksimon
Date: Sun Mar 25 12:20:08 2018
New Revision: 328459

URL: http://llvm.org/viewvc/llvm-project?rev=328459&view=rev
Log:
[SchedModel] Remove instregex entries that don't match any instructions

This patch throws a fatal error if an instregex entry doesn't actually match any instructions. This is part of the work to reduce the compile time impact of increased instregex usage (PR35955), although the x86 models seem to be relatively clean.

All the cases I encountered have now been fixed in trunk and this will ensure they don't get reintroduced.

Differential Revision: https://reviews.llvm.org/D44687

Modified:
    llvm/trunk/utils/TableGen/CodeGenSchedule.cpp

Modified: llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenSchedule.cpp?rev=328459&r1=328458&r2=328459&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenSchedule.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenSchedule.cpp Sun Mar 25 12:20:08 2018
@@ -106,6 +106,8 @@ struct InstRegexOp : public SetTheory::O
         Regexpr = Regex(pat);
       }
 
+      int NumMatches = 0;
+
       unsigned NumGeneric = Target.getNumFixedInstructions();
       ArrayRef<const CodeGenInstruction *> Generics =
           Target.getInstructionsByEnumValue().slice(0, NumGeneric + 1);
@@ -114,8 +116,10 @@ struct InstRegexOp : public SetTheory::O
       for (auto *Inst : Generics) {
         StringRef InstName = Inst->TheDef->getName();
         if (InstName.startswith(Prefix) &&
-            (!Regexpr || Regexpr->match(InstName.substr(Prefix.size()))))
+            (!Regexpr || Regexpr->match(InstName.substr(Prefix.size())))) {
           Elts.insert(Inst->TheDef);
+          NumMatches++;
+        }
       }
 
       ArrayRef<const CodeGenInstruction *> Instructions =
@@ -139,9 +143,14 @@ struct InstRegexOp : public SetTheory::O
       // a regex that needs to be checked.
       for (auto *Inst : make_range(Range)) {
         StringRef InstName = Inst->TheDef->getName();
-        if (!Regexpr || Regexpr->match(InstName.substr(Prefix.size())))
+        if (!Regexpr || Regexpr->match(InstName.substr(Prefix.size()))) {
           Elts.insert(Inst->TheDef);
+          NumMatches++;
+        }
       }
+
+      if (0 == NumMatches)
+        PrintFatalError(Loc, "instregex has no matches: " + Original);
     }
   }
 };




More information about the llvm-commits mailing list