[PATCH] D26982: Restructure DwarfDebug::beginInstruction (NFC).

Paul Robinson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 10:47:14 PST 2016


probinson created this revision.
probinson added reviewers: dblaikie, echristo.
probinson added a subscriber: llvm-commits.
Herald added a subscriber: mehdi_amini.

Based on discussion in https://reviews.llvm.org/D24180, redo the method with less indentation which should help make the other patch easier to understand.


https://reviews.llvm.org/D26982

Files:
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp


Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1007,28 +1007,33 @@
   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 a new, explicit location.
+    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);
+    return;
+  }
+  // We have an unspecified location.
+  if (UnknownLocations) {
+    PrevInstLoc = DL;
+    recordSourceLine(0, 0, nullptr, 0);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26982.78893.patch
Type: text/x-patch
Size: 1828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161122/b04865ac/attachment.bin>


More information about the llvm-commits mailing list