[PATCH] D46098: [GlobalISel][InstructionSelect] Making Coverage Info generation optional on per-match table basis

Roman Tereshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 2 13:19:27 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL331398: [GlobalISel][InstructionSelect] Making Coverage Info generation optional on per… (authored by rtereshin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46098?vs=144042&id=144925#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46098

Files:
  llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp


Index: llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
===================================================================
--- llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
+++ llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
@@ -424,6 +424,8 @@
   unsigned CurrentSize = 0;
   /// A unique identifier for a MatchTable label.
   unsigned CurrentLabelID = 0;
+  /// Determines if the table should be instrumented for rule coverage tracking.
+  bool IsWithCoverage;
 
 public:
   static MatchTableRecord LineBreak;
@@ -466,9 +468,12 @@
                                 MatchTableRecord::MTRF_CommaFollows);
   }
 
-  static MatchTable buildTable(ArrayRef<Matcher *> Rules);
+  static MatchTable buildTable(ArrayRef<Matcher *> Rules, bool WithCoverage);
 
-  MatchTable(unsigned ID = 0) : ID(ID) {}
+  MatchTable(bool WithCoverage, unsigned ID = 0)
+      : ID(ID), IsWithCoverage(WithCoverage) {}
+
+  bool isWithCoverage() const { return IsWithCoverage; }
 
   void push_back(const MatchTableRecord &Value) {
     if (Value.Flags & MatchTableRecord::MTRF_Label)
@@ -578,8 +583,9 @@
   virtual std::unique_ptr<PredicateMatcher> forgetFirstCondition() = 0;
 };
 
-MatchTable MatchTable::buildTable(ArrayRef<Matcher *> Rules) {
-  MatchTable Table;
+MatchTable MatchTable::buildTable(ArrayRef<Matcher *> Rules,
+                                  bool WithCoverage) {
+  MatchTable Table(WithCoverage);
   for (Matcher *Rule : Rules)
     Rule->emit(Table);
 
@@ -2492,7 +2498,7 @@
   for (const auto &MA : Actions)
     MA->emitActionOpcodes(Table, *this);
 
-  if (GenerateCoverage)
+  if (Table.isWithCoverage())
     Table << MatchTable::Opcode("GIR_Coverage") << MatchTable::IntValue(RuleID)
           << MatchTable::LineBreak;
 
@@ -2698,7 +2704,8 @@
       ArrayRef<Matcher *> Rules,
       std::vector<std::unique_ptr<GroupMatcher>> &StorageGroupMatcher);
 
-  MatchTable buildMatchTable(MutableArrayRef<RuleMatcher> Rules, bool Optimize);
+  MatchTable buildMatchTable(MutableArrayRef<RuleMatcher> Rules, bool Optimize,
+                             bool WithCoverage);
 };
 
 void GlobalISelEmitter::gatherNodeEquivs() {
@@ -3688,19 +3695,19 @@
 
 MatchTable
 GlobalISelEmitter::buildMatchTable(MutableArrayRef<RuleMatcher> Rules,
-                                   bool Optimize) {
+                                   bool Optimize, bool WithCoverage) {
   std::vector<Matcher *> InputRules;
   for (Matcher &Rule : Rules)
     InputRules.push_back(&Rule);
 
   if (!Optimize)
-    return MatchTable::buildTable(InputRules);
+    return MatchTable::buildTable(InputRules, WithCoverage);
 
   std::vector<std::unique_ptr<GroupMatcher>> StorageGroupMatcher;
   std::vector<Matcher *> OptRules =
       optimizeRules(InputRules, StorageGroupMatcher);
 
-  return MatchTable::buildTable(OptRules);
+  return MatchTable::buildTable(OptRules, WithCoverage);
 }
 
 void GlobalISelEmitter::run(raw_ostream &OS) {
@@ -3991,7 +3998,8 @@
      << "  return false;\n"
      << "}\n\n";
 
-  const MatchTable Table = buildMatchTable(Rules, OptimizeMatchTable);
+  const MatchTable Table =
+      buildMatchTable(Rules, OptimizeMatchTable, GenerateCoverage);
   OS << "const int64_t *" << Target.getName()
      << "InstructionSelector::getMatchTable() const {\n";
   Table.emitDeclaration(OS);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46098.144925.patch
Type: text/x-patch
Size: 3290 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180502/3819d752/attachment.bin>


More information about the llvm-commits mailing list