diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-04-19 10:59:49 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-04-19 10:59:49 +0000 |
commit | b04cd1b9f3a877290d893c9a19ea3ea40e38a135 (patch) | |
tree | c5885bf5814817cf19680312b5ae6056177ef1e3 /llvm | |
parent | 147fc016e3ce9575545d55837c2e4775c7ca67c9 (diff) | |
download | bcm5719-llvm-b04cd1b9f3a877290d893c9a19ea3ea40e38a135.tar.gz bcm5719-llvm-b04cd1b9f3a877290d893c9a19ea3ea40e38a135.zip |
[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
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/utils/TableGen/SubtargetEmitter.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp index 38b0df60239..e2e5b8b2164 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<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(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"; |