From: Devang Patel Date: Fri, 6 Aug 2010 00:26:18 +0000 (+0000) Subject: While emitting DBG_VALUE for registers spilled at the end of a block do not use locat... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=31defcf2349916ac759be33baaa4060703fd78df;p=oota-llvm.git While emitting DBG_VALUE for registers spilled at the end of a block do not use location of MBB->end(). If a block does not have terminator then incoming iterator points to end(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110411 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/RegAllocFast.cpp b/lib/CodeGen/RegAllocFast.cpp index 9567308aa73..9dff74b5dd9 100644 --- a/lib/CodeGen/RegAllocFast.cpp +++ b/lib/CodeGen/RegAllocFast.cpp @@ -277,7 +277,14 @@ void RAFast::spillVirtReg(MachineBasicBlock::iterator MI, int64_t Offset = 0; if (DBG->getOperand(1).isImm()) Offset = DBG->getOperand(1).getImm(); - DebugLoc DL = MI->getDebugLoc(); + DebugLoc DL; + if (MI == MBB->end()) { + // If MI is at basic block end then use last instruction's location. + MachineBasicBlock::iterator EI = MI; + DL = (--EI)->getDebugLoc(); + } + else + DL = MI->getDebugLoc(); if (MachineInstr *NewDV = TII->emitFrameIndexDebugValue(*MF, FI, Offset, MDPtr, DL)) { MachineBasicBlock *MBB = DBG->getParent();