<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 25, 2016, at 10:33 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Sun, Apr 24, 2016 at 3:23 PM, Adrian Prantl via llvm-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><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 class="">Date: Sun Apr 24 17:23:13 2016<br class="">New Revision: 267370<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=267370&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=267370&view=rev</a><br class="">Log:<br class="">Verifier: Verify that each inlinable callsite of a debug-info-bearing function<br class="">in a debug-info-bearing function has a debug location attached to it. Failure to<br class="">do so causes an "!dbg attachment points at wrong subprogram for function"<br class="">assertion failure when the inliner sets up inline scope info.<br class=""></blockquote><div class=""><br class=""></div><div class="">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 class=""><br class="">  void f1();<br class="">  inline __attribute__((alwaysinline)) void f2() { f1(); }<br class="">  inline __attribute__((alwaysinline)) void f3() { f2(); } // make this nodebug or equivalent<br class="">  void f4() { f3(); } // if f3 has no debugloc<br class=""><br class=""></div><div class="">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 class=""></div></div></div></blockquote><div><br class=""></div><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><br class=""></div><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><br class="">- Dave<br class=""><br class=""></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 class=""><a href="rdar://problem/25878916" class="">rdar://problem/25878916</a><br class=""><br class="">This reaplies r267320 without changes after fixing an issue in the OpenMP IR<br class="">generator in clang.<br class=""><br class="">Added:<br class="">   <span class="Apple-converted-space"> </span>llvm/trunk/test/Verifier/callsite-dbgloc.ll<br class="">Modified:<br class="">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/IR/Verifier.cpp<br class="">   <span class="Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll<br class="">   <span class="Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll<br class=""><br class="">Modified: llvm/trunk/lib/IR/Verifier.cpp<br class="">URL:<span class="Apple-converted-space"> </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" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=267370&r1=267369&r2=267370&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/IR/Verifier.cpp (original)<br class="">+++ llvm/trunk/lib/IR/Verifier.cpp Sun Apr 24 17:23:13 2016<br class="">@@ -2579,6 +2579,15 @@ void Verifier::verifyCallSite(CallSite C<br class="">     }<br class="">   }<br class=""><br class="">+  // Verify that each inlinable callsite of a debug-info-bearing function in a<br class="">+  // debug-info-bearing function has a debug location attached to it. Failure to<br class="">+  // do so causes assertion failures when the inliner sets up inline scope info.<br class="">+  if (I->getFunction()->getSubprogram() && CS.getCalledFunction() &&<br class="">+      CS.getCalledFunction()->getSubprogram())<br class="">+    Assert(I->getDebugLoc(), "inlinable function call in a function with debug "<br class="">+                             "info must have a !dbg location",<br class="">+           I);<br class="">+<br class="">   visitInstruction(*I);<br class=""> }<br class=""><br class=""><br class="">Modified: llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll<br class="">URL:<span class="Apple-converted-space"> </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" class="">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 class="">==============================================================================<br class="">--- llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll (original)<br class="">+++ llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll Sun Apr 24 17:23:13 2016<br class="">@@ -18,7 +18,7 @@ define void @foo() !dbg !4 {<br class=""><br class=""> define void @bar() personality i8* bitcast (void ()* @foo to i8*) !dbg !9 {<br class="">   invoke void @foo()<br class="">-          to label %invoke.cont unwind label %lpad<br class="">+          to label %invoke.cont unwind label %lpad, !dbg !19<br class=""><br class=""> invoke.cont:                                      ; preds = %0<br class="">   ret void<br class="">@@ -50,3 +50,4 @@ lpad:<br class=""> !16 = !DISubrange(count: 1)<br class=""> !17 = !{i32 2, !"Dwarf Version", i32 4}<br class=""> !18 = !{i32 2, !"Debug Info Version", i32 3}<br class="">+!19 = !DILocation(line: 0, scope: !9)<br class=""><br class="">Modified: llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll<br class="">URL:<span class="Apple-converted-space"> </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" class="">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 class="">==============================================================================<br class="">--- llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll (original)<br class="">+++ llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll Sun Apr 24 17:23:13 2016<br class="">@@ -54,7 +54,7 @@ entry:<br class="">   store %class.A* %this, %class.A** %this.addr, align 8<br class="">   call void @llvm.dbg.declare(metadata %class.A** %this.addr, metadata !43, metadata !DIExpression()), !dbg !44<br class="">   %this1 = load %class.A*, %class.A** %this.addr<br class="">-  call void @_ZN1AD2Ev(%class.A* %this1)<br class="">+  call void @_ZN1AD2Ev(%class.A* %this1), !dbg !53<br class="">   ret void, !dbg !45<br class=""> }<br class=""><br class="">@@ -124,3 +124,4 @@ entry:<br class=""> !49 = distinct !DILexicalBlock(line: 2, column: 52, file: !51, scope: !25)<br class=""> !51 = !DIFile(filename: "a.cc", directory: "/private/tmp")<br class=""> !52 = !{i32 1, !"Debug Info Version", i32 3}<br class="">+!53 = !DILocation(line: 0, scope: !22)<br class=""><br class="">Added: llvm/trunk/test/Verifier/callsite-dbgloc.ll<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/callsite-dbgloc.ll?rev=267370&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/callsite-dbgloc.ll?rev=267370&view=auto</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/Verifier/callsite-dbgloc.ll (added)<br class="">+++ llvm/trunk/test/Verifier/callsite-dbgloc.ll Sun Apr 24 17:23:13 2016<br class="">@@ -0,0 +1,62 @@<br class="">+; RUN: not llvm-as %s -o %t 2>&1 | FileCheck %s<br class="">+; Created and then edited from<br class=""></blockquote><div class=""><br class=""></div><div class="">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 class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div>I did, next to the CHECK :-)</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 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 class="">+define void @g() #0 !dbg !11 {<br class="">+entry:<br class="">+; Manually removed !dbg.<br class="">+; CHECK: inlinable function call in a function with debug info must have a !dbg location<br class="">+  call void @h()<br class="">+  ret void, !dbg !13<br class="">+}<br class="">+<br class=""></blockquote></div></div></blockquote></div><br class=""></body></html>