AMDGPU/SI: Fix bug in SIInstrInfo::insertWaitStates() uncovered by r268260
authorTom Stellard <thomas.stellard@amd.com>
Mon, 2 May 2016 18:02:24 +0000 (18:02 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Mon, 2 May 2016 18:02:24 +0000 (18:02 +0000)
We can't use MI->getDebugLoc() when MI is an iterator that could be
MBB.end().

llvm-svn: 268265

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

index eb17ffe..f5cd065 100644 (file)
@@ -806,6 +806,7 @@ unsigned SIInstrInfo::calculateLDSSpillAddress(MachineBasicBlock &MBB,
 void SIInstrInfo::insertWaitStates(MachineBasicBlock &MBB,
                                    MachineBasicBlock::iterator MI,
                                    int Count) const {
+  DebugLoc DL = MBB.findDebugLoc(MI);
   while (Count > 0) {
     int Arg;
     if (Count >= 8)
@@ -813,7 +814,7 @@ void SIInstrInfo::insertWaitStates(MachineBasicBlock &MBB,
     else
       Arg = Count - 1;
     Count -= 8;
-    BuildMI(MBB, MI, MI->getDebugLoc(), get(AMDGPU::S_NOP))
+    BuildMI(MBB, MI, DL, get(AMDGPU::S_NOP))
             .addImm(Arg);
   }
 }