Skip to content

Commit

Permalink
AS, remove setAnlayses and use constructor itself
Browse files Browse the repository at this point in the history
  • Loading branch information
optimisan committed Jan 23, 2025
1 parent dfaf508 commit df4bdd8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion llvm/include/llvm/CodeGen/RegAllocGreedyPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using namespace llvm;

class RAGreedyPass : public PassInfoMixin<RAGreedyPass> {

public:
struct Options {
RegAllocFilterFunc Filter;
Expand Down
13 changes: 7 additions & 6 deletions llvm/lib/CodeGen/RegAllocGreedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ RAGreedyLegacy::RAGreedyLegacy(const RegAllocFilterFunc F)
initializeRAGreedyLegacyPass(*PassRegistry::getPassRegistry());
}

RAGreedy::RAGreedy(const RegAllocFilterFunc F) : RegAllocBase(F) {}
RAGreedy::RAGreedy(RequiredAnalyses &Analyses, const RegAllocFilterFunc F) : RegAllocBase(F) {
setAnalyses(Analyses);
}

void RAGreedy::setAnalyses(RequiredAnalyses &Analyses) {
VRM = Analyses.VRM;
Expand All @@ -204,14 +206,13 @@ void RAGreedy::setAnalyses(RequiredAnalyses &Analyses) {

void RAGreedyPass::printPipeline(raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) const {
StringRef FilterName = Opts.FilterName.empty() ? "all" : Opts.FilterName;
OS << "regallocgreedy<" << FilterName << ">";
OS << "regallocgreedy<" << FilterName << '>';
}

PreservedAnalyses RAGreedyPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
MFPropsModifier _(*this, MF);

RAGreedy Impl(Opts.Filter);
RAGreedy::RequiredAnalyses Analyses;

Analyses.LIS = &MFAM.getResult<LiveIntervalsAnalysis>(MF);
Expand All @@ -231,7 +232,8 @@ PreservedAnalyses RAGreedyPass::run(MachineFunction &MF,
MFAM.getResult<RegAllocPriorityAdvisorAnalysis>(MF).Provider;
Analyses.VRM = &MFAM.getResult<VirtRegMapAnalysis>(MF);

Impl.setAnalyses(Analyses);
RAGreedy Impl(Analyses, Opts.Filter);

bool Changed = Impl.run(MF);
if (!Changed)
return PreservedAnalyses::all();
Expand All @@ -248,7 +250,6 @@ PreservedAnalyses RAGreedyPass::run(MachineFunction &MF,
}

bool RAGreedyLegacy::runOnMachineFunction(MachineFunction &MF) {
RAGreedy Impl(F);

RAGreedy::RequiredAnalyses Analyses;
Analyses.VRM = &getAnalysis<VirtRegMapWrapperLegacy>().getVRM();
Expand All @@ -271,7 +272,7 @@ bool RAGreedyLegacy::runOnMachineFunction(MachineFunction &MF) {
Analyses.PriorityProvider =
&getAnalysis<RegAllocPriorityAdvisorAnalysisLegacy>().getProvider();

Impl.setAnalyses(Analyses);
RAGreedy Impl(Analyses, F);
return Impl.run(MF);
}

Expand Down
7 changes: 2 additions & 5 deletions llvm/lib/CodeGen/RegAllocGreedy.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,9 @@ class LLVM_LIBRARY_VISIBILITY RAGreedy : public RegAllocBase,

bool ReverseLocalAssignment = false;

public:
RAGreedy(const RegAllocFilterFunc F = nullptr);
// Evict and priority advisors use this object, so we can construct those
// first and pass them here.
// Not required once legacy PM is removed.
void setAnalyses(RequiredAnalyses &Analyses);
public:
RAGreedy(RequiredAnalyses &Analyses, const RegAllocFilterFunc F = nullptr);

Spiller &spiller() override { return *SpillerInstance; }
void enqueueImpl(const LiveInterval *LI) override;
Expand Down

0 comments on commit df4bdd8

Please sign in to comment.