From 074ff7c5b649b56708b82e925d82dc8283f4c207 Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Wed, 11 Apr 2018 12:31:44 +0000 Subject: [PATCH] [llvm-mca] Minor code cleanup. NFC llvm-svn: 329796 --- llvm/tools/llvm-mca/DispatchStatistics.cpp | 5 +++++ llvm/tools/llvm-mca/DispatchStatistics.h | 18 +++++------------- llvm/tools/llvm-mca/SchedulerStatistics.cpp | 6 +++--- llvm/tools/llvm-mca/SchedulerStatistics.h | 14 +++++--------- llvm/tools/llvm-mca/llvm-mca.cpp | 2 +- 5 files changed, 19 insertions(+), 26 deletions(-) diff --git a/llvm/tools/llvm-mca/DispatchStatistics.cpp b/llvm/tools/llvm-mca/DispatchStatistics.cpp index f1281c3..da85245 100644 --- a/llvm/tools/llvm-mca/DispatchStatistics.cpp +++ b/llvm/tools/llvm-mca/DispatchStatistics.cpp @@ -20,6 +20,11 @@ using namespace llvm; namespace mca { +void DispatchStatistics::onStallEvent(const HWStallEvent &Event) { + if (Event.Type < HWStallEvent::LastGenericEvent) + HWStalls[Event.Type]++; +} + void DispatchStatistics::onInstructionEvent(const HWInstructionEvent &Event) { if (Event.Type == HWInstructionEvent::Dispatched) ++NumDispatched; diff --git a/llvm/tools/llvm-mca/DispatchStatistics.h b/llvm/tools/llvm-mca/DispatchStatistics.h index e17338a..220ed84 100644 --- a/llvm/tools/llvm-mca/DispatchStatistics.h +++ b/llvm/tools/llvm-mca/DispatchStatistics.h @@ -42,11 +42,6 @@ namespace mca { class DispatchStatistics : public View { - const llvm::MCSubtargetInfo &STI; - - using Histogram = llvm::DenseMap; - Histogram DispatchGroupSizePerCycle; - unsigned NumDispatched; unsigned NumCycles; @@ -54,6 +49,9 @@ class DispatchStatistics : public View { // is one counter for every generic stall kind (see class HWStallEvent). llvm::SmallVector HWStalls; + using Histogram = llvm::DenseMap; + Histogram DispatchGroupSizePerCycle; + void updateHistograms() { DispatchGroupSizePerCycle[NumDispatched]++; NumDispatched = 0; @@ -62,12 +60,9 @@ class DispatchStatistics : public View { void printDispatchHistogram(llvm::raw_ostream &OS) const; void printDispatchStalls(llvm::raw_ostream &OS) const; - void printDispatchUnitUsage(llvm::raw_ostream &OS, const Histogram &Stats, - unsigned Cycles) const; public: - DispatchStatistics(const llvm::MCSubtargetInfo &sti) - : STI(sti), NumDispatched(0), NumCycles(0), + DispatchStatistics() : NumDispatched(0), NumCycles(0), HWStalls(HWStallEvent::LastGenericEvent) {} void onInstructionEvent(const HWInstructionEvent &Event) override; @@ -76,10 +71,7 @@ public: void onCycleEnd(unsigned Cycle) override { updateHistograms(); } - void onStallEvent(const HWStallEvent &Event) override { - if (Event.Type < HWStallEvent::LastGenericEvent) - HWStalls[Event.Type]++; - } + void onStallEvent(const HWStallEvent &Event) override; void printView(llvm::raw_ostream &OS) const override { printDispatchStalls(OS); diff --git a/llvm/tools/llvm-mca/SchedulerStatistics.cpp b/llvm/tools/llvm-mca/SchedulerStatistics.cpp index 28a34de..128bb8f 100644 --- a/llvm/tools/llvm-mca/SchedulerStatistics.cpp +++ b/llvm/tools/llvm-mca/SchedulerStatistics.cpp @@ -47,7 +47,8 @@ void SchedulerStatistics::onReleasedBuffers(ArrayRef Buffers) { } } -void SchedulerStatistics::printSchedulerStatistics(llvm::raw_ostream &OS) const { +void SchedulerStatistics::printSchedulerStatistics( + llvm::raw_ostream &OS) const { std::string Buffer; raw_string_ostream TempStream(Buffer); TempStream << "\n\nSchedulers - number of cycles where we saw N instructions " @@ -63,8 +64,7 @@ void SchedulerStatistics::printSchedulerStatistics(llvm::raw_ostream &OS) const OS << Buffer; } -void SchedulerStatistics::printSchedulerUsage(raw_ostream &OS, - const MCSchedModel &SM) const { +void SchedulerStatistics::printSchedulerUsage(raw_ostream &OS) const { std::string Buffer; raw_string_ostream TempStream(Buffer); TempStream << "\n\nScheduler's queue usage:\n"; diff --git a/llvm/tools/llvm-mca/SchedulerStatistics.h b/llvm/tools/llvm-mca/SchedulerStatistics.h index 88d35f0..6324115 100644 --- a/llvm/tools/llvm-mca/SchedulerStatistics.h +++ b/llvm/tools/llvm-mca/SchedulerStatistics.h @@ -39,7 +39,7 @@ namespace mca { class SchedulerStatistics : public View { - const llvm::MCSubtargetInfo &STI; + const llvm::MCSchedModel &SM; using Histogram = llvm::DenseMap; Histogram IssuedPerCycle; @@ -61,15 +61,11 @@ class SchedulerStatistics : public View { } void printSchedulerStatistics(llvm::raw_ostream &OS) const; - - void printIssuePerCycle(const Histogram &IssuePerCycle, - unsigned TotalCycles) const; - void printSchedulerUsage(llvm::raw_ostream &OS, - const llvm::MCSchedModel &SM) const; + void printSchedulerUsage(llvm::raw_ostream &OS) const; public: - SchedulerStatistics(const llvm::MCSubtargetInfo &sti) - : STI(sti), NumIssued(0), NumCycles(0) { } + SchedulerStatistics(const llvm::MCSubtargetInfo &STI) + : SM(STI.getSchedModel()), NumIssued(0), NumCycles(0) { } void onInstructionEvent(const HWInstructionEvent &Event) override; @@ -87,7 +83,7 @@ public: void printView(llvm::raw_ostream &OS) const override { printSchedulerStatistics(OS); - printSchedulerUsage(OS, STI.getSchedModel()); + printSchedulerUsage(OS); } }; } // namespace mca diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp index 3cb6292..89900a4 100644 --- a/llvm/tools/llvm-mca/llvm-mca.cpp +++ b/llvm/tools/llvm-mca/llvm-mca.cpp @@ -441,7 +441,7 @@ int main(int argc, char **argv) { llvm::make_unique(*STI, *MCII, S, *IP)); if (PrintDispatchStats) - Printer.addView(llvm::make_unique(*STI)); + Printer.addView(llvm::make_unique()); if (PrintSchedulerStats) Printer.addView(llvm::make_unique(*STI)); -- 2.7.4