[llvm-mca] Set the Selection strategy to Default if nullptr is passed.
* Set (not reset) the strategy in Scheduler::setCustomStrategyImpl()
llvm-svn: 340566
diff --git a/llvm/tools/llvm-mca/Scheduler.h b/llvm/tools/llvm-mca/Scheduler.h
index 37ebdb4..ed138fd 100644
--- a/llvm/tools/llvm-mca/Scheduler.h
+++ b/llvm/tools/llvm-mca/Scheduler.h
@@ -430,6 +430,11 @@
std::vector<InstRef> ReadySet;
std::vector<InstRef> IssuedSet;
+ /// Verify the given selection strategy and set the Strategy member
+ /// accordingly. If no strategy is provided, the DefaultSchedulerStrategy is
+ /// used.
+ void initializeStrategy(std::unique_ptr<SchedulerStrategy> S);
+
/// Issue an instruction without updating the ready queue.
void issueInstructionImpl(
InstRef &IR,
@@ -446,16 +451,19 @@
public:
Scheduler(const llvm::MCSchedModel &Model, LSUnit *Lsu)
- : LSU(Lsu), Strategy(llvm::make_unique<DefaultSchedulerStrategy>()),
- Resources(llvm::make_unique<ResourceManager>(Model)) {}
+ : LSU(Lsu), Resources(llvm::make_unique<ResourceManager>(Model)) {
+ initializeStrategy(nullptr);
+ }
Scheduler(const llvm::MCSchedModel &Model, LSUnit *Lsu,
std::unique_ptr<SchedulerStrategy> SelectStrategy)
- : LSU(Lsu), Strategy(std::move(SelectStrategy)),
- Resources(llvm::make_unique<ResourceManager>(Model)) {}
+ : LSU(Lsu), Resources(llvm::make_unique<ResourceManager>(Model)) {
+ initializeStrategy(std::move(SelectStrategy));
+ }
Scheduler(std::unique_ptr<ResourceManager> RM, LSUnit *Lsu,
std::unique_ptr<SchedulerStrategy> SelectStrategy)
- : LSU(Lsu), Strategy(std::move(SelectStrategy)),
- Resources(std::move(RM)) {}
+ : LSU(Lsu), Resources(std::move(RM)) {
+ initializeStrategy(std::move(SelectStrategy));
+ }
// Stalls generated by the scheduler.
enum Status {