Index: lib/Target/AMDGPU/SIMachineScheduler.cpp =================================================================== --- lib/Target/AMDGPU/SIMachineScheduler.cpp +++ lib/Target/AMDGPU/SIMachineScheduler.cpp @@ -1119,12 +1119,11 @@ static MachineBasicBlock::iterator nextIfDebug(MachineBasicBlock::iterator I, MachineBasicBlock::const_iterator End) { - // Cast the return value to nonconst MachineInstr, then cast to an - // instr_iterator, which does not check for null, finally return a - // bundle_iterator. - return MachineBasicBlock::instr_iterator( - const_cast( - &*nextIfDebug(MachineBasicBlock::const_iterator(I), End))); + for (; I != End; ++I) { + if (!I->isDebugValue()) + break; + } + return I; } void SIScheduleBlockCreator::topologicalSort() {