<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 14, 2014 at 10:11 AM, 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: Tue Oct 14 12:11:59 2014<br>
New Revision: 219693<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=219693&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=219693&view=rev</a><br>
Log:<br>
Fix stuff... again.<br></blockquote><div><br></div><div>Sorry about the commit message - reverted. (though should be recommitted soon with a real commit message once I've done some more testing after the recent fix in Clang)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/LexicalScopes.cpp<br>
    llvm/trunk/lib/IR/DebugInfo.cpp<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=219693&r1=219692&r2=219693&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LexicalScopes.cpp?rev=219693&r1=219692&r2=219693&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/LexicalScopes.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/LexicalScopes.cpp Tue Oct 14 12:11:59 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>
+    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=219693&r1=219692&r2=219693&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=219693&r1=219692&r2=219693&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)<br>
+++ llvm/trunk/lib/IR/DebugInfo.cpp Tue Oct 14 12:11:59 2014<br>
@@ -568,6 +568,34 @@ bool DISubprogram::Verify() const {<br>
   if (isLValueReference() && isRValueReference())<br>
     return false;<br>
<br>
+  // If a DISubprogram has an llvm::Function*, then scope chains from all<br>
+  // instructions within the function should lead to this DISubprogram.<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() == 9 && getNumHeaderFields() == 12;<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>