<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 25, 2016 at 10:39 AM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Apr 25, 2016, at 10:33 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><br><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On Sun, Apr 24, 2016 at 3:23 PM, Adrian Prantl via llvm-commits<span> </span><span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: adrian<br>Date: Sun Apr 24 17:23:13 2016<br>New Revision: 267370<br><br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project?rev=267370&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=267370&view=rev</a><br>Log:<br>Verifier: Verify that each inlinable callsite of a debug-info-bearing function<br>in a debug-info-bearing function has a debug location attached to it. Failure to<br>do so causes an "!dbg attachment points at wrong subprogram for function"<br>assertion failure when the inliner sets up inline scope info.<br></blockquote><div><br></div><div>Great to have this check - though, as an FYI: This doesn't catch all the cases of the downstream assertion. The downstream assertion can be triggered through indirect scenarios:<br><br>  void f1();<br>  inline __attribute__((alwaysinline)) void f2() { f1(); }<br>  inline __attribute__((alwaysinline)) void f3() { f2(); } // make this nodebug or equivalent<br>  void f4() { f3(); } // if f3 has no debugloc<br><br></div><div>Now you'll end up with the same problem if f2 is inlined into f3 (maybe even in the other order), producing instructions with debug locations - and then that's inlined into f4 at a callsite with no debugloc, leaving the instructions having debug locations that don't chain up to the f4 subprogram scope - but still chain up to the f2 subprogram scope.<br></div></div></div></blockquote><div><br></div></span><div>Thanks for pointing this out! I hope that the (cheaper) check from this patch will be enough to diagnose the most obvious bugs in frontends though.</div></div></div></blockquote><div><br></div><div>Yeah, for sure/here's hoping!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div class="h5"><div><br></div><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><br>- Dave<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br><a>rdar://problem/25878916</a><br><br>This reaplies r267320 without changes after fixing an issue in the OpenMP IR<br>generator in clang.<br><br>Added:<br>   <span> </span>llvm/trunk/test/Verifier/callsite-dbgloc.ll<br>Modified:<br>   <span> </span>llvm/trunk/lib/IR/Verifier.cpp<br>   <span> </span>llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll<br>   <span> </span>llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll<br><br>Modified: llvm/trunk/lib/IR/Verifier.cpp<br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=267370&r1=267369&r2=267370&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=267370&r1=267369&r2=267370&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/IR/Verifier.cpp (original)<br>+++ llvm/trunk/lib/IR/Verifier.cpp Sun Apr 24 17:23:13 2016<br>@@ -2579,6 +2579,15 @@ void Verifier::verifyCallSite(CallSite C<br>     }<br>   }<br><br>+  // Verify that each inlinable callsite of a debug-info-bearing function in a<br>+  // debug-info-bearing function has a debug location attached to it. Failure to<br>+  // do so causes assertion failures when the inliner sets up inline scope info.<br>+  if (I->getFunction()->getSubprogram() && CS.getCalledFunction() &&<br>+      CS.getCalledFunction()->getSubprogram())<br>+    Assert(I->getDebugLoc(), "inlinable function call in a function with debug "<br>+                             "info must have a !dbg location",<br>+           I);<br>+<br>   visitInstruction(*I);<br> }<br><br><br>Modified: llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll<br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll?rev=267370&r1=267369&r2=267370&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll?rev=267370&r1=267369&r2=267370&view=diff</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll (original)<br>+++ llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll Sun Apr 24 17:23:13 2016<br>@@ -18,7 +18,7 @@ define void @foo() !dbg !4 {<br><br> define void @bar() personality i8* bitcast (void ()* @foo to i8*) !dbg !9 {<br>   invoke void @foo()<br>-          to label %invoke.cont unwind label %lpad<br>+          to label %invoke.cont unwind label %lpad, !dbg !19<br><br> invoke.cont:                                      ; preds = %0<br>   ret void<br>@@ -50,3 +50,4 @@ lpad:<br> !16 = !DISubrange(count: 1)<br> !17 = !{i32 2, !"Dwarf Version", i32 4}<br> !18 = !{i32 2, !"Debug Info Version", i32 3}<br>+!19 = !DILocation(line: 0, scope: !9)<br><br>Modified: llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll<br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll?rev=267370&r1=267369&r2=267370&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll?rev=267370&r1=267369&r2=267370&view=diff</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll (original)<br>+++ llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll Sun Apr 24 17:23:13 2016<br>@@ -54,7 +54,7 @@ entry:<br>   store %class.A* %this, %class.A** %this.addr, align 8<br>   call void @llvm.dbg.declare(metadata %class.A** %this.addr, metadata !43, metadata !DIExpression()), !dbg !44<br>   %this1 = load %class.A*, %class.A** %this.addr<br>-  call void @_ZN1AD2Ev(%class.A* %this1)<br>+  call void @_ZN1AD2Ev(%class.A* %this1), !dbg !53<br>   ret void, !dbg !45<br> }<br><br>@@ -124,3 +124,4 @@ entry:<br> !49 = distinct !DILexicalBlock(line: 2, column: 52, file: !51, scope: !25)<br> !51 = !DIFile(filename: "a.cc", directory: "/private/tmp")<br> !52 = !{i32 1, !"Debug Info Version", i32 3}<br>+!53 = !DILocation(line: 0, scope: !22)<br><br>Added: llvm/trunk/test/Verifier/callsite-dbgloc.ll<br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/callsite-dbgloc.ll?rev=267370&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/callsite-dbgloc.ll?rev=267370&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Verifier/callsite-dbgloc.ll (added)<br>+++ llvm/trunk/test/Verifier/callsite-dbgloc.ll Sun Apr 24 17:23:13 2016<br>@@ -0,0 +1,62 @@<br>+; RUN: not llvm-as %s -o %t 2>&1 | FileCheck %s<br>+; Created and then edited from<br></blockquote><div><br></div><div>It'd be good to describe the required edits here? (so that if someone is trying to regenerate or otherwise understand this test they know what to look for)</div><div><br></div></div></div></blockquote><div><br></div></div></div><div>I did, next to the CHECK :-)</div></div></div></blockquote><div><br></div><div>Ah, thanks for pointing it out - not sure if many of the debug info test cases interleave the CHECK lines inside the IR, generally, so I didn't spot it there.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class=""><br><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">+; Function Attrs: nounwind ssp uwtable<br>+define void @g() #0 !dbg !11 {<br>+entry:<br>+; Manually removed !dbg.<br>+; CHECK: inlinable function call in a function with debug info must have a !dbg location<br>+  call void @h()<br>+  ret void, !dbg !13<br>+}<br>+<br></blockquote></div></div></blockquote></span></div><br></div></blockquote></div><br></div></div>