[llvm] [CodeGen][NPM] Update dominator tree and post dominator tree consistently (PR #173485)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 5 05:42:50 PST 2026


================
@@ -135,12 +137,20 @@ PreservedAnalyses BranchFolderPass::run(MachineFunction &MF,
         "ProfileSummaryAnalysis is required for BranchFoldingPass", false);
 
   auto &MBFI = MFAM.getResult<MachineBlockFrequencyAnalysis>(MF);
+  auto *MDT = MFAM.getCachedResult<MachineDominatorTreeAnalysis>(MF);
+  auto *MPDT = MFAM.getCachedResult<MachinePostDominatorTreeAnalysis>(MF);
   MBFIWrapper MBBFreqInfo(MBFI);
   BranchFolder Folder(EnableTailMerge, /*CommonHoist=*/true, MBBFreqInfo, MBPI,
                       PSI);
   if (!Folder.OptimizeFunction(MF, MF.getSubtarget().getInstrInfo(),
----------------
jayfoad wrote:

Nit: invert this condition to handle the simpler `return getMachineFunctionPassPreservedAnalyses()` case first?

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


More information about the llvm-commits mailing list