<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 31, 2017 at 1:50 PM Kostya Serebryany <<a href="mailto:kcc@google.com">kcc@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 31, 2017 at 1:46 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><span class="m_-3257782158604647418gmail-"><div dir="ltr">On Mon, Jul 31, 2017 at 1:01 PM Kostya Serebryany via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: kcc<br>
Date: Mon Jul 31 13:00:22 2017<br>
New Revision: 309611<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=309611&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=309611&view=rev</a><br>
Log:<br>
[sanitizer-coverage] don't instrument available_externally functions<br></blockquote></span><div><br>I take it this happens long after inlining, etc? </div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Correct. this happens at the later stages of LLVM transformations. </div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>(usually I'd expect various sanitizer instrumentation to happen early</div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>It depends. </div><div>ubsan happens in frontend, because there is where we have all the C++-cpecific data. </div><div>asan/msan/tsan happen late in LLVM pipeline, because by that time all loads/stores that could have been optimized -- are. </div><div>sanitizer coverage happens right before asan/msan/tsan</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> - so it could be inlined & still tracked, etc (eg: you'd want to know you had function coverage at one inlined site rather than believing there was no coverage at all) </div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Sanitizer coverage is *mostly* used for automated tools like fuzzers, and so visualization of coverage is of a less concern (still is, but that's a trade-off)</div></div></div></div></blockquote><div><br></div><div>Ah, makes sense - thanks for the context!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>- so it surprises me that you wouldn't want to instrument available_externally functions so that when they were inlined the inlined version would be appropriately instrumented too)<br> </div><div><div class="m_-3257782158604647418gmail-h5"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp<br>
    llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll<br>
<br>
Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=309611&r1=309610&r2=309611&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=309611&r1=309610&r2=309611&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Mon Jul 31 13:00:22 2017<br>
@@ -418,6 +418,9 @@ bool SanitizerCoverageModule::runOnFunct<br>
     return false; // Should not instrument sanitizer init functions.<br>
   if (F.getName().startswith("__sanitizer_"))<br>
     return false;  // Don't instrument __sanitizer_* callbacks.<br>
+  // Don't touch available_externally functions, their actual body is elewhere.<br>
+  if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage)<br>
+    return false;<br>
   // Don't instrument MSVC CRT configuration helpers. They may run before normal<br>
   // initialization.<br>
   if (F.getName() == "__local_stdio_printf_options" ||<br>
<br>
Modified: llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll?rev=309611&r1=309610&r2=309611&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll?rev=309611&r1=309610&r2=309611&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll (original)<br>
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll Mon Jul 31 13:00:22 2017<br>
@@ -18,6 +18,12 @@ entry:<br>
   ret void<br>
 }<br>
<br>
+define available_externally void @external_bar(i32* %a) sanitize_address {<br>
+entry:<br>
+  ret void<br>
+}<br>
+<br>
+<br>
 ; CHECK_PC-LABEL: define void @foo<br>
 ; CHECK_PC: call void @__sanitizer_cov_trace_pc<br>
 ; CHECK_PC: call void @__sanitizer_cov_trace_pc<br>
@@ -33,6 +39,10 @@ entry:<br>
 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard<br>
 ; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc<br>
 ; CHECK_PC_GUARD: ret void<br>
+; CHECK_PC_GUARD-LABEL: @external_bar<br>
+; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc<br>
+; CHECK_PC_GUARD: ret void<br>
+<br>
 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard_init(i32* bitcast (i32** @__start___sancov_guards to i32*), i32* bitcast (i32** @__stop___sancov_guards to i32*))<br>
<br>
 ; CHECK_PC_GUARD_DARWIN-LABEL: define void @foo<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div></div>
</blockquote></div></div></div></blockquote></div></div>