aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineTraceMetrics.cpp
diff options
context:
space:
mode:
authorAnton Sidorenko <anton.sidorenko@syntacore.com>2023-02-14 13:30:44 +0300
committerAnton Sidorenko <anton.sidorenko@syntacore.com>2023-02-15 15:53:14 +0300
commit980aa8d740dac77dfe722b04892457b731d1c58b (patch)
tree6d7a717b09afe5696968f6cb741f264acfd2464c /llvm/lib/CodeGen/MachineTraceMetrics.cpp
parentb0e7ca79ab0cd22a6dbac853ace1e8f0a00b0a94 (diff)
downloadllvm-980aa8d740dac77dfe722b04892457b731d1c58b.zip
llvm-980aa8d740dac77dfe722b04892457b731d1c58b.tar.gz
llvm-980aa8d740dac77dfe722b04892457b731d1c58b.tar.bz2
[MachineTraceMetrics] Add local strategy
This strategy makes each trace local to the basic block. For in-order cores some heuristics work better when we do local decisions. For example, MachineCombiner may expect that instructions outside the current basic block do not lengthen the critical path when we execute instructions in order or the core has a small re-order buffer. This patch only introduce the strategy, real use-case is added in the further pathes. Depends on D140539 Reviewed By: spatel Differential Revision: https://reviews.llvm.org/D140540
Diffstat (limited to 'llvm/lib/CodeGen/MachineTraceMetrics.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineTraceMetrics.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineTraceMetrics.cpp b/llvm/lib/CodeGen/MachineTraceMetrics.cpp
index a3ea657..62a114df 100644
--- a/llvm/lib/CodeGen/MachineTraceMetrics.cpp
+++ b/llvm/lib/CodeGen/MachineTraceMetrics.cpp
@@ -318,6 +318,21 @@ public:
: MachineTraceMetrics::Ensemble(mtm) {}
};
+/// Pick only the current basic block for the trace and do not choose any
+/// predecessors/successors.
+class LocalEnsemble : public MachineTraceMetrics::Ensemble {
+ const char *getName() const override { return "Local"; }
+ const MachineBasicBlock *pickTracePred(const MachineBasicBlock *) override {
+ return nullptr;
+ };
+ const MachineBasicBlock *pickTraceSucc(const MachineBasicBlock *) override {
+ return nullptr;
+ };
+
+public:
+ LocalEnsemble(MachineTraceMetrics *MTM)
+ : MachineTraceMetrics::Ensemble(MTM) {}
+};
} // end anonymous namespace
// Select the preferred predecessor for MBB.
@@ -391,6 +406,8 @@ MachineTraceMetrics::getEnsemble(MachineTraceStrategy strategy) {
switch (strategy) {
case MachineTraceStrategy::TS_MinInstrCount:
return (E = new MinInstrCountEnsemble(this));
+ case MachineTraceStrategy::TS_Local:
+ return (E = new LocalEnsemble(this));
default: llvm_unreachable("Invalid trace strategy enum");
}
}