diff --git a/llvm/include/llvm/CodeGen/RegAllocPriorityAdvisor.h b/llvm/include/llvm/CodeGen/RegAllocPriorityAdvisor.h index 3aba88fb802583..c9ab4a4ee8399f 100644 --- a/llvm/include/llvm/CodeGen/RegAllocPriorityAdvisor.h +++ b/llvm/include/llvm/CodeGen/RegAllocPriorityAdvisor.h @@ -73,18 +73,15 @@ class RegAllocPriorityAdvisorProvider { virtual ~RegAllocPriorityAdvisorProvider() = default; virtual void logRewardIfNeeded(const MachineFunction &MF, - llvm::function_ref GetReward) {}; + function_ref GetReward) {}; virtual std::unique_ptr - getAdvisor(const MachineFunction &MF, const RAGreedy &RA) = 0; - - void setAnalyses(SlotIndexes *SI) { this->SI = SI; } + getAdvisor(const MachineFunction &MF, const RAGreedy &RA, + SlotIndexes *SI) = 0; AdvisorMode getAdvisorMode() const { return Mode; } protected: - SlotIndexes *SI; - private: const AdvisorMode Mode; }; @@ -125,7 +122,9 @@ class RegAllocPriorityAdvisorAnalysisLegacy : public ImmutablePass { static char ID; /// Get an advisor for the given context (i.e. machine function, etc) - virtual std::unique_ptr &getProvider() = 0; + std::unique_ptr &getProvider() { + return Provider; + } AdvisorMode getAdvisorMode() const { return Mode; } virtual void logRewardIfNeeded(const MachineFunction &MF, llvm::function_ref GetReward) {}; diff --git a/llvm/lib/CodeGen/MLRegAllocPriorityAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocPriorityAdvisor.cpp index dedd20b31d1c02..8b195b36a711fa 100644 --- a/llvm/lib/CodeGen/MLRegAllocPriorityAdvisor.cpp +++ b/llvm/lib/CodeGen/MLRegAllocPriorityAdvisor.cpp @@ -127,7 +127,8 @@ class ReleaseModePriorityAdvisorProvider final ReleaseModePriorityAdvisorProvider() : RegAllocPriorityAdvisorProvider(AdvisorMode::Release) {} std::unique_ptr - getAdvisor(const MachineFunction &MF, const RAGreedy &RA) override { + getAdvisor(const MachineFunction &MF, const RAGreedy &RA, + SlotIndexes *SI) override { if (!Runner) { if (InteractiveChannelBaseName.empty()) Runner = std::make_unique>( @@ -163,11 +164,6 @@ class ReleaseModePriorityAdvisorAnalysisLegacy final RegAllocPriorityAdvisorAnalysisLegacy::getAnalysisUsage(AU); } - std::unique_ptr &getProvider() override { - Provider->setAnalyses(&getAnalysis().getSI()); - return Provider; - } - bool doInitialization(Module &M) override { Provider = std::make_unique(); return false; @@ -262,7 +258,8 @@ class DevelopmentModePriorityAdvisorProvider final } std::unique_ptr - getAdvisor(const MachineFunction &MF, const RAGreedy &RA) override { + getAdvisor(const MachineFunction &MF, const RAGreedy &RA, + SlotIndexes *SI) override { if (!Runner) return nullptr; if (Log) { @@ -307,11 +304,6 @@ class DevelopmentModePriorityAdvisorAnalysisLegacy final return false; ; } - - std::unique_ptr &getProvider() override { - Provider->setAnalyses(&getAnalysis().getSI()); - return Provider; - } }; #endif //#ifdef LLVM_HAVE_TFLITE diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index cd264695287f48..466c3f69c6acda 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -2754,7 +2754,7 @@ bool RAGreedy::runOnMachineFunction(MachineFunction &mf) { PriorityAdvisor = getAnalysis() .getProvider() - ->getAdvisor(*MF, *this); + ->getAdvisor(*MF, *this, Indexes); VRAI = std::make_unique(*MF, *LIS, *VRM, *Loops, *MBFI); SpillerInstance.reset(createInlineSpiller(*this, *MF, *VRM, *VRAI)); diff --git a/llvm/lib/CodeGen/RegAllocPriorityAdvisor.cpp b/llvm/lib/CodeGen/RegAllocPriorityAdvisor.cpp index 407b8f8a283ca1..05444189c12f8d 100644 --- a/llvm/lib/CodeGen/RegAllocPriorityAdvisor.cpp +++ b/llvm/lib/CodeGen/RegAllocPriorityAdvisor.cpp @@ -54,7 +54,8 @@ class DefaultPriorityAdvisorProvider final } std::unique_ptr - getAdvisor(const MachineFunction &MF, const RAGreedy &RA) override { + getAdvisor(const MachineFunction &MF, const RAGreedy &RA, + SlotIndexes *SI) override { assert(SI && "SlotIndexes result must be set"); return std::make_unique(MF, RA, SI); } @@ -78,11 +79,6 @@ class DefaultPriorityAdvisorAnalysisLegacy final RegAllocPriorityAdvisorAnalysisLegacy::getAnalysisUsage(AU); } - std::unique_ptr &getProvider() override { - Provider->setAnalyses(&getAnalysis().getSI()); - return Provider; - } - bool doInitialization(Module &M) override { Provider.reset( new DefaultPriorityAdvisorProvider(NotAsRequested, M.getContext())); @@ -90,7 +86,6 @@ class DefaultPriorityAdvisorAnalysisLegacy final } const bool NotAsRequested; - // std::unique_ptr Provider; }; } // namespace @@ -114,8 +109,6 @@ RegAllocPriorityAdvisorAnalysis::run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM) { // Lazily initialize the provider. initializeProvider(MF.getFunction().getContext()); - // On each run, update the analysis for the provider. - Provider->setAnalyses(&MFAM.getResult(MF)); // The requiring analysis will construct the advisor. return Result{Provider.get()}; }