Skip to content

Commit

Permalink
[nfc][mlgo] De-const a parameter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mtrofin committed Jan 31, 2022
1 parent 52a1346 commit bc3b372
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp
Expand Up @@ -227,8 +227,8 @@ using FeaturesListNormalizer = std::array<float, FeatureIDs::FeatureCount>;
/// 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:
Expand Down Expand Up @@ -319,7 +319,7 @@ class ReleaseModeEvictionAdvisorAnalysis final
}

std::unique_ptr<RegAllocEvictionAdvisor>
getAdvisor(const MachineFunction &MF, const RAGreedy &RA) override {
getAdvisor(MachineFunction &MF, const RAGreedy &RA) override {
if (!Runner)
Runner = std::make_unique<ReleaseModeModelRunner<RegallocEvictModel>>(
MF.getFunction().getContext(), FeatureNames, DecisionName);
Expand Down Expand Up @@ -364,7 +364,7 @@ static const std::vector<TensorSpec> 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)
Expand Down Expand Up @@ -420,7 +420,7 @@ class DevelopmentModeEvictionAdvisorAnalysis final
}

std::unique_ptr<RegAllocEvictionAdvisor>
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 "
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
Expand Up @@ -66,7 +66,7 @@ class DefaultEvictionAdvisorAnalysis final

private:
std::unique_ptr<RegAllocEvictionAdvisor>
getAdvisor(const MachineFunction &MF, const RAGreedy &RA) override {
getAdvisor(MachineFunction &MF, const RAGreedy &RA) override {
return std::make_unique<DefaultEvictionAdvisor>(MF, RA);
}
bool doInitialization(Module &M) override {
Expand Down Expand Up @@ -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()),
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/RegAllocEvictionAdvisor.h
Expand Up @@ -115,7 +115,7 @@ class RegAllocEvictionAdvisor {
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;

Expand Down Expand Up @@ -173,7 +173,7 @@ class RegAllocEvictionAdvisorAnalysis : public ImmutablePass {

/// Get an advisor for the given context (i.e. machine function, etc)
virtual std::unique_ptr<RegAllocEvictionAdvisor>
getAdvisor(const MachineFunction &MF, const RAGreedy &RA) = 0;
getAdvisor(MachineFunction &MF, const RAGreedy &RA) = 0;
AdvisorMode getAdvisorMode() const { return Mode; }

protected:
Expand All @@ -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:
Expand Down

0 comments on commit bc3b372

Please sign in to comment.