[llvm] r309611 - [sanitizer-coverage] don't instrument available_externally functions

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 13:50:20 PDT 2017


On Mon, Jul 31, 2017 at 1:46 PM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
> On Mon, Jul 31, 2017 at 1:01 PM Kostya Serebryany via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: kcc
>> Date: Mon Jul 31 13:00:22 2017
>> New Revision: 309611
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=309611&view=rev
>> Log:
>> [sanitizer-coverage] don't instrument available_externally functions
>>
>
> I take it this happens long after inlining, etc?
>

Correct. this happens at the later stages of LLVM transformations.


> (usually I'd expect various sanitizer instrumentation to happen early
>

It depends.
ubsan happens in frontend, because there is where we have all the
C++-cpecific data.
asan/msan/tsan happen late in LLVM pipeline, because by that time all
loads/stores that could have been optimized -- are.
sanitizer coverage happens right before asan/msan/tsan


> - 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)
>

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)


> - 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)
>
>
>>
>> Modified:
>>     llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
>>     llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll
>>
>> Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
>> Transforms/Instrumentation/SanitizerCoverage.cpp?rev=
>> 309611&r1=309610&r2=309611&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
>> (original)
>> +++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Mon
>> Jul 31 13:00:22 2017
>> @@ -418,6 +418,9 @@ bool SanitizerCoverageModule::runOnFunct
>>      return false; // Should not instrument sanitizer init functions.
>>    if (F.getName().startswith("__sanitizer_"))
>>      return false;  // Don't instrument __sanitizer_* callbacks.
>> +  // Don't touch available_externally functions, their actual body is
>> elewhere.
>> +  if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage)
>> +    return false;
>>    // Don't instrument MSVC CRT configuration helpers. They may run
>> before normal
>>    // initialization.
>>    if (F.getName() == "__local_stdio_printf_options" ||
>>
>> Modified: llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/
>> SanitizerCoverage/tracing.ll?rev=309611&r1=309610&r2=309611&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll
>> (original)
>> +++ llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll Mon Jul
>> 31 13:00:22 2017
>> @@ -18,6 +18,12 @@ entry:
>>    ret void
>>  }
>>
>> +define available_externally void @external_bar(i32* %a) sanitize_address
>> {
>> +entry:
>> +  ret void
>> +}
>> +
>> +
>>  ; CHECK_PC-LABEL: define void @foo
>>  ; CHECK_PC: call void @__sanitizer_cov_trace_pc
>>  ; CHECK_PC: call void @__sanitizer_cov_trace_pc
>> @@ -33,6 +39,10 @@ entry:
>>  ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
>>  ; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc
>>  ; CHECK_PC_GUARD: ret void
>> +; CHECK_PC_GUARD-LABEL: @external_bar
>> +; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc
>> +; CHECK_PC_GUARD: ret void
>> +
>>  ; 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*))
>>
>>  ; CHECK_PC_GUARD_DARWIN-LABEL: define void @foo
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170731/64bddada/attachment.html>


More information about the llvm-commits mailing list