<div dir="ltr"><br><br><div class="gmail_quote"><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">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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><div><br>I take it this happens long after inlining, etc? (usually I'd expect various sanitizer instrumentation to happen early - 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) - 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><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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>