[llvm] [AMDGPU] Fix overlapping insert crash during rewrite-agpr-copy-mfma (PR #205962)

Lukas Sommer via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 01:04:02 PDT 2026


================
@@ -610,8 +610,15 @@ void AMDGPURewriteAGPRCopyMFMAImpl::eliminateSpillsOfReassignedVGPRs() const {
 
     ArrayRef<MCPhysReg> AllocOrder = RegClassInfo.getOrder(RC);
 
+    // The stack slot's LiveInterval may be discontiguous: a slot can be live
+    // in memory around a spill store and around a much later reload. Once
+    // we unspill the slot into a register, however, the value must reside in
+    // that register continuously from its first reference to its last. Checking
+    // interference against the slot's discontiguous interval could let us pick
+    // a PhysReg that is busy inside a gap, corrupting it. Instead, check
+    // interference over the range the replacement register will occupy.
----------------
sommerlukas wrote:

IIUC, this is a safe over-approximation, as we split the individual components of the stack slot's life interval further down. If so, we should probably document this here.

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


More information about the llvm-commits mailing list