<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 28, 2016 at 1:11 PM, 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 28, 2016, at 12:53 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 28, 2016 at 12:50 PM, 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><blockquote type="cite"><div>On Apr 28, 2016, at 12:34 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><div dir="ltr">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><br></div></span><div>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><br></div><div>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></div></span><div>Ah yes, I guess we could be using the cleanup location of the function for this.</div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><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> 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><br></div><div>I'm not quite sure what the ramifications of that would be/why that would be bad (or good) - could you explain further?<br></div></div></div></div></div></blockquote><div><br></div></span><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></div></blockquote><div><br></div><div>Sorry, I meant specifically what would be the impact of giving it the non-artificial location (the same as the location of the cleanup code, as you noted), not the impact of not giving it a location at all.</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>- 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></div></blockquote><div><br></div><div>Much like the non-trivial dtor, just because the user didn't explicitly write the function call doesn't seem to me to mean it should be invisible.<br><br>The profiling argument sort of makes sense to me - but it's going to be attributed to /something/, right? (& wait - aren't these functions the profiling mechanisms themselves for counter based (rather than sample based) profiling? Do people sample /and/ counter profile the same binary?)<br><br>- Dave</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="HOEnZb"><font color="#888888"><div><br></div><div>-- adrian</div></font></span><div><div class="h5"><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>- Dave</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><font color="#888888"><div><br></div><div>-- adrian</div></font></span><div><div><br><blockquote type="cite"><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 28, 2016 at 10:21 AM, Adrian Prantl via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Thu Apr 28 12:21:56 2016<br>
New Revision: 267904<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=267904&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=267904&view=rev</a><br>
Log:<br>
Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.<br>
The LLVM Verifier expects all inlinable calls in debuggable functions to<br>
have a location.<br>
<br>
<a>rdar://problem/25818489</a><br>
<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br>
    cfe/trunk/test/CodeGen/instrument-functions.c<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br>
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">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904&r1=267903&r2=267904&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Apr 28 12:21:56 2016<br>
@@ -401,6 +401,7 @@ bool CodeGenFunction::ShouldInstrumentFu<br>
 /// instrumentation function with the current function and the call site, if<br>
 /// function instrumentation is enabled.<br>
 void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {<br>
+  auto NL = ApplyDebugLocation::CreateArtificial(*this);<br>
   // void __cyg_profile_func_{enter,exit} (void *this_fn, void *call_site);<br>
   llvm::PointerType *PointerTy = Int8PtrTy;<br>
   llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy };<br>
<br>
Modified: cfe/trunk/test/CodeGen/instrument-functions.c<br>
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">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/instrument-functions.c?rev=267904&r1=267903&r2=267904&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGen/instrument-functions.c (original)<br>
+++ cfe/trunk/test/CodeGen/instrument-functions.c Thu Apr 28 12:21:56 2016<br>
@@ -1,9 +1,9 @@<br>
-// RUN: %clang_cc1 -S -emit-llvm -o - %s -finstrument-functions | FileCheck %s<br>
+// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions | FileCheck %s<br>
<br>
 // CHECK: @test1<br>
 int test1(int x) {<br>
-// CHECK: __cyg_profile_func_enter<br>
-// CHECK: __cyg_profile_func_exit<br>
+// CHECK: call void @__cyg_profile_func_enter({{.*}}, !dbg<br>
+// CHECK: call void @__cyg_profile_func_exit({{.*}}, !dbg<br>
 // CHECK: ret<br>
   return x;<br>
 }<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div></blockquote></div></div></div><br></div></blockquote></div><br></div></div>
</div></blockquote></div></div></div><br></div></blockquote></div><br></div></div>