]> granicus.if.org Git - llvm/commitdiff
Restructure DwarfDebug::beginInstruction(). [NFC]
authorPaul Robinson <paul.robinson@sony.com>
Tue, 22 Nov 2016 19:46:51 +0000 (19:46 +0000)
committerPaul Robinson <paul.robinson@sony.com>
Tue, 22 Nov 2016 19:46:51 +0000 (19:46 +0000)
Will help a pending patch.

Differential Revision: http://reviews.llvm.org/D26982

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

lib/CodeGen/AsmPrinter/DwarfDebug.cpp

index 59467f7dbaf658e2a3f45bc8563497627ca5e06f..06641d807844f589768becfd3611fd66fc9701b9 100644 (file)
@@ -1007,29 +1007,34 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
   assert(CurMI);
 
   // Check if source location changes, but ignore DBG_VALUE locations.
-  if (!MI->isDebugValue()) {
-    const DebugLoc &DL = MI->getDebugLoc();
-    if (DL != PrevInstLoc) {
-      if (DL) {
-        unsigned Flags = 0;
-        PrevInstLoc = DL;
-        if (DL == PrologEndLoc) {
-          Flags |= DWARF2_FLAG_PROLOGUE_END;
-          PrologEndLoc = DebugLoc();
-          Flags |= DWARF2_FLAG_IS_STMT;
-        }
-        if (DL.getLine() !=
-            Asm->OutStreamer->getContext().getCurrentDwarfLoc().getLine())
-          Flags |= DWARF2_FLAG_IS_STMT;
-
-        const MDNode *Scope = DL.getScope();
-        recordSourceLine(DL.getLine(), DL.getCol(), Scope, Flags);
-      } else if (UnknownLocations) {
-        PrevInstLoc = DL;
-        recordSourceLine(0, 0, nullptr, 0);
-      }
+  if (MI->isDebugValue())
+    return;
+  const DebugLoc &DL = MI->getDebugLoc();
+  if (DL == PrevInstLoc)
+    return;
+
+  if (!DL) {
+    // We have an unspecified location, which might want to be line 0.
+    if (UnknownLocations) {
+      PrevInstLoc = DL;
+      recordSourceLine(0, 0, nullptr, 0);
     }
+    return;
+  }
+
+  // We have a new, explicit location.
+  unsigned Flags = 0;
+  PrevInstLoc = DL;
+  if (DL == PrologEndLoc) {
+    Flags |= DWARF2_FLAG_PROLOGUE_END | DWARF2_FLAG_IS_STMT;
+    PrologEndLoc = DebugLoc();
   }
+  if (DL.getLine() !=
+      Asm->OutStreamer->getContext().getCurrentDwarfLoc().getLine())
+    Flags |= DWARF2_FLAG_IS_STMT;
+
+  const MDNode *Scope = DL.getScope();
+  recordSourceLine(DL.getLine(), DL.getCol(), Scope, Flags);
 }
 
 static DebugLoc findPrologueEndLoc(const MachineFunction *MF) {