[llvm] r330317 - [llvm-exegesis] Fix PfmIssueCountersTable creation

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 19 03:59:49 PDT 2018


Author: rksimon
Date: Thu Apr 19 03:59:49 2018
New Revision: 330317

URL: http://llvm.org/viewvc/llvm-project?rev=330317&view=rev
Log:
[llvm-exegesis] Fix PfmIssueCountersTable creation

This patch ensures that the pfm issue counter tables are the correct size, accounting for the invalid resource entry at the beginning of the resource tables.

It also fixes an issue with pfm failing to match event counters due to a trailing comma added to all the event names.

I've also added a counter comment to each entry as it helps locate problems with the tables.

Note: I don't have access to a SandyBridge test machine, which is the only model to make use of multiple event counters being mapped to a single resource. I don't know if pfm accepts a comma-seperated list or not, but that is what it was doing.

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

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

Modified: llvm/trunk/utils/TableGen/SubtargetEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SubtargetEmitter.cpp?rev=330317&r1=330316&r2=330317&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/SubtargetEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/SubtargetEmitter.cpp Thu Apr 19 03:59:49 2018
@@ -686,9 +686,11 @@ SubtargetEmitter::EmitRegisterFileTables
 
   return CostTblIndex;
 }
+
 static bool EmitPfmIssueCountersTable(const CodeGenProcModel &ProcModel,
                                       raw_ostream &OS) {
-  std::vector<const Record *> CounterDefs(ProcModel.ProcResourceDefs.size());
+  unsigned NumCounterDefs = 1 + ProcModel.ProcResourceDefs.size();
+  std::vector<const Record *> CounterDefs(NumCounterDefs);
   bool HasCounters = false;
   for (const Record *CounterDef : ProcModel.PfmIssueCounterDefs) {
     const Record *&CD = CounterDefs[ProcModel.getProcResourceIdx(
@@ -706,16 +708,19 @@ static bool EmitPfmIssueCountersTable(co
   }
   OS << "\nstatic const char* " << ProcModel.ModelName
      << "PfmIssueCounters[] = {\n";
-  for (const Record *CounterDef : CounterDefs) {
+  for (unsigned i = 0; i != NumCounterDefs; ++i) {
+    const Record *CounterDef = CounterDefs[i];
     if (CounterDef) {
       const auto PfmCounters = CounterDef->getValueAsListOfStrings("Counters");
       if (PfmCounters.empty())
         PrintFatalError(CounterDef->getLoc(), "empty counter list");
-      for (const StringRef CounterName : PfmCounters)
-        OS << "  \"" << CounterName << ",\"";
-      OS << ",  //" << CounterDef->getValueAsDef("Resource")->getName() << "\n";
+      OS << "  \"" << PfmCounters[0];
+      for (unsigned p = 1, e = PfmCounters.size(); p != e; ++p)
+        OS << ",\" \"" << PfmCounters[p];
+      OS << "\",  // #" << i << " = ";
+      OS << CounterDef->getValueAsDef("Resource")->getName() << "\n";
     } else {
-      OS << "  nullptr,\n";
+      OS << "  nullptr, // #" << i << "\n";
     }
   }
   OS << "};\n";




More information about the llvm-commits mailing list