[llvm-branch-commits] [llvm] [CodeGen][NewPM] Port RegisterCoalescer to NPM (PR #124698)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jan 27 23:18:06 PST 2025
================
@@ -4241,7 +4259,33 @@ void RegisterCoalescer::releaseMemory() {
LargeLIVisitCounter.clear();
}
-bool RegisterCoalescer::runOnMachineFunction(MachineFunction &fn) {
+PreservedAnalyses
+RegisterCoalescerPass::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+ auto &LIS = MFAM.getResult<LiveIntervalsAnalysis>(MF);
+ auto &Loops = MFAM.getResult<MachineLoopAnalysis>(MF);
+ auto *SI = MFAM.getCachedResult<SlotIndexesAnalysis>(MF);
+ RegisterCoalescer Impl(&LIS, SI, &Loops);
+ if (!Impl.run(MF))
+ return PreservedAnalyses::all();
+ auto PA = getMachineFunctionPassPreservedAnalyses();
+ PA.preserve<LiveIntervalsAnalysis>();
+ PA.preserve<SlotIndexesAnalysis>();
+ PA.preserve<MachineLoopAnalysis>();
+ PA.preserve<MachineDominatorTreeAnalysis>();
+ return PA;
+}
+
+bool RegisterCoalescerLegacy::runOnMachineFunction(MachineFunction &MF) {
+ auto *LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS();
+ auto *Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI();
+ auto *SIWrapper = getAnalysisIfAvailable<SlotIndexesWrapperPass>();
+ SlotIndexes *SI = SIWrapper ? &SIWrapper->getSI() : nullptr;
+ Impl.reset(new RegisterCoalescer(LIS, SI, Loops));
----------------
arsenm wrote:
Don't see why this needs heap allocation
https://github.com/llvm/llvm-project/pull/124698
More information about the llvm-branch-commits
mailing list