[llvm] [CodeGen][NewPM] Port `AsmPrinter` to new pass manager (PR #99320)

Akshat Oke via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 04:02:08 PDT 2025


================
@@ -440,9 +440,13 @@ void AMDGPUAsmPrinter::validateMCResourceInfo(Function &F) {
         RI.getSymbol(FnSym->getName(), RIK::RIK_NumAGPR, OutContext, IsLocal);
     uint64_t NumVgpr, NumAgpr;
 
-    MachineModuleInfo &MMI =
-        getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
-    MachineFunction *MF = MMI.getMachineFunction(F);
+    MachineFunction *MF =
+        !MAM ? MMI->getMachineFunction(F)
+             : &MAM->getResult<FunctionAnalysisManagerModuleProxy>(
+                       *F.getParent())
+                    .getManager()
+                    .getResult<MachineFunctionAnalysis>(F)
+                    .getMF();
----------------
optimisan wrote:

```suggestion
  MachineFunction *MF =
        !MAM ? MMI->getMachineFunction(F) : [&]() -> MachineFunction * {
      auto *MFA =
          MAM->getResult<FunctionAnalysisManagerModuleProxy>(*F.getParent())
              .getManager()
              .getCachedResult<MachineFunctionAnalysis>(F);
      if (MFA)
        return &MFA->getMF();
      return nullptr;
    }();
```

This needs to be `getCachedResult`, else it will return a new empty MF (since it got cleared in the Invalidate<MFA> that ran before this `AsmFinalize` pass)

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


More information about the llvm-commits mailing list