[llvm] [NPM] Port ImmutableModuleSummaryAnalysis to NPM (PR #203510)

Vikram Hegde via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 6 01:22:00 PDT 2026


https://github.com/vikramRH updated https://github.com/llvm/llvm-project/pull/203510

>From deba4c08339fe182eb0690d1a5082f0b7aad3c35 Mon Sep 17 00:00:00 2001
From: vikhegde <vikram.hegde at amd.com>
Date: Thu, 4 Jun 2026 11:24:30 +0530
Subject: [PATCH 1/4] [AMDGPU][NPM] Complete AsmPrinter support for AMDGPU

---
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp   | 48 +++++++++++++++++--
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h     | 22 +++++++++
 .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 16 +++++--
 llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll  | 11 ++++-
 4 files changed, 89 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index 53d45d97ab527..984b96af01354 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -116,6 +116,13 @@ AMDGPUAsmPrinter::AMDGPUAsmPrinter(TargetMachine &TM,
                                    std::unique_ptr<MCStreamer> Streamer)
     : AsmPrinter(TM, std::move(Streamer)) {
   assert(OutStreamer && "AsmPrinter constructed without streamer");
+  GetResourceUsage = [this](MachineFunction &MF)
+      -> const AMDGPUResourceUsageAnalysisImpl::SIFunctionResourceInfo * {
+    if (auto *ResourceUsageW =
+            getAnalysisIfAvailable<AMDGPUResourceUsageAnalysisWrapperPass>())
+      return &ResourceUsageW->getResourceInfo();
+    return nullptr;
+  };
 }
 
 StringRef AMDGPUAsmPrinter::getPassName() const {
@@ -544,8 +551,7 @@ void AMDGPUAsmPrinter::validateMCResourceInfo(Function &F) {
         RI.getSymbol(FnSym->getName(), RIK::RIK_NumAGPR, OutContext);
     uint64_t NumVgpr, NumAgpr;
 
-    MachineModuleInfo &MMI =
-        getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
+    MachineModuleInfo &MMI = *GetMMI();
     MachineFunction *MF = MMI.getMachineFunction(F);
     if (MF && NumVgprSymbol->isVariable() && NumAgprSymbol->isVariable() &&
         TryGetMCExprValue(NumVgprSymbol->getVariableValue(), NumVgpr) &&
@@ -893,8 +899,7 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   if (!IsTargetStreamerInitialized)
     initTargetStreamer(*MF.getFunction().getParent());
 
-  ResourceUsage =
-      &getAnalysis<AMDGPUResourceUsageAnalysisWrapperPass>().getResourceInfo();
+  ResourceUsage = GetResourceUsage(MF);
   CurrentProgramInfo.reset(MF);
 
   const AMDGPUMachineFunctionInfo *MFI =
@@ -2008,6 +2013,41 @@ void AMDGPUAsmPrinter::emitResourceUsageRemarks(
                             CurrentProgramInfo.LDSSize);
 }
 
+PreservedAnalyses AMDGPUAsmPrinterBeginPass::run(Module &M,
+                                                 ModuleAnalysisManager &MAM) {
+
+  AMDGPUAsmPrinter &AsmPrinter = static_cast<AMDGPUAsmPrinter &>(
+      MAM.getResult<AsmPrinterAnalysis>(M).getPrinter());
+  setupModuleAsmPrinter(M, MAM, AsmPrinter);
+  AsmPrinter.doInitialization(M);
+  return PreservedAnalyses::all();
+}
+
+PreservedAnalyses
+AMDGPUAsmPrinterPass::run(MachineFunction &MF,
+                          MachineFunctionAnalysisManager &MFAM) {
+  AMDGPUAsmPrinter &AsmPrinter = static_cast<AMDGPUAsmPrinter &>(
+      MFAM.getResult<ModuleAnalysisManagerMachineFunctionProxy>(MF)
+          .getCachedResult<AsmPrinterAnalysis>(*MF.getFunction().getParent())
+          ->getPrinter());
+  setupMachineFunctionAsmPrinter(MFAM, MF, AsmPrinter);
+  AsmPrinter.GetResourceUsage = [&MFAM](MachineFunction &MF)
+      -> const AMDGPUResourceUsageAnalysisImpl::SIFunctionResourceInfo * {
+    return &MFAM.getResult<AMDGPUResourceUsageAnalysis>(MF);
+  };
+  AsmPrinter.runOnMachineFunction(MF);
+  return PreservedAnalyses::all();
+}
+
+PreservedAnalyses AMDGPUAsmPrinterEndPass::run(Module &M,
+                                               ModuleAnalysisManager &MAM) {
+  AMDGPUAsmPrinter &AsmPrinter = static_cast<AMDGPUAsmPrinter &>(
+      MAM.getResult<AsmPrinterAnalysis>(M).getPrinter());
+  setupModuleAsmPrinter(M, MAM, AsmPrinter);
+  AsmPrinter.doFinalization(M);
+  return PreservedAnalyses::all();
+}
+
 char AMDGPUAsmPrinter::ID = 0;
 
 INITIALIZE_PASS(AMDGPUAsmPrinter, "amdgpu-asm-printer",
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
index 9066b2d419f89..b1b1d025058e9 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
@@ -20,6 +20,7 @@
 #include "SIProgramInfo.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/Passes/CodeGenPassBuilder.h"
 
 namespace llvm {
 
@@ -104,6 +105,9 @@ class AMDGPUAsmPrinter final : public AsmPrinter {
   void validateMCResourceInfo(Function &F);
 
 public:
+  std::function<const AMDGPUResourceUsageAnalysisImpl::SIFunctionResourceInfo *(
+      MachineFunction &)>
+      GetResourceUsage;
   explicit AMDGPUAsmPrinter(TargetMachine &TM,
                             std::unique_ptr<MCStreamer> Streamer);
 
@@ -161,6 +165,24 @@ class AMDGPUAsmPrinter final : public AsmPrinter {
   bool IsTargetStreamerInitialized;
 };
 
+class AMDGPUAsmPrinterBeginPass
+    : public PassInfoMixin<AMDGPUAsmPrinterBeginPass> {
+public:
+  PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
+};
+
+class AMDGPUAsmPrinterPass
+    : public RequiredPassInfoMixin<AMDGPUAsmPrinterPass> {
+public:
+  PreservedAnalyses run(MachineFunction &MF,
+                        MachineFunctionAnalysisManager &MFAM);
+};
+
+class AMDGPUAsmPrinterEndPass : public PassInfoMixin<AMDGPUAsmPrinterEndPass> {
+public:
+  PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
+};
+
 } // end namespace llvm
 
 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUASMPRINTER_H
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 06bfc7e1a5162..b4a0aae2c3d45 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -17,6 +17,7 @@
 #include "AMDGPUTargetMachine.h"
 #include "AMDGPU.h"
 #include "AMDGPUAliasAnalysis.h"
+#include "AMDGPUAsmPrinter.h"
 #include "AMDGPUBarrierLatency.h"
 #include "AMDGPUCoExecSchedStrategy.h"
 #include "AMDGPUCtorDtorLowering.h"
@@ -962,6 +963,14 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
 #define GET_PASS_REGISTRY "AMDGPUPassRegistry.def"
 #include "llvm/Passes/TargetPassRegistry.inc"
 
+  if (PIC) {
+    PIC->addClassToPassName(AMDGPUAsmPrinterBeginPass::name(),
+                            "amdgpu-asm-printer-begin");
+    PIC->addClassToPassName(AMDGPUAsmPrinterPass::name(), "amdgpu-asm-printer");
+    PIC->addClassToPassName(AMDGPUAsmPrinterEndPass::name(),
+                            "amdgpu-asm-printer-end");
+  }
+
   PB.registerPipelineParsingCallback(
       [this](StringRef Name, CGSCCPassManager &PM,
              ArrayRef<PassBuilder::PipelineElement> Pipeline) {
@@ -2406,15 +2415,16 @@ void AMDGPUCodeGenPassBuilder::addILPOpts(PassManagerWrapper &PMW) const {
 
 void AMDGPUCodeGenPassBuilder::addAsmPrinterBegin(
     PassManagerWrapper &PMW) const {
-  // TODO: Add AsmPrinterBegin
+  addModulePass(AMDGPUAsmPrinterBeginPass(), PMW,
+                /*Force=*/true);
 }
 
 void AMDGPUCodeGenPassBuilder::addAsmPrinter(PassManagerWrapper &PMW) const {
-  // TODO: Add AsmPrinter.
+  addMachineFunctionPass(AMDGPUAsmPrinterPass(), PMW);
 }
 
 void AMDGPUCodeGenPassBuilder::addAsmPrinterEnd(PassManagerWrapper &PMW) const {
-  // TODO: Add AsmPrinterEnd
+  addModulePass(AMDGPUAsmPrinterEndPass(), PMW, /*Force=*/true);
 }
 
 Error AMDGPUCodeGenPassBuilder::addInstSelector(PassManagerWrapper &PMW) const {
diff --git a/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll b/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
index 0c591ec5b4669..865058fa1d92c 100644
--- a/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
+++ b/llvm/test/CodeGen/AMDGPU/llc-pipeline-npm.ll
@@ -55,6 +55,7 @@
 ; GCN-O0-NEXT:     safe-stack
 ; GCN-O0-NEXT:     stack-protector
 ; GCN-O0-NEXT:     verify
+; GCN-O0-NEXT: amdgpu-asm-printer-begin
 ; GCN-O0-NEXT: cgscc
 ; GCN-O0-NEXT:   function
 ; GCN-O0-NEXT:     machine-function
@@ -103,7 +104,9 @@
 ; GCN-O0-NEXT:       amdgpu-preload-kern-arg-prolog
 ; GCN-O0-NEXT:       stack-frame-layout
 ; GCN-O0-NEXT:       verify
-; GCN-O0-NEXT:     free-machine-function
+; GCN-O0-NEXT:       amdgpu-asm-printer
+; GCN-O0-NEXT:     free-machine-function 
+; GCN-O0-NEXT: amdgpu-asm-printer-end
 
 ; GCN-O2: require<MachineModuleAnalysis>
 ; GCN-O2-NEXT: require<profile-summary>
@@ -183,6 +186,7 @@
 ; GCN-O2-NEXT:     safe-stack
 ; GCN-O2-NEXT:     stack-protector
 ; GCN-O2-NEXT:     verify
+; GCN-O2-NEXT: amdgpu-asm-printer-begin
 ; GCN-O2-NEXT: cgscc
 ; GCN-O2-NEXT:   function
 ; GCN-O2-NEXT:     machine-function
@@ -289,7 +293,9 @@
 ; GCN-O2-NEXT:       amdgpu-preload-kern-arg-prolog
 ; GCN-O2-NEXT:       stack-frame-layout
 ; GCN-O2-NEXT:       verify
+; GCN-O2-NEXT:       amdgpu-asm-printer
 ; GCN-O2-NEXT:     free-machine-function
+; GCN-O2-NEXT: amdgpu-asm-printer-end
 
 ; GCN-O3: require<MachineModuleAnalysis>
 ; GCN-O3-NEXT: require<profile-summary>
@@ -369,6 +375,7 @@
 ; GCN-O3-NEXT:     safe-stack
 ; GCN-O3-NEXT:     stack-protector
 ; GCN-O3-NEXT:     verify
+; GCN-O3-NEXT: amdgpu-asm-printer-begin
 ; GCN-O3-NEXT: cgscc
 ; GCN-O3-NEXT:   function
 ; GCN-O3-NEXT:     machine-function
@@ -475,7 +482,9 @@
 ; GCN-O3-NEXT:       amdgpu-preload-kern-arg-prolog
 ; GCN-O3-NEXT:       stack-frame-layout
 ; GCN-O3-NEXT:       verify
+; GCN-O3-NEXT:       amdgpu-asm-printer
 ; GCN-O3-NEXT:     free-machine-function
+; GCN-O3-NEXT: amdgpu-asm-printer-end
 
 define void @empty() {
   ret void

>From dfab07ad12d23aae7f0670c5298906addfd84e22 Mon Sep 17 00:00:00 2001
From: vikhegde <vikram.hegde at amd.com>
Date: Mon, 6 Jul 2026 05:33:02 +0530
Subject: [PATCH 2/4] review comments

---
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp    | 1 +
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h      | 6 +++---
 llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 4 +++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index 984b96af01354..42650a66b981e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -35,6 +35,7 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/ELF.h"
+#include "llvm/CodeGen/AsmPrinterAnalysis.h"
 #include "llvm/CodeGen/AsmPrinterHandler.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
index b1b1d025058e9..4394cde308665 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
@@ -20,7 +20,6 @@
 #include "SIProgramInfo.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/CodeGen/AsmPrinter.h"
-#include "llvm/Passes/CodeGenPassBuilder.h"
 
 namespace llvm {
 
@@ -166,7 +165,7 @@ class AMDGPUAsmPrinter final : public AsmPrinter {
 };
 
 class AMDGPUAsmPrinterBeginPass
-    : public PassInfoMixin<AMDGPUAsmPrinterBeginPass> {
+    : public RequiredPassInfoMixin<AMDGPUAsmPrinterBeginPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
@@ -178,7 +177,8 @@ class AMDGPUAsmPrinterPass
                         MachineFunctionAnalysisManager &MFAM);
 };
 
-class AMDGPUAsmPrinterEndPass : public PassInfoMixin<AMDGPUAsmPrinterEndPass> {
+class AMDGPUAsmPrinterEndPass
+    : public RequiredPassInfoMixin<AMDGPUAsmPrinterEndPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index b4a0aae2c3d45..b07905a71b16f 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -963,6 +963,8 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
 #define GET_PASS_REGISTRY "AMDGPUPassRegistry.def"
 #include "llvm/Passes/TargetPassRegistry.inc"
 
+  // TODO: Move this into the base CodeGenPassBuilder once all
+  // targets that currently implement it have a ported asm-printer pass.
   if (PIC) {
     PIC->addClassToPassName(AMDGPUAsmPrinterBeginPass::name(),
                             "amdgpu-asm-printer-begin");
@@ -2424,7 +2426,7 @@ void AMDGPUCodeGenPassBuilder::addAsmPrinter(PassManagerWrapper &PMW) const {
 }
 
 void AMDGPUCodeGenPassBuilder::addAsmPrinterEnd(PassManagerWrapper &PMW) const {
-  addModulePass(AMDGPUAsmPrinterEndPass(), PMW, /*Force=*/true);
+  addModulePass(AMDGPUAsmPrinterEndPass(), PMW);
 }
 
 Error AMDGPUCodeGenPassBuilder::addInstSelector(PassManagerWrapper &PMW) const {

>From 0e8654606455e1beaac441cdbbee26ca25e424e2 Mon Sep 17 00:00:00 2001
From: vikhegde <vikram.hegde at amd.com>
Date: Thu, 4 Jun 2026 14:14:38 +0530
Subject: [PATCH 3/4] [NPM] Port ImmutableModuleSummaryAnalysis to NPM

---
 .../llvm/Analysis/ModuleSummaryAnalysis.h     | 29 +++++++++++++++++++
 llvm/lib/Analysis/ModuleSummaryAnalysis.cpp   |  1 +
 llvm/lib/Analysis/StackSafetyAnalysis.cpp     |  7 +++--
 llvm/lib/Passes/PassRegistry.def              |  2 ++
 4 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h b/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
index 7e78e9b9f2262..8d79ae418751a 100644
--- a/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
+++ b/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
@@ -92,6 +92,35 @@ class LLVM_ABI ImmutableModuleSummaryIndexWrapperPass : public ImmutablePass {
   void getAnalysisUsage(AnalysisUsage &AU) const override;
 };
 
+/// NPM analysis to provide an externally-built ModuleSummaryIndex (e.g. the
+/// combined index from LTO).
+class ImmutableModuleSummaryIndexAnalysis
+    : public AnalysisInfoMixin<ImmutableModuleSummaryIndexAnalysis> {
+  friend AnalysisInfoMixin<ImmutableModuleSummaryIndexAnalysis>;
+  LLVM_ABI static AnalysisKey Key;
+  const ModuleSummaryIndex *Index = nullptr;
+
+public:
+  class Result {
+    const ModuleSummaryIndex *Index;
+    Result(const ModuleSummaryIndex *Index) : Index(Index) {}
+    friend class ImmutableModuleSummaryIndexAnalysis;
+
+  public:
+    const ModuleSummaryIndex *getIndex() const { return Index; }
+    bool invalidate(Module &, const PreservedAnalyses &,
+                    ModuleAnalysisManager::Invalidator &) {
+      return false;
+    }
+  };
+
+  ImmutableModuleSummaryIndexAnalysis() = default;
+  ImmutableModuleSummaryIndexAnalysis(const ModuleSummaryIndex *Index)
+      : Index(Index) {}
+
+  Result run(Module &M, ModuleAnalysisManager &AM) { return Result(Index); }
+};
+
 //===--------------------------------------------------------------------===//
 //
 // ImmutableModuleSummaryIndexWrapperPass - This pass wrap provided
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 0a2e5583c240b..33caa268b1c6e 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -1175,6 +1175,7 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex(
 }
 
 AnalysisKey ModuleSummaryIndexAnalysis::Key;
+AnalysisKey ImmutableModuleSummaryIndexAnalysis::Key;
 
 ModuleSummaryIndex
 ModuleSummaryIndexAnalysis::run(Module &M, ModuleAnalysisManager &AM) {
diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index 024a30f10e8f0..9c20019677895 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -1068,14 +1068,17 @@ AnalysisKey StackSafetyGlobalAnalysis::Key;
 
 StackSafetyGlobalInfo
 StackSafetyGlobalAnalysis::run(Module &M, ModuleAnalysisManager &AM) {
-  // FIXME: Lookup Module Summary.
   FunctionAnalysisManager &FAM =
       AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
+  const ModuleSummaryIndex *Index = nullptr;
+  if (auto *IndexPass =
+          AM.getCachedResult<ImmutableModuleSummaryIndexAnalysis>(M))
+    Index = IndexPass->getIndex();
   return {&M,
           [&FAM](Function &F) -> const StackSafetyInfo & {
             return FAM.getResult<StackSafetyAnalysis>(F);
           },
-          nullptr};
+          Index};
 }
 
 PreservedAnalyses StackSafetyGlobalPrinterPass::run(Module &M,
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 64331e04c155b..d95f8b6e0e3db 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -31,6 +31,8 @@ MODULE_ANALYSIS("ir-similarity", IRSimilarityAnalysis())
 MODULE_ANALYSIS("last-run-tracking", LastRunTrackingAnalysis())
 MODULE_ANALYSIS("lcg", LazyCallGraphAnalysis())
 MODULE_ANALYSIS("libcall-lowering-info", LibcallLoweringModuleAnalysis())
+MODULE_ANALYSIS("immutable-module-summary",
+                ImmutableModuleSummaryIndexAnalysis())
 MODULE_ANALYSIS("module-summary", ModuleSummaryIndexAnalysis())
 MODULE_ANALYSIS("no-op-module", NoOpModuleAnalysis())
 MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))

>From 47acb0c3dfc6d593d434bcebecc531082b1cf771 Mon Sep 17 00:00:00 2001
From: vikhegde <vikram.hegde at amd.com>
Date: Mon, 6 Jul 2026 13:43:33 +0530
Subject: [PATCH 4/4] provide default nullptr to Index

---
 llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h b/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
index 8d79ae418751a..c0d198d16bba5 100644
--- a/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
+++ b/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
@@ -102,7 +102,7 @@ class ImmutableModuleSummaryIndexAnalysis
 
 public:
   class Result {
-    const ModuleSummaryIndex *Index;
+    const ModuleSummaryIndex *Index = nullptr;
     Result(const ModuleSummaryIndex *Index) : Index(Index) {}
     friend class ImmutableModuleSummaryIndexAnalysis;
 



More information about the llvm-commits mailing list