29 AddTimer(Label::Timer).start();
35 const auto fullName =
util::strfmt(std::setw(3), std::setfill(
'0'), passNumber,
"-", passName);
38 AddMeasurement(fullName +
"-#RvsdgNodesBefore", totalNodes);
40 JLM_ASSERT(currentTransformationTimer_ ==
nullptr);
41 currentTransformationTimer_ = &AddTimer(fullName +
"-Timer");
42 currentTransformationTimer_->start();
48 JLM_ASSERT(currentTransformationTimer_ !=
nullptr);
49 currentTransformationTimer_->stop();
50 currentTransformationTimer_ =
nullptr;
56 GetTimer(Label::Timer).stop();
57 AddMeasurement(Label::NumRvsdgNodesAfter,
nnodes(&graph.GetRootRegion()));
60 static std::unique_ptr<Statistics>
63 return std::make_unique<Statistics>(sourceFile);
69 return collector.
IsDemanded(Id::RvsdgOptimization);
81 util::StatisticsCollector & statisticsCollector)
83 std::unique_ptr<Statistics> statistics;
84 if (Statistics::IsDemandedBy(statisticsCollector))
85 statistics = Statistics::Create(rvsdgModule.SourceFilePath().value());
88 statistics->StartMeasuring();
91 if (DumpRvsdgDotGraphs_)
95 statisticsCollector.GetSettings().GetOrCreateOutputDirectory(),
101 for (
const auto & transformation : Transformations_)
104 statistics->StartTransformationMeasuring(
106 transformation->GetName(),
107 rvsdgModule.Rvsdg());
109 transformation->Run(rvsdgModule, statisticsCollector);
112 statistics->EndTransformationMeasuring();
114 if (DumpRvsdgDotGraphs_)
118 statisticsCollector.GetSettings().GetOrCreateOutputDirectory(),
119 "After" + std::string(transformation->GetName()),
128 statistics->EndMeasuring(rvsdgModule.Rvsdg());
129 statisticsCollector.CollectDemandedStatistics(std::move(statistics));
137 const std::string & passName,
138 size_t numPass)
const
145 std::stringstream filePath;
146 filePath << outputDir.
to_str() <<
"/" << std::setw(3) << std::setfill(
'0') << numPass <<
"-"
147 << passName <<
".dot";
149 std::ofstream outputFile;
150 outputFile.open(filePath.str());
util::graph::Graph & WriteGraphs(util::graph::Writer &writer, const Region ®ion, bool emitTypeGraph)
Region & GetRootRegion() const noexcept
bool IsDirectory() const noexcept
Determines whether file path is a directory.
const std::string & to_str() const noexcept
bool Exists() const noexcept
Determines whether the file path exists.
bool IsDemanded(Statistics::Id id) const noexcept
void outputAllGraphs(std::ostream &out, OutputFormat format)
size_t nnodes(const jlm::rvsdg::Region *region) noexcept
static std::string strfmt(Args... args)