Index: lib/Target/AMDGPU/GCNSchedStrategy.cpp =================================================================== --- lib/Target/AMDGPU/GCNSchedStrategy.cpp +++ lib/Target/AMDGPU/GCNSchedStrategy.cpp @@ -422,9 +422,12 @@ unsigned SGPRs = 0; unsigned VGPRs = 0; - auto &MI = *begin()->getParent()->getFirstNonDebugInstr(); + auto I = begin(); + for (auto const E = I->getParent()->end(); I != E; ++I) + if (!I->isDebugValue()) + break; const SIRegisterInfo *SRI = static_cast(TRI); - SlotIndex SI = LIS->getInstructionIndex(MI).getBaseIndex(); + SlotIndex SI = LIS->getInstructionIndex(*I).getBaseIndex(); assert (SI.isValid()); DEBUG(dbgs() << "Region live-ins:");