<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 4:31 PM, 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 Thu, Apr 28, 2016 at 1:11 PM, Adrian Prantl<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</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;"><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:53 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=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Apr 28, 2016 at 12:50 PM, Adrian Prantl<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</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;"><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 class=""><br class=""></div></span><div class="">Ah yes, I guess we could be using the cleanup location of the function for this.</div><span class=""><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: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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 class=""><br class=""></div></span><div class="">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 class=""><br class=""></div><div class="">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 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;"><div style="word-wrap: break-word;" class=""><div class=""><div class="">- Profiling: It shouldn't show up in a profile counted towards the source location of the instructions before it.</div><div class="">- 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 class=""><br class=""></div><div class="">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 class=""></div></div></div></blockquote><div><br class=""></div><div>The user may not have written the call to the dtor, but the user did at least write the dtor itself; and there exists source code for it.</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="">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?</div></div></div></blockquote><div><br class=""></div><div>Yes they are, that’s why I said at the beginning that this example was a terrible one :-)</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;"><div class=""> Do people sample /and/ counter profile the same binary?)<br class=""></div></div></div></blockquote><div><br class=""></div><div>Hopefully not. This was really just meant as an example why someone would choose an artificial location over a concrete one in similar situations. In the end, I’m not particularly attached to using the artificial location here, but these were the reasons that made me opt for an artificial location here.</div><div><br class=""></div><div>-- adrian</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;"><div class=""><br class="">- Dave</div><div 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;"><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 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: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- adrian</div></font></span><div class=""><div class=""><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 class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-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: Thu Apr 28 12:21:56 2016<br class="">New Revision: 267904<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><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="">   <span class="Apple-converted-space"> </span>cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br class="">   <span class="Apple-converted-space"> </span>cfe/trunk/test/CodeGen/instrument-functions.c<br class=""><br class="">Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br class="">URL:<span class="Apple-converted-space"> </span><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:<span class="Apple-converted-space"> </span><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></blockquote></div></div></div></blockquote></div></div></div></div></blockquote></div></div></div></div></blockquote></div></div></div></div></blockquote></div></div></blockquote></div><br class=""></body></html>