[llvm] [CodeGen][NewPM] Port machine dominator tree analysis to new pass manager (PR #95879)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 00:15:00 PDT 2024


================
@@ -57,6 +57,33 @@ template bool Verify<MBBDomTree>(const MBBDomTree &DT,
 } // namespace DomTreeBuilder
 }
 
+bool MachineDominatorTree::invalidate(
+    MachineFunction &, const PreservedAnalyses &PA,
+    MachineFunctionAnalysisManager::Invalidator &) {
+  // Check whether the analysis, all analyses on machine functions, or the
+  // machine function's CFG have been preserved.
+  auto PAC = PA.getChecker<MachineDominatorTreeAnalysis>();
+  return !(PAC.preserved() ||
+           PAC.preservedSet<AllAnalysesOn<MachineFunction>>() ||
+           PAC.preservedSet<CFGAnalyses>());
+}
+
+AnalysisKey MachineDominatorTreeAnalysis::Key;
+
+MachineDominatorTreeAnalysis::Result
+MachineDominatorTreeAnalysis::run(MachineFunction &MF,
+                                  MachineFunctionAnalysisManager &) {
+  return MachineDominatorTree(MF);
+}
+
+PreservedAnalyses
+MachineDominatorTreePrinterPass::run(MachineFunction &MF,
+                                     MachineFunctionAnalysisManager &MFAM) {
+  OS << "MachineDominatorTree for machine function: " << MF.getName() << '\n';
----------------
paperchalice wrote:

This follows `DominatorTreePrinterPass`:
https://github.com/llvm/llvm-project/blob/4b4aaf1e792367b4ce0e24966a7d21e2a83bb979/llvm/lib/IR/Dominators.cpp#L384-L385

https://github.com/llvm/llvm-project/pull/95879


More information about the llvm-commits mailing list