Don't insert DBG_VALUE instructions after the first terminator.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 11 Jan 2011 22:11:16 +0000 (22:11 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 11 Jan 2011 22:11:16 +0000 (22:11 +0000)
For one, MachineBasicBlock::getFirstTerminator() doesn't understand what is
happening, and it also makes sense to have all control flow run through the
DBG_VALUE.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123277 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveDebugVariables.cpp

index da4b017cdca01d29de656eaea3d9650a952844f9..9a67a630b5428bedd05029d1f6a236f0e03b270c 100644 (file)
@@ -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))) {