Index: lib/Target/AMDGPU/SIDefines.h =================================================================== --- lib/Target/AMDGPU/SIDefines.h +++ lib/Target/AMDGPU/SIDefines.h @@ -148,6 +148,13 @@ }; } +namespace SIStackID { +enum StackTypes : uint8_t { + SCRATCH = 0, + SGPR_SPILL = 1 +}; +} + // Input operand modifiers bit-masks // NEG and SEXT share same bit-mask because they can't be set simultaneously. namespace SISrcMods { Index: lib/Target/AMDGPU/SIFrameLowering.cpp =================================================================== --- lib/Target/AMDGPU/SIFrameLowering.cpp +++ lib/Target/AMDGPU/SIFrameLowering.cpp @@ -691,6 +691,7 @@ if (TII->isSGPRSpill(MI)) { int FI = TII->getNamedOperand(MI, AMDGPU::OpName::addr)->getIndex(); + assert(MFI.getStackID(FI) == SIStackID::SGPR_SPILL); if (FuncInfo->allocateSGPRSpillToVGPR(MF, FI)) { bool Spilled = TRI.eliminateSGPRToVGPRSpillFrameIndex(MI, FI, RS); (void)Spilled; Index: lib/Target/AMDGPU/SIInstrInfo.cpp =================================================================== --- lib/Target/AMDGPU/SIInstrInfo.cpp +++ lib/Target/AMDGPU/SIInstrInfo.cpp @@ -864,7 +864,7 @@ // needing them, and need to ensure that the reserved registers are // correctly handled. - FrameInfo.setStackID(FrameIndex, 1); + FrameInfo.setStackID(FrameIndex, SIStackID::SGPR_SPILL); if (ST.hasScalarStores()) { // m0 is used for offset to scalar stores if used to spill. Spill.addReg(AMDGPU::M0, RegState::ImplicitDefine | RegState::Dead); @@ -960,7 +960,7 @@ MRI.constrainRegClass(DestReg, &AMDGPU::SReg_32_XM0RegClass); } - FrameInfo.setStackID(FrameIndex, 1); + FrameInfo.setStackID(FrameIndex, SIStackID::SGPR_SPILL); MachineInstrBuilder Spill = BuildMI(MBB, MI, DL, OpDesc, DestReg) .addFrameIndex(FrameIndex) // addr .addMemOperand(MMO)