[llvm-branch-commits] [llvm] [CodeGen][NewPM] Port MachineCSE pass to new pass manager. (PR #106605)
Christudasan Devadasan via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 29 12:04:31 PDT 2024
================
@@ -932,18 +935,55 @@ bool MachineCSE::isProfitableToHoistInto(MachineBasicBlock *CandidateBB,
MBFI->getBlockFreq(MBB) + MBFI->getBlockFreq(MBB1);
}
-bool MachineCSE::runOnMachineFunction(MachineFunction &MF) {
- if (skipFunction(MF.getFunction()))
- return false;
+void MachineCSEImpl::releaseMemory() {
+ ScopeMap.clear();
+ PREMap.clear();
+ Exps.clear();
+}
+bool MachineCSEImpl::run(MachineFunction &MF) {
TII = MF.getSubtarget().getInstrInfo();
TRI = MF.getSubtarget().getRegisterInfo();
MRI = &MF.getRegInfo();
- DT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
- MBFI = &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
LookAheadLimit = TII->getMachineCSELookAheadLimit();
bool ChangedPRE, ChangedCSE;
ChangedPRE = PerformSimplePRE(DT);
ChangedCSE = PerformCSE(DT->getRootNode());
+ releaseMemory();
return ChangedPRE || ChangedCSE;
}
+
+PreservedAnalyses MachineCSEPass::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+ MFPropsModifier _(*this, MF);
+
+ if (MF.getFunction().hasOptNone())
+ return PreservedAnalyses::all();
+
+ MachineDominatorTree &MDT = MFAM.getResult<MachineDominatorTreeAnalysis>(MF);
+ MachineBlockFrequencyInfo &MBFI =
+ MFAM.getResult<MachineBlockFrequencyAnalysis>(MF);
+ MachineCSEImpl Impl(&MDT, &MBFI);
+ bool Changed = Impl.run(MF);
+ if (!Changed)
+ return PreservedAnalyses::all();
+
+ auto PA = getMachineFunctionPassPreservedAnalyses();
+ PA.preserve<MachineLoopAnalysis>();
+ PA.preserve<MachineDominatorTreeAnalysis>();
----------------
cdevadas wrote:
I guess, we won't be able to figure it out until we have the whole pipeline running in NPM.
https://github.com/llvm/llvm-project/pull/106605
More information about the llvm-branch-commits
mailing list