[llvm] [tools] Register analyses correctly (PR #203808)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 14 18:01:35 PDT 2026


https://github.com/paperchalice created https://github.com/llvm/llvm-project/pull/203808

-  Analyses with custom parameter must be registered before register*Analyses, otherwise it will be skipped.
- Remove redundant LibcallLoweringModuleAnalysis, pass builder will register it automatically.

>From ceb40f9d47f4763cf452dbde9067b811bb5e5772 Mon Sep 17 00:00:00 2001
From: PaperChalice <liujunchang97 at outlook.com>
Date: Mon, 15 Jun 2026 09:00:44 +0800
Subject: [PATCH] [tools] Register analyses correctly -  Analyses with custom
 parameter must be registered before register*Analyses, otherwise it will be
 skipped. - Remove redundant LibcallLoweringModuleAnalysis, pass builder will
 register it automatically.

---
 llvm/tools/llc/NewPMDriver.cpp | 18 +++++++++---------
 llvm/tools/opt/NewPMDriver.cpp |  2 --
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/llvm/tools/llc/NewPMDriver.cpp b/llvm/tools/llc/NewPMDriver.cpp
index b50fb3ada22cb..97a7a8a2a6ba8 100644
--- a/llvm/tools/llc/NewPMDriver.cpp
+++ b/llvm/tools/llc/NewPMDriver.cpp
@@ -128,14 +128,6 @@ int llvm::compileModuleWithNewPM(
   FunctionAnalysisManager FAM;
   CGSCCAnalysisManager CGAM;
   ModuleAnalysisManager MAM;
-  PassBuilder PB(Target.get(), PipelineTuningOptions(), std::nullopt, &PIC);
-  PB.registerModuleAnalyses(MAM);
-  PB.registerCGSCCAnalyses(CGAM);
-  PB.registerFunctionAnalyses(FAM);
-  PB.registerLoopAnalyses(LAM);
-  PB.registerMachineFunctionAnalyses(MFAM);
-  PB.crossRegisterProxies(LAM, FAM, CGAM, MAM, &MFAM);
-  SI.registerCallbacks(PIC, &MAM);
 
   FAM.registerPass([&] { return TargetLibraryAnalysis(TLII); });
 
@@ -146,10 +138,18 @@ int llvm::compileModuleWithNewPM(
         Target->Options.FloatABIType, Target->Options.EABIVersion,
         Options.MCOptions.ABIName, Target->Options.VecLib);
   });
-  MAM.registerPass([&] { return LibcallLoweringModuleAnalysis(); });
 
   MAM.registerPass([&] { return MachineModuleAnalysis(MMI); });
 
+  PassBuilder PB(Target.get(), PipelineTuningOptions(), std::nullopt, &PIC);
+  PB.registerModuleAnalyses(MAM);
+  PB.registerCGSCCAnalyses(CGAM);
+  PB.registerFunctionAnalyses(FAM);
+  PB.registerLoopAnalyses(LAM);
+  PB.registerMachineFunctionAnalyses(MFAM);
+  PB.crossRegisterProxies(LAM, FAM, CGAM, MAM, &MFAM);
+  SI.registerCallbacks(PIC, &MAM);
+
   ModulePassManager MPM;
   FunctionPassManager FPM;
 
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index f5007bb7c3571..9431e16600118 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -426,8 +426,6 @@ bool llvm::runPassPipeline(
                                     Options.FloatABIType, Options.EABIVersion,
                                     Options.MCOptions.ABIName, Options.VecLib);
     });
-
-    MAM.registerPass([&] { return LibcallLoweringModuleAnalysis(); });
   }
 
   PassInstrumentationCallbacks PIC;



More information about the llvm-commits mailing list