<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 4, 2014 at 12:30 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dblaikie<br>
Date: Mon Aug  4 14:30:08 2014<br>
New Revision: 214761<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=214761&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=214761&view=rev</a><br>
Log:<br>
Reapply "DebugInfo: Ensure that all debug location scope chains from instructions within a function, lead to the function itself."<br>
<br>
Originally reverted in r213432 with flakey failures on an ASan self-host<br>
build. After reduction it seems to be the same issue fixed in r213805<br>
(ArgPromo + DebugInfo: Handle updating debug info over multiple<br>
applications of argument promotion) and r213952 (by having<br>
LiveDebugVariables strip dbg_value intrinsics in functions that are not<br>
described by debug info). Though I cannot explain why this failure was<br>
flakey...<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
    llvm/trunk/lib/CodeGen/LexicalScopes.cpp<br>
    llvm/trunk/lib/IR/DebugInfo.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=214761&r1=214760&r2=214761&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=214761&r1=214760&r2=214761&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug  4 14:30:08 2014<br>
@@ -796,8 +796,7 @@ void DwarfDebug::finishVariableDefinitio<br>
   for (const auto &Var : ConcreteVariables) {<br>
     DIE *VariableDie = Var->getDIE();<br>
     // FIXME: There shouldn't be any variables without DIEs.<br>
-    if (!VariableDie)<br>
-      continue;<br>
+    assert(VariableDie);<br>
     // FIXME: Consider the time-space tradeoff of just storing the unit pointer<br>
     // in the ConcreteVariables list, rather than looking it up again here.<br>
     // DIE::getUnit isn't simple - it walks parent pointers, etc.<br>
<br>
Modified: llvm/trunk/lib/CodeGen/LexicalScopes.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LexicalScopes.cpp?rev=214761&r1=214760&r2=214761&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LexicalScopes.cpp?rev=214761&r1=214760&r2=214761&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/LexicalScopes.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/LexicalScopes.cpp Mon Aug  4 14:30:08 2014<br>
@@ -137,6 +137,8 @@ LexicalScope *LexicalScopes::findLexical<br>
 /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If<br>
 /// not available then create new lexical scope.<br>
 LexicalScope *LexicalScopes::getOrCreateLexicalScope(DebugLoc DL) {<br>
+  if (DL.isUnknown())<br>
+    return nullptr;<br>
   MDNode *Scope = nullptr;<br>
   MDNode *InlinedAt = nullptr;<br>
   DL.getScopeAndInlinedAt(Scope, InlinedAt, MF->getFunction()->getContext());<br>
@@ -172,9 +174,12 @@ LexicalScope *LexicalScopes::getOrCreate<br>
                               std::make_tuple(Parent, DIDescriptor(Scope),<br>
                                               nullptr, false)).first;<br>
<br>
-  if (!Parent && DIDescriptor(Scope).isSubprogram() &&<br>
-      DISubprogram(Scope).describes(MF->getFunction()))<br>
+  if (!Parent) {<br>
+    assert(DIDescriptor(Scope).isSubprogram());<br>
+    assert(DISubprogram(Scope).describes(MF->getFunction()));<br></blockquote><div><br></div><div>^ This assertion is failing during a self-host on Windows that uses -gmlt. I'll post a .ii file soon.</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+    assert(!CurrentFnLexicalScope);<br>
     CurrentFnLexicalScope = &I->second;<br>
+  }<br>
<br>
   return &I->second;<br>
 }<br>
<br>
Modified: llvm/trunk/lib/IR/DebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=214761&r1=214760&r2=214761&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=214761&r1=214760&r2=214761&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)<br>
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Aug  4 14:30:08 2014<br>
@@ -560,6 +560,32 @@ bool DISubprogram::Verify() const {<br>
   if (isLValueReference() && isRValueReference())<br>
     return false;<br>
<br>
+  if (auto *F = getFunction()) {<br>
+    LLVMContext &Ctxt = F->getContext();<br>
+    for (auto &BB : *F) {<br>
+      for (auto &I : BB) {<br>
+        DebugLoc DL = I.getDebugLoc();<br>
+        if (DL.isUnknown())<br>
+          continue;<br>
+<br>
+        MDNode *Scope = nullptr;<br>
+        MDNode *IA = nullptr;<br>
+        // walk the inlined-at scopes<br>
+        while (DL.getScopeAndInlinedAt(Scope, IA, F->getContext()), IA)<br>
+          DL = DebugLoc::getFromDILocation(IA);<br>
+        DL.getScopeAndInlinedAt(Scope, IA, Ctxt);<br>
+        assert(!IA);<br>
+        while (!DIDescriptor(Scope).isSubprogram()) {<br>
+          DILexicalBlockFile D(Scope);<br>
+          Scope = D.isLexicalBlockFile()<br>
+                      ? D.getScope()<br>
+                      : DebugLoc::getFromDILexicalBlock(Scope).getScope(Ctxt);<br>
+        }<br>
+        if (!DISubprogram(Scope).describes(F))<br>
+          return false;<br>
+      }<br>
+    }<br>
+  }<br>
   return DbgNode->getNumOperands() == 20;<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>