From 341e293d67541115a7eeb235e94ad5e1e82f6c73 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 2 May 2016 18:02:24 +0000 Subject: [PATCH] AMDGPU/SI: Fix bug in SIInstrInfo::insertWaitStates() uncovered by r268260 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp index eb17ffe..f5cd065 100644 --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp @@ -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); } } -- 2.7.4