diff options
author | Clement Courbet <courbet@google.com> | 2021-04-19 09:08:44 +0200 |
---|---|---|
committer | Clement Courbet <courbet@google.com> | 2021-04-19 10:44:28 +0200 |
commit | 9e9f991ac0330bee8cf6e9c73fe8a7c976d7afce (patch) | |
tree | 055c20f5921de7a7cbce38ab1b81e4ffe69a72c4 | |
parent | 782b9858882dde5f63463ea89b88983e920ecccc (diff) | |
download | llvm-9e9f991ac0330bee8cf6e9c73fe8a7c976d7afce.zip llvm-9e9f991ac0330bee8cf6e9c73fe8a7c976d7afce.tar.gz llvm-9e9f991ac0330bee8cf6e9c73fe8a7c976d7afce.tar.bz2 |
[llvm-exegesis] Honor -mcpu in analysis mode.
This is useful to set the baseline model for an unknown CPU.
Fixes PR50013.
Differential Revision: https://reviews.llvm.org/D100743
-rw-r--r-- | llvm/tools/llvm-exegesis/lib/Analysis.cpp | 9 | ||||
-rw-r--r-- | llvm/tools/llvm-exegesis/lib/Analysis.h | 3 | ||||
-rw-r--r-- | llvm/tools/llvm-exegesis/llvm-exegesis.cpp | 2 |
3 files changed, 9 insertions, 5 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp index ac21de1..a1f576d 100644 --- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp +++ b/llvm/tools/llvm-exegesis/lib/Analysis.cpp @@ -154,7 +154,8 @@ void Analysis::printInstructionRowCsv(const size_t PointId, Analysis::Analysis(const Target &Target, std::unique_ptr<MCInstrInfo> InstrInfo, const InstructionBenchmarkClustering &Clustering, double AnalysisInconsistencyEpsilon, - bool AnalysisDisplayUnstableOpcodes) + bool AnalysisDisplayUnstableOpcodes, + const std::string &ForceCpuName) : Clustering_(Clustering), InstrInfo_(std::move(InstrInfo)), AnalysisInconsistencyEpsilonSquared_(AnalysisInconsistencyEpsilon * AnalysisInconsistencyEpsilon), @@ -163,12 +164,14 @@ Analysis::Analysis(const Target &Target, std::unique_ptr<MCInstrInfo> InstrInfo, return; const InstructionBenchmark &FirstPoint = Clustering.getPoints().front(); + const std::string CpuName = + ForceCpuName.empty() ? FirstPoint.CpuName : ForceCpuName; RegInfo_.reset(Target.createMCRegInfo(FirstPoint.LLVMTriple)); MCTargetOptions MCOptions; AsmInfo_.reset( Target.createMCAsmInfo(*RegInfo_, FirstPoint.LLVMTriple, MCOptions)); - SubtargetInfo_.reset(Target.createMCSubtargetInfo(FirstPoint.LLVMTriple, - FirstPoint.CpuName, "")); + SubtargetInfo_.reset( + Target.createMCSubtargetInfo(FirstPoint.LLVMTriple, CpuName, "")); InstPrinter_.reset(Target.createMCInstPrinter( Triple(FirstPoint.LLVMTriple), 0 /*default variant*/, *AsmInfo_, *InstrInfo_, *RegInfo_)); diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.h b/llvm/tools/llvm-exegesis/lib/Analysis.h index 4c1c864..0f8209c 100644 --- a/llvm/tools/llvm-exegesis/lib/Analysis.h +++ b/llvm/tools/llvm-exegesis/lib/Analysis.h @@ -39,7 +39,8 @@ public: Analysis(const Target &Target, std::unique_ptr<MCInstrInfo> InstrInfo, const InstructionBenchmarkClustering &Clustering, double AnalysisInconsistencyEpsilon, - bool AnalysisDisplayUnstableOpcodes); + bool AnalysisDisplayUnstableOpcodes, + const std::string &ForceCpuName = ""); // Prints a csv of instructions for each cluster. struct PrintClusters {}; diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp index 9cbcc1b..b26d3b6 100644 --- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp +++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp @@ -436,7 +436,7 @@ static void analysisMain() { const Analysis Analyzer(*TheTarget, std::move(InstrInfo), Clustering, AnalysisInconsistencyEpsilon, - AnalysisDisplayUnstableOpcodes); + AnalysisDisplayUnstableOpcodes, CpuName); maybeRunAnalysis<Analysis::PrintClusters>(Analyzer, "analysis clusters", AnalysisClustersOutputFile); |