summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
diff options
context:
space:
mode:
authorClement Courbet <courbet@google.com>2018-05-17 13:41:28 +0000
committerClement Courbet <courbet@google.com>2018-05-17 13:41:28 +0000
commitcf210746038b4b7a31b8dffb937611d6d9afc4df (patch)
tree80bce1d061af5f29d95a41b70fc69839182c5462 /llvm/tools/llvm-exegesis/llvm-exegesis.cpp
parent5e41fc83c5b614569ea862a4e412b8920b9aca1f (diff)
downloadbcm5719-llvm-cf210746038b4b7a31b8dffb937611d6d9afc4df.tar.gz
bcm5719-llvm-cf210746038b4b7a31b8dffb937611d6d9afc4df.zip
[llvm-exegesis] Write out inconsistencies to a file.
Reviewers: gchatelet Subscribers: tschuett, llvm-commits Differential Revision: https://reviews.llvm.org/D47013 llvm-svn: 332608
Diffstat (limited to 'llvm/tools/llvm-exegesis/llvm-exegesis.cpp')
-rw-r--r--llvm/tools/llvm-exegesis/llvm-exegesis.cpp47
1 files changed, 32 insertions, 15 deletions
diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
index 23453747e6d..90b2ebb18cc 100644
--- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
+++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
@@ -70,9 +70,12 @@ static llvm::cl::opt<float>
llvm::cl::desc("dbscan epsilon for analysis clustering"),
llvm::cl::init(0.1));
-static llvm::cl::opt<std::string> AnalysisClustersFile("analysis-clusters-file",
- llvm::cl::desc(""),
- llvm::cl::init("-"));
+static llvm::cl::opt<std::string>
+ AnalysisClustersOutputFile("analysis-clusters-output-file",
+ llvm::cl::desc(""), llvm::cl::init("-"));
+static llvm::cl::opt<std::string>
+ AnalysisInconsistenciesOutputFile("analysis-inconsistencies-output-file",
+ llvm::cl::desc(""), llvm::cl::init("-"));
namespace exegesis {
@@ -125,7 +128,27 @@ void benchmarkMain() {
exegesis::pfm::pfmTerminate();
}
-void analysisMain() {
+// Prints the results of running analysis pass `Pass` to file `OutputFilename`
+// if OutputFilename is non-empty.
+template <typename Pass>
+static void maybeRunAnalysis(const Analysis &Analyzer, const std::string &Name,
+ const std::string &OutputFilename) {
+ if (OutputFilename.empty())
+ return;
+ if (OutputFilename != "-") {
+ llvm::errs() << "Printing " << Name << " results to file '"
+ << OutputFilename << "'\n";
+ }
+ std::error_code ErrorCode;
+ llvm::raw_fd_ostream ClustersOS(OutputFilename, ErrorCode,
+ llvm::sys::fs::F_RW);
+ if (ErrorCode)
+ llvm::report_fatal_error("cannot open out file: " + OutputFilename);
+ if (auto Err = Analyzer.run<Pass>(ClustersOS))
+ llvm::report_fatal_error(std::move(Err));
+}
+
+static void analysisMain() {
// Read benchmarks.
const std::vector<InstructionBenchmark> Points =
InstructionBenchmark::readYamlsOrDie(BenchmarkFile);
@@ -152,17 +175,11 @@ void analysisMain() {
const Analysis Analyzer(*TheTarget, Clustering);
- std::error_code ErrorCode;
- llvm::raw_fd_ostream ClustersOS(AnalysisClustersFile, ErrorCode,
- llvm::sys::fs::F_RW);
- if (ErrorCode)
- llvm::report_fatal_error("cannot open out file: " + AnalysisClustersFile);
-
- if (auto Err = Analyzer.printClusters(ClustersOS))
- llvm::report_fatal_error(std::move(Err));
-
- if (auto Err = Analyzer.printSchedClassInconsistencies(llvm::outs()))
- llvm::report_fatal_error(std::move(Err));
+ maybeRunAnalysis<Analysis::PrintClusters>(Analyzer, "analysis clusters",
+ AnalysisClustersOutputFile);
+ maybeRunAnalysis<Analysis::PrintSchedClassInconsistencies>(
+ Analyzer, "sched class consistency analysis",
+ AnalysisInconsistenciesOutputFile);
}
} // namespace exegesis
OpenPOWER on IntegriCloud