<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></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 28, 2016, at 12:53 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Apr 28, 2016 at 12:50 PM, Adrian Prantl <span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Apr 28, 2016, at 12:34 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">Should these have no/artificial location? It seems like perhaps they should have the same location as the scope they're for? (well, the beginning or end of that scope, respectively, etc)</div></div></blockquote><div class=""><br class=""></div></span><div class="">While there is usually a single source location for the beginning of the function, there can be more than one such location for the end of the function, so I don’t think this is generally possible.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Seems to me like it would be - declare a variable with a non-trivial dtor at the start of the function. Whichever line the dtor call is attributed to, that's the end of the function. (I think we use the } for this, or perhaps the final return statement if there is one and only one - I forget the specifics)</div></div></div></div></div></blockquote><div><br class=""></div><div>Ah yes, I guess we could be using the cleanup location of the function for this.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </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" class=""><div class=""><div class=""> The artificial location unambiguously marks the function call as something that does not appear in source code. For a (terrible) example (given the nature of these function calls :-p) if you look at a profile you wouldn’t want these function calls to be misattributed to any line in the source code.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I'm not quite sure what the ramifications of that would be/why that would be bad (or good) - could you explain further?<br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>If the compiler generates code that does not have any meaningful source location (in this case one could argue that ‘{‘ and ‘}’ might be meaningful source locations?) then I wouldn’t want that code to be attributed to a source location just because the instructions immediately follow some completely unrelated instructions that happen to have a source location.</div><div>- Profiling: It shouldn't show up in a profile counted towards the source location of the instructions before it.</div><div>- Debugging: Since there is no source code for it a source-based debugger (you can still switch to disassembly) should treat the function call as transparent and skip over it as if it didn’t exist.</div><div><br class=""></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class="">- Dave</div><div class=""> </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" class=""><div class=""><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- adrian</div></font></span><div class=""><div class="h5"><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Apr 28, 2016 at 10:21 AM, Adrian Prantl via cfe-commits <span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br class="">
Date: Thu Apr 28 12:21:56 2016<br class="">
New Revision: 267904<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=267904&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=267904&view=rev</a><br class="">
Log:<br class="">
Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.<br class="">
The LLVM Verifier expects all inlinable calls in debuggable functions to<br class="">
have a location.<br class="">
<br class="">
<a class="">rdar://problem/25818489</a><br class="">
<br class="">
Modified:<br class="">
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br class="">
    cfe/trunk/test/CodeGen/instrument-functions.c<br class="">
<br class="">
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904&r1=267903&r2=267904&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904&r1=267903&r2=267904&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)<br class="">
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Apr 28 12:21:56 2016<br class="">
@@ -401,6 +401,7 @@ bool CodeGenFunction::ShouldInstrumentFu<br class="">
 /// instrumentation function with the current function and the call site, if<br class="">
 /// function instrumentation is enabled.<br class="">
 void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {<br class="">
+  auto NL = ApplyDebugLocation::CreateArtificial(*this);<br class="">
   // void __cyg_profile_func_{enter,exit} (void *this_fn, void *call_site);<br class="">
   llvm::PointerType *PointerTy = Int8PtrTy;<br class="">
   llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy };<br class="">
<br class="">
Modified: cfe/trunk/test/CodeGen/instrument-functions.c<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/instrument-functions.c?rev=267904&r1=267903&r2=267904&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/instrument-functions.c?rev=267904&r1=267903&r2=267904&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/test/CodeGen/instrument-functions.c (original)<br class="">
+++ cfe/trunk/test/CodeGen/instrument-functions.c Thu Apr 28 12:21:56 2016<br class="">
@@ -1,9 +1,9 @@<br class="">
-// RUN: %clang_cc1 -S -emit-llvm -o - %s -finstrument-functions | FileCheck %s<br class="">
+// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions | FileCheck %s<br class="">
<br class="">
 // CHECK: @test1<br class="">
 int test1(int x) {<br class="">
-// CHECK: __cyg_profile_func_enter<br class="">
-// CHECK: __cyg_profile_func_exit<br class="">
+// CHECK: call void @__cyg_profile_func_enter({{.*}}, !dbg<br class="">
+// CHECK: call void @__cyg_profile_func_exit({{.*}}, !dbg<br class="">
 // CHECK: ret<br class="">
   return x;<br class="">
 }<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
cfe-commits mailing list<br class="">
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div></div></div><br class=""></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>