[llvm] [MachineFunctionPass] Preserve more IR analyses (PR #178871)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 30 03:48:59 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-aarch64

Author: Nikita Popov (nikic)

<details>
<summary>Changes</summary>

Preserve, PDT, BPI, LazyBPI and LazyBFI. These are all IR analysis that are not invalidated by machine passes.

This partially mitigates the compile-time regression from https://github.com/llvm/llvm-project/pull/174746.

Compile-time: https://llvm-compile-time-tracker.com/compare.php?from=f0eba4f530ab52167a8f17efb0cc9a134757490a&to=5a4e5a6dfcc79a94e3be5d8fc6aaf72c59534f43&stat=instructions%3Au

---
Full diff: https://github.com/llvm/llvm-project/pull/178871.diff


2 Files Affected:

- (modified) llvm/lib/CodeGen/MachineFunctionPass.cpp (+8) 
- (modified) llvm/test/CodeGen/AArch64/O3-pipeline.ll (-4) 


``````````diff
diff --git a/llvm/lib/CodeGen/MachineFunctionPass.cpp b/llvm/lib/CodeGen/MachineFunctionPass.cpp
index a669877985821..d1a05b6118aea 100644
--- a/llvm/lib/CodeGen/MachineFunctionPass.cpp
+++ b/llvm/lib/CodeGen/MachineFunctionPass.cpp
@@ -12,12 +12,16 @@
 
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/Analysis/BasicAliasAnalysis.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
 #include "llvm/Analysis/DominanceFrontier.h"
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/IVUsers.h"
+#include "llvm/Analysis/LazyBranchProbabilityInfo.h"
+#include "llvm/Analysis/LazyBlockFrequencyInfo.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/MemoryDependenceAnalysis.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
+#include "llvm/Analysis/PostDominators.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
 #include "llvm/CodeGen/DroppedVariableStatsMIR.h"
@@ -193,6 +197,10 @@ void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addPreserved<BasicAAWrapperPass>();
   AU.addPreserved<DominanceFrontierWrapperPass>();
   AU.addPreserved<DominatorTreeWrapperPass>();
+  AU.addPreserved<PostDominatorTreeWrapperPass>();
+  AU.addPreserved<BranchProbabilityInfoWrapperPass>();
+  AU.addPreserved<LazyBranchProbabilityInfoPass>();
+  AU.addPreserved<LazyBlockFrequencyInfoPass>();
   AU.addPreserved<AAResultsWrapperPass>();
   AU.addPreserved<GlobalsAAWrapperPass>();
   AU.addPreserved<IVUsersWrapperPass>();
diff --git a/llvm/test/CodeGen/AArch64/O3-pipeline.ll b/llvm/test/CodeGen/AArch64/O3-pipeline.ll
index 5bf833558c596..472f1f616c600 100644
--- a/llvm/test/CodeGen/AArch64/O3-pipeline.ll
+++ b/llvm/test/CodeGen/AArch64/O3-pipeline.ll
@@ -134,11 +134,7 @@
 ; CHECK-NEXT:       Lazy Block Frequency Analysis
 ; CHECK-NEXT:       InstructionSelect
 ; CHECK-NEXT:       ResetMachineFunction
-; CHECK-NEXT:       Post-Dominator Tree Construction
-; CHECK-NEXT:       Branch Probability Analysis
 ; CHECK-NEXT:       Assignment Tracking Analysis
-; CHECK-NEXT:       Lazy Branch Probability Analysis
-; CHECK-NEXT:       Lazy Block Frequency Analysis
 ; CHECK-NEXT:       AArch64 Instruction Selection
 ; CHECK-NEXT:       MachineDominator Tree Construction
 ; CHECK-NEXT:       AArch64 Local Dynamic TLS Access Clean-up

``````````

</details>


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


More information about the llvm-commits mailing list