[llvm] [AMDGPU] Fix crash with dead frame indices in debug values (PR #183297)

Juan Manuel Martinez Caamaño via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 05:24:38 PDT 2026


================
@@ -1531,13 +1531,11 @@ void SIFrameLowering::processFunctionBeforeFrameFinalized(
         // correct register value. But not sure the register value alone is
         for (MachineInstr &MI : MBB) {
           if (MI.isDebugValue()) {
-            uint32_t StackOperandIdx = MI.isDebugValueList() ? 2 : 0;
-            if (MI.getOperand(StackOperandIdx).isFI() &&
-                !MFI.isFixedObjectIndex(
-                    MI.getOperand(StackOperandIdx).getIndex()) &&
-                SpillFIs[MI.getOperand(StackOperandIdx).getIndex()]) {
-              MI.getOperand(StackOperandIdx)
-                  .ChangeToRegister(Register(), false /*isDef*/);
+            for (MachineOperand &Op : MI.debug_operands()) {
+              if (Op.isFI() && !MFI.isFixedObjectIndex(Op.getIndex()) &&
+                  SpillFIs[Op.getIndex()]) {
+                Op.ChangeToRegister(Register(), false /*isDef*/);
+              }
----------------
jmmartinez wrote:

Can we move this to a helper function? The two code snippets look like a copy paste. But one with a line missing: `// adequate to lower the DIExpression. It should be worked out later.`

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


More information about the llvm-commits mailing list