[llvm-branch-commits] [llvm] [X86][NewPM] Port X86FixupLEAs to NPM (PR #173744)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Dec 28 03:14:32 PST 2025


================
@@ -911,3 +915,35 @@ void FixupLEAPass::processInstrForSlow3OpLEA(MachineBasicBlock::iterator &I,
   MBB.erase(I);
   I = NewMI;
 }
+
+bool FixupLEAsLegacy::runOnMachineFunction(MachineFunction &MF) {
+  if (skipFunction(MF.getFunction()))
+    return false;
+
+  auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
+  auto *MBFI = (PSI && PSI->hasProfileSummary())
+                   ? &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI()
+                   : nullptr;
+  FixupLEAsImpl PassImpl(PSI, MBFI);
+  return PassImpl.runOnMachineFunction(MF);
+}
+
+PreservedAnalyses X86FixupLEAsPass::run(MachineFunction &MF,
+                                        MachineFunctionAnalysisManager &MFAM) {
+  ProfileSummaryInfo *PSI =
+      MFAM.getResult<ModuleAnalysisManagerMachineFunctionProxy>(MF)
+          .getCachedResult<ProfileSummaryAnalysis>(
+              *MF.getFunction().getParent());
+  if (!PSI)
+    report_fatal_error("x86-fixup-leas requires ProfileSummaryAnalysis", false);
+  MachineBlockFrequencyInfo *MBFI =
+      &MFAM.getResult<MachineBlockFrequencyAnalysis>(MF);
+
+  FixupLEAsImpl PassImpl(PSI, MBFI);
+  bool Changed = PassImpl.runOnMachineFunction(MF);
+  if (!Changed)
+    return PreservedAnalyses::all();
+  PreservedAnalyses PA = getMachineFunctionPassPreservedAnalyses();
+  PA.preserveSet<CFGAnalyses>();
+  return PA;
+}
----------------
paperchalice wrote:

End with newline.

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


More information about the llvm-branch-commits mailing list