diff options
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugVariables.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugVariables.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp index da4b017cdca..9a67a630b54 100644 --- a/llvm/lib/CodeGen/LiveDebugVariables.cpp +++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp @@ -587,6 +587,13 @@ findInsertLocation(MachineBasicBlock *MBB, SlotIndex Idx, DebugLoc &DL, SlotIndex Start = LIS.getMBBStartIdx(MBB); Idx = Idx.getBaseIndex(); + // Don't insert anything after the first terminator. + MachineBasicBlock::iterator Term = MBB->getFirstTerminator(); + if (Term != MBB->end() && Idx >= LIS.getInstructionIndex(Term)) { + DL = Term->getDebugLoc(); + return Term; + } + // Try to find an insert location by going backwards from Idx. MachineInstr *MI; while (!(MI = LIS.getInstructionFromIndex(Idx))) { |