From bc3b372161716a4c4845d47a877e4892df0d08da Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Mon, 31 Jan 2022 13:42:47 -0800 Subject: [PATCH] [nfc][mlgo] De-const a parameter We plan to pass the MachineFunction& to APIs that expect it non-const (for legitimate reasons). The advisor still holds the ref as a const ref, though, so we keep most of the maintainability value of that. --- llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp | 12 ++++++------ llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 4 ++-- llvm/lib/CodeGen/RegAllocEvictionAdvisor.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp index 14781ebd424b..061066b64a2d 100644 --- a/llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp +++ b/llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp @@ -227,8 +227,8 @@ using FeaturesListNormalizer = std::array; /// The ML evictor (commonalities between release and development mode) class MLEvictAdvisor : public RegAllocEvictionAdvisor { public: - MLEvictAdvisor(const MachineFunction &MF, const RAGreedy &RA, - MLModelRunner *Runner, const MachineBlockFrequencyInfo &MBFI, + MLEvictAdvisor(MachineFunction &MF, const RAGreedy &RA, MLModelRunner *Runner, + const MachineBlockFrequencyInfo &MBFI, const MachineLoopInfo &Loops); protected: @@ -319,7 +319,7 @@ private: } std::unique_ptr - getAdvisor(const MachineFunction &MF, const RAGreedy &RA) override { + getAdvisor(MachineFunction &MF, const RAGreedy &RA) override { if (!Runner) Runner = std::make_unique>( MF.getFunction().getContext(), FeatureNames, DecisionName); @@ -364,7 +364,7 @@ static const std::vector TrainingInputFeatures{ class DevelopmentModeEvictAdvisor : public MLEvictAdvisor { public: - DevelopmentModeEvictAdvisor(const MachineFunction &MF, const RAGreedy &RA, + DevelopmentModeEvictAdvisor(MachineFunction &MF, const RAGreedy &RA, MLModelRunner *Runner, const MachineBlockFrequencyInfo &MBFI, const MachineLoopInfo &Loops, Logger *Log) @@ -420,7 +420,7 @@ private: } std::unique_ptr - getAdvisor(const MachineFunction &MF, const RAGreedy &RA) override { + getAdvisor(MachineFunction &MF, const RAGreedy &RA) override { LLVMContext &Ctx = MF.getFunction().getContext(); if (ModelUnderTraining.empty() && TrainingLog.empty()) { Ctx.emitError("Regalloc development mode should be requested with at " @@ -480,7 +480,7 @@ float MLEvictAdvisor::getInitialQueueSize(const MachineFunction &MF) { return Ret; } -MLEvictAdvisor::MLEvictAdvisor(const MachineFunction &MF, const RAGreedy &RA, +MLEvictAdvisor::MLEvictAdvisor(MachineFunction &MF, const RAGreedy &RA, MLModelRunner *Runner, const MachineBlockFrequencyInfo &MBFI, const MachineLoopInfo &Loops) diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp index 995079f909ec..24b33060d159 100644 --- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp +++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp @@ -66,7 +66,7 @@ public: private: std::unique_ptr - getAdvisor(const MachineFunction &MF, const RAGreedy &RA) override { + getAdvisor(MachineFunction &MF, const RAGreedy &RA) override { return std::make_unique(MF, RA); } bool doInitialization(Module &M) override { @@ -113,7 +113,7 @@ StringRef RegAllocEvictionAdvisorAnalysis::getPassName() const { llvm_unreachable("Unknown advisor kind"); } -RegAllocEvictionAdvisor::RegAllocEvictionAdvisor(const MachineFunction &MF, +RegAllocEvictionAdvisor::RegAllocEvictionAdvisor(MachineFunction &MF, const RAGreedy &RA) : MF(MF), RA(RA), Matrix(RA.getInterferenceMatrix()), LIS(RA.getLiveIntervals()), VRM(RA.getVirtRegMap()), diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.h b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.h index 33e03aed81a7..1f40386db8da 100644 --- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.h +++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.h @@ -115,7 +115,7 @@ public: bool isUnusedCalleeSavedReg(MCRegister PhysReg) const; protected: - RegAllocEvictionAdvisor(const MachineFunction &MF, const RAGreedy &RA); + RegAllocEvictionAdvisor(MachineFunction &MF, const RAGreedy &RA); Register canReassign(LiveInterval &VirtReg, Register PrevReg) const; @@ -173,7 +173,7 @@ public: /// Get an advisor for the given context (i.e. machine function, etc) virtual std::unique_ptr - getAdvisor(const MachineFunction &MF, const RAGreedy &RA) = 0; + getAdvisor(MachineFunction &MF, const RAGreedy &RA) = 0; AdvisorMode getAdvisorMode() const { return Mode; } protected: @@ -200,7 +200,7 @@ RegAllocEvictionAdvisorAnalysis *createDevelopmentModeAdvisor(); // out of RegAllocGreedy.cpp class DefaultEvictionAdvisor : public RegAllocEvictionAdvisor { public: - DefaultEvictionAdvisor(const MachineFunction &MF, const RAGreedy &RA) + DefaultEvictionAdvisor(MachineFunction &MF, const RAGreedy &RA) : RegAllocEvictionAdvisor(MF, RA) {} private: