<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Dan,<div><br></div><div>This does not make sense. See below...</div><div><br><div><div>On May 5, 2010, at 4:41 PM, Dan Gohman wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Author: djg<br>Date: Wed May  5 18:41:32 2010<br>New Revision: 103135<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=103135&view=rev">http://llvm.org/viewvc/llvm-project?rev=103135&view=rev</a><br>Log:<br>Emit debug info for MachineInstrs with unknown debug locations, instead<br>of just letting them inherit the debug locations of adjacent instructions.<br><br>Debug info should aim to be either accurate or absent.<br><br>Modified:<br>    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br><br>Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=103135&r1=103134&r2=103135&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=103135&r1=103134&r2=103135&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed May  5 18:41:32 2010<br>@@ -2150,8 +2150,20 @@<br> void DwarfDebug::beginScope(const MachineInstr *MI) {<br>   // Check location.<br>   DebugLoc DL = MI->getDebugLoc();<br>-  if (DL.isUnknown())<br>+  if (DL.isUnknown()) {<br>+    // This instruction has no debug location. If the preceding instruction<br>+    // did, emit debug location information to indicate that the debug<br>+    // location is now unknown.<br>+    MCSymbol *Label = NULL;<br>+    if (DL == PrevInstLoc)<br>+      Label = PrevLabel;<br></div></blockquote><div><br></div><div>Here, Label is not used afterwords.</div><div><br></div><blockquote type="cite"><div>+    else {<br>+      Label = recordSourceLine(DL.getLine(), DL.getCol(), 0);</div></blockquote><div><br></div>If DL is unknown then DL.getLine(), DL.getCol() are not useful to record source location.<br><blockquote type="cite"><div>+      PrevInstLoc = DL;<br>+      PrevLabel = Label;<br></div></blockquote><div><br></div> And here PrevInstLoc and PrevLable were updated when a label for valid location was emitted. Instead you're overriding valid PrevInstLoc with Unknown debug location.</div><div><br><blockquote type="cite"><div>+    }<br>     return;<br>+  }<br></div></blockquote><div><br></div><div><br></div><blockquote type="cite"><div>   MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext());<br><br>@@ -2564,23 +2576,28 @@<br>   StringRef Dir;<br>   StringRef Fn;<br><br>-  DIDescriptor Scope(S);<br>-  if (Scope.isCompileUnit()) {<br>-    DICompileUnit CU(S);<br>-    Dir = CU.getDirectory();<br>-    Fn = CU.getFilename();<br>-  } else if (Scope.isSubprogram()) {<br>-    DISubprogram SP(S);<br>-    Dir = SP.getDirectory();<br>-    Fn = SP.getFilename();<br>-  } else if (Scope.isLexicalBlock()) {<br>-    DILexicalBlock DB(S);<br>-    Dir = DB.getDirectory();<br>-    Fn = DB.getFilename();<br>-  } else<br>-    assert(0 && "Unexpected scope info");<br>+  unsigned Src = 1;<br>+  if (S) {<br>+    DIDescriptor Scope(S);<br>+<br>+    if (Scope.isCompileUnit()) {<br>+      DICompileUnit CU(S);<br>+      Dir = CU.getDirectory();<br>+      Fn = CU.getFilename();<br>+    } else if (Scope.isSubprogram()) {<br>+      DISubprogram SP(S);<br>+      Dir = SP.getDirectory();<br>+      Fn = SP.getFilename();<br>+    } else if (Scope.isLexicalBlock()) {<br>+      DILexicalBlock DB(S);<br>+      Dir = DB.getDirectory();<br>+      Fn = DB.getFilename();<br>+    } else<br>+      assert(0 && "Unexpected scope info");<br>+<br>+    Src = GetOrCreateSourceID(Dir, Fn);<br>+  }<br></div></blockquote><div><br></div>I am not sure what exactly this part achieves other then increasing indentation.<br><blockquote type="cite"><div><br>-  unsigned Src = GetOrCreateSourceID(Dir, Fn);<br>   MCSymbol *Label = MMI->getContext().CreateTempSymbol();<br>   Lines.push_back(SrcLineInfo(Line, Col, Src, Label));<br><br>@@ -2967,8 +2984,6 @@<br>       MCSymbol *Label = LineInfo.getLabel();<br>       if (!Label->isDefined()) continue; // Not emitted, in dead code.<br><br>-      if (LineInfo.getLine() == 0) continue;<br>-<br>       if (Asm->isVerbose()) {<br>         std::pair<unsigned, unsigned> SrcID =<br>           getSourceDirectoryAndFileIds(LineInfo.getSourceID());<font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote><br></div><div>Can you send me small test case where this patch improves debug info ?</div><div>Thanks,</div><div>-</div><div>Devang</div></div></body></html>