Comments

On Thu, Nov 22, 2012 at 09:08:23AM +0100, Jakub Jelinek wrote:
> On Thu, Nov 22, 2012 at 11:29:05AM +0400, Dmitry Vyukov wrote:> > +static bool> > +tsan_gate (void)> > +{> > + return flag_tsan != 0> > + && builtin_decl_implicit_p (BUILT_IN_TSAN_INIT);> > > > > > What does it mean? Why builtin_decl_implicit_p (BUILT_IN_TSAN_INIT)?> > It is a temporary workaround, I'll handle it when the patch goes in.> The thing is that while the C/C++ family of FEs will create all the builtins> just because they are included in builtins.def, other FEs won't.> So we need some routine that will build the builtins if the FEs didn't> initialize them.
Like so. The c-family/ FEs (C/ObjC/C++/ObjC++) will initialize the builtins
themselves automatically, for other FEs that don't there is a new routine
that initializes them the first time they are needed.
Ok for trunk (the patch is on top of the tsan patch)?
2012-11-22 Jakub Jelinek <jakub@redhat.com>
* sanitizer.def: Add Address Sanitizer builtins.
Rename BUILT_IN_TSAN_READ_* to BUILT_IN_TSAN_READ* and
BUILT_IN_TSAN_WRITE_* to BUILT_IN_TSAN_WRITE*.
* Makefile.in (asan.o): Depend on langhooks.h.
(tsan.o): Depend on asan.h.
* asan.h (initialize_sanitizer_builtins): New prototype.
* asan.c: Include langhooks.h.
(report_error_func): Use builtin_decl_implicit of corresponding
BUILT_IN_ASAN_REPORT_{LOAD,STORE}*.
(asan_init_func): Removed.
(initialize_sanitizer_builtins): New function.
(asan_finish_file): Call it. Use builtin_decl_implicit
on BUILT_IN_ASAN_{INIT,{,UN}REGISTER_GLOBALS}.
(asan_instrument): Call initialize_sanitizer_builtins.
* builtins.def (DEF_SANITIZER_BUILTIN): Change condition to
(flag_asan || flag_tsan).
* tsan.c: Include asan.h and tsan.h.
(get_memory_access_decl): Rename BUILT_IN_TSAN_{READ,WRITE}_*
to BUILT_IN_TSAN_{READ,WRITE}*.
(tsan_pass): Call initialize_sanitizer_builtins.
(tsan_gate, tsan_gate_O0): Don't check if
builtin_decl_implicit_p (BUILT_IN_TSAN_INIT) is true.
(tsan_finish_file): Call initialize_sanitizer_builtins.
* builtin-types.def (BT_FN_VOID_PTR_PTRMODE): New fn type.
Jakub