[llvm] 9e9f991 - [llvm-exegesis] Honor -mcpu in analysis mode.
Clement Courbet via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 19 01:44:42 PDT 2021
Author: Clement Courbet
Date: 2021-04-19T10:44:28+02:00
New Revision: 9e9f991ac0330bee8cf6e9c73fe8a7c976d7afce
URL: https://github.com/llvm/llvm-project/commit/9e9f991ac0330bee8cf6e9c73fe8a7c976d7afce
DIFF: https://github.com/llvm/llvm-project/commit/9e9f991ac0330bee8cf6e9c73fe8a7c976d7afce.diff
LOG: [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
Added:
Modified:
llvm/tools/llvm-exegesis/lib/Analysis.cpp
llvm/tools/llvm-exegesis/lib/Analysis.h
llvm/tools/llvm-exegesis/llvm-exegesis.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp
index ac21de1b9652..a1f576db4500 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 4c1c864e6e73..0f8209c6e2f3 100644
--- a/llvm/tools/llvm-exegesis/lib/Analysis.h
+++ b/llvm/tools/llvm-exegesis/lib/Analysis.h
@@ -39,7 +39,8 @@ class Analysis {
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 9cbcc1b0b6e2..b26d3b60aabf 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);
More information about the llvm-commits
mailing list