[llvm] [AMDGPU][NewPM] Port SIOptimizeVGPRLiveRange pass to NPM. (PR #117686)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 27 10:07:32 PST 2024
================
@@ -611,35 +620,59 @@ void SIOptimizeVGPRLiveRange::optimizeWaterfallLiveRange(
}
}
-char SIOptimizeVGPRLiveRange::ID = 0;
+char SIOptimizeVGPRLiveRangeLegacy::ID = 0;
-INITIALIZE_PASS_BEGIN(SIOptimizeVGPRLiveRange, DEBUG_TYPE,
+INITIALIZE_PASS_BEGIN(SIOptimizeVGPRLiveRangeLegacy, DEBUG_TYPE,
"SI Optimize VGPR LiveRange", false, false)
INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LiveVariablesWrapperPass)
-INITIALIZE_PASS_END(SIOptimizeVGPRLiveRange, DEBUG_TYPE,
+INITIALIZE_PASS_END(SIOptimizeVGPRLiveRangeLegacy, DEBUG_TYPE,
"SI Optimize VGPR LiveRange", false, false)
-char &llvm::SIOptimizeVGPRLiveRangeID = SIOptimizeVGPRLiveRange::ID;
+char &llvm::SIOptimizeVGPRLiveRangeLegacyID = SIOptimizeVGPRLiveRangeLegacy::ID;
+
+FunctionPass *llvm::createSIOptimizeVGPRLiveRangeLegacyPass() {
+ return new SIOptimizeVGPRLiveRangeLegacy();
+}
+
+bool SIOptimizeVGPRLiveRangeLegacy::runOnMachineFunction(MachineFunction &MF) {
+ if (skipFunction(MF.getFunction()))
+ return false;
-FunctionPass *llvm::createSIOptimizeVGPRLiveRangePass() {
- return new SIOptimizeVGPRLiveRange();
+ LiveVariables *LV = &getAnalysis<LiveVariablesWrapperPass>().getLV();
+ MachineDominatorTree *MDT =
+ &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
+ MachineLoopInfo *Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI();
+ return SIOptimizeVGPRLiveRange(LV, MDT, Loops).run(MF);
}
-bool SIOptimizeVGPRLiveRange::runOnMachineFunction(MachineFunction &MF) {
+PreservedAnalyses
+SIOptimizeVGPRLiveRangePass::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+ MFPropsModifier _(*this, MF);
+ LiveVariables *LV = &MFAM.getResult<LiveVariablesAnalysis>(MF);
+ MachineDominatorTree *MDT = &MFAM.getResult<MachineDominatorTreeAnalysis>(MF);
+ MachineLoopInfo *Loops = &MFAM.getResult<MachineLoopAnalysis>(MF);
+
+ bool Changed = SIOptimizeVGPRLiveRange(LV, MDT, Loops).run(MF);
+ if (!Changed)
+ return PreservedAnalyses::all();
+
+ auto PA = getMachineFunctionPassPreservedAnalyses();
+ PA.preserve<LiveVariablesAnalysis>();
+ PA.preserve<DominatorTreeAnalysis>();
+ PA.preserve<MachineLoopAnalysis>();
+ PA.preserveSet<CFGAnalyses>();
----------------
arsenm wrote:
Should fix old pm in follow up
https://github.com/llvm/llvm-project/pull/117686
More information about the llvm-commits
mailing list