[llvm] 8a3891c - [AMDGPU][NPM] Preserve analyses in AMDGPURewriteAGPRCopyMFMA for NPM (#170130)

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 09:26:41 PST 2025


Author: Prasoon Mishra
Date: 2025-12-01T22:56:37+05:30
New Revision: 8a3891ceadad3a156b8fbcdccd82f0aa7dece982

URL: https://github.com/llvm/llvm-project/commit/8a3891ceadad3a156b8fbcdccd82f0aa7dece982
DIFF: https://github.com/llvm/llvm-project/commit/8a3891ceadad3a156b8fbcdccd82f0aa7dece982.diff

LOG: [AMDGPU][NPM] Preserve analyses in AMDGPURewriteAGPRCopyMFMA for NPM (#170130)

The pass preserved LiveStacksAnalysis but failed to preserve
LiveIntervalsAnalysis, LiveRegMatrixAnalysis, VirtRegMapAnalysis, and
SlotIndexesAnalysis under NPM. This caused these analyses to be
invalidated and recomputed, leading to incorrect behavior in subsequent
passes like VirtRegRewriter.

Fix by explicitly preserving all required analyses in the NPM version,
matching the legacy pass manager behavior.

---------

Co-authored-by: vikhegde <vikram.hegde at amd.com>

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp b/llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp
index 89c16dadb4b41..095f23ad22d97 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp
@@ -32,6 +32,7 @@
 #include "llvm/CodeGen/LiveStacks.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/SlotIndexes.h"
 #include "llvm/CodeGen/VirtRegMap.h"
 #include "llvm/InitializePasses.h"
 
@@ -659,7 +660,11 @@ AMDGPURewriteAGPRCopyMFMAPass::run(MachineFunction &MF,
   if (!Impl.run(MF))
     return PreservedAnalyses::all();
   auto PA = getMachineFunctionPassPreservedAnalyses();
-  PA.preserveSet<CFGAnalyses>();
-  PA.preserve<LiveStacksAnalysis>();
+  PA.preserveSet<CFGAnalyses>()
+      .preserve<LiveStacksAnalysis>()
+      .preserve<VirtRegMapAnalysis>()
+      .preserve<SlotIndexesAnalysis>()
+      .preserve<LiveIntervalsAnalysis>()
+      .preserve<LiveRegMatrixAnalysis>();
   return PA;
 }


        


More information about the llvm-commits mailing list