[llvm] r340566 - [llvm-mca] Set the Selection strategy to Default if nullptr is passed.
Matt Davis via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 23 11:42:38 PDT 2018
Author: mattd
Date: Thu Aug 23 11:42:37 2018
New Revision: 340566
URL: http://llvm.org/viewvc/llvm-project?rev=340566&view=rev
Log:
[llvm-mca] Set the Selection strategy to Default if nullptr is passed.
* Set (not reset) the strategy in Scheduler::setCustomStrategyImpl()
Modified:
llvm/trunk/tools/llvm-mca/Scheduler.cpp
llvm/trunk/tools/llvm-mca/Scheduler.h
Modified: llvm/trunk/tools/llvm-mca/Scheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/Scheduler.cpp?rev=340566&r1=340565&r2=340566&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/Scheduler.cpp (original)
+++ llvm/trunk/tools/llvm-mca/Scheduler.cpp Thu Aug 23 11:42:37 2018
@@ -24,6 +24,11 @@ using namespace llvm;
ResourceStrategy::~ResourceStrategy() = default;
+void Scheduler::initializeStrategy(std::unique_ptr<SchedulerStrategy> S) {
+ // Ensure we have a valid (non-null) strategy object.
+ Strategy = S ? std::move(S) : llvm::make_unique<DefaultSchedulerStrategy>();
+}
+
void DefaultResourceStrategy::skipMask(uint64_t Mask) {
NextInSequenceMask &= (~Mask);
if (!NextInSequenceMask) {
@@ -116,7 +121,7 @@ void ResourceManager::setCustomStrategyI
unsigned Index = getResourceStateIndex(ResourceID);
assert(Index < Resources.size() && "Invalid processor resource index!");
assert(S && "Unexpected null strategy in input!");
- Strategies[Index].reset(S.get());
+ Strategies[Index] = std::move(S);
}
unsigned ResourceManager::resolveResourceMask(uint64_t Mask) const {
Modified: llvm/trunk/tools/llvm-mca/Scheduler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/Scheduler.h?rev=340566&r1=340565&r2=340566&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/Scheduler.h (original)
+++ llvm/trunk/tools/llvm-mca/Scheduler.h Thu Aug 23 11:42:37 2018
@@ -430,6 +430,11 @@ class Scheduler : public HardwareUnit {
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 @@ class Scheduler : public HardwareUnit {
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 {
More information about the llvm-commits
mailing list