From: Simon Pilgrim Date: Thu, 19 Apr 2018 10:59:49 +0000 (+0000) Subject: [llvm-exegesis] Fix PfmIssueCountersTable creation X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b04cd1b9f3a877290d893c9a19ea3ea40e38a135;p=platform%2Fupstream%2Fllvm.git [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 llvm-svn: 330317 --- diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp index 38b0df6..e2e5b8b 100644 --- a/llvm/utils/TableGen/SubtargetEmitter.cpp +++ b/llvm/utils/TableGen/SubtargetEmitter.cpp @@ -686,9 +686,11 @@ SubtargetEmitter::EmitRegisterFileTables(const CodeGenProcModel &ProcModel, return CostTblIndex; } + static bool EmitPfmIssueCountersTable(const CodeGenProcModel &ProcModel, raw_ostream &OS) { - std::vector CounterDefs(ProcModel.ProcResourceDefs.size()); + unsigned NumCounterDefs = 1 + ProcModel.ProcResourceDefs.size(); + std::vector CounterDefs(NumCounterDefs); bool HasCounters = false; for (const Record *CounterDef : ProcModel.PfmIssueCounterDefs) { const Record *&CD = CounterDefs[ProcModel.getProcResourceIdx( @@ -706,16 +708,19 @@ static bool EmitPfmIssueCountersTable(const CodeGenProcModel &ProcModel, } 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";