tsan: Add param to disable func-entry-exit instrumentation
authorMarco Elver <elver@google.com>
Wed, 10 Jun 2020 14:21:21 +0000 (16:21 +0200)
committerMarco Elver <elver@google.com>
Fri, 12 Jun 2020 15:29:45 +0000 (17:29 +0200)
commit06712fc68dc9843d9af7c7ac10047f49d305ad76
treee8c4e992fbe0a21e10eee6da02bc143cfcdfbe4b
parent1432bc368121eed511a0a004f2e21d89ceaf14ad
tsan: Add param to disable func-entry-exit instrumentation

Adds param tsan-instrument-func-entry-exit, which controls if
__tsan_func_{entry,exit} calls should be emitted or not. The default
behaviour is to emit the calls.

This may be required by alternative race detection runtimes. One such
runtime is the Kernel Concurrency Sanitizer (KCSAN):

https://github.com/google/ktsan/wiki/KCSAN

After this change, GCC should satisfy all requirements for KCSAN:

https://lore.kernel.org/lkml/20200515150338.190344-7-elver@google.com/

gcc/ChangeLog:

* gimplify.c (gimplify_function_tree): Optimize and do not emit
IFN_TSAN_FUNC_EXIT in a finally block if we do not need it.
* params.opt: Add --param=tsan-instrument-func-entry-exit=.
* tsan.c (instrument_memory_accesses): Make
fentry_exit_instrument bool depend on new param.

gcc/testsuite/ChangeLog:

* c-c++-common/tsan/func_entry_exit.c: New test.
* c-c++-common/tsan/func_entry_exit_disabled.c: New test.
gcc/gimplify.c
gcc/params.opt
gcc/testsuite/c-c++-common/tsan/func_entry_exit.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/tsan/func_entry_exit_disabled.c [new file with mode: 0644]
gcc/tsan.c