https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69254

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
With __builtin_omp_get_num_threads (); in the body instead and -fopenmp instead
of -fsanitize=shift it works, so there must be some lto-opts.c or whatever
magic that makes that work for other options.
Now, for the sanitizers, what we need to arrange (but not sure how to do that
exactly) is for the builtins that if any of the source files being read had
non-zero:
              (flag_sanitize & (SANITIZE_ADDRESS | SANITIZE_THREAD \
                                | SANITIZE_UNDEFINED | SANITIZE_NONDEFAULT) \
               || flag_sanitize_coverage))
then the sanitizer builtins will be also enabled for LTO (either by arranging
the options so that the condition matches, or by calling
initialize_sanitizer_builtins), and also that the sanopt pass will be run.
ubsan is special in that the various instrumentations happen at various passes,
some happen at various stages, some instrumentation is done in the FEs, some is
done during genericization or gimplification, others in the ubsan pass, and yet
others even later (e.g. __builtin_unreachable instrumentation).
Unlike that, address or thread sanitization are always done post-IPA.
Thus, perhaps best would be if lto-opts.c or whatever arranged that if any of
the input sources had
flag_sanitize & (SANITIZE_UNDEFINED | SANITIZE_NONDEFAULT)
then flag_sanitize |= SANITIZE_SHIFT (as an example of FE only handled
sanitization), this would cause both the builtins being available and the
sanopt pass be performed, but nothing else.

Also, makes me wonder what happens (if the inliner allows that) to inline ubsan
sanitized function into no_sanitize_undefined function, whether that won't
leave some partly but not fully lowered ubsan stuff in there.

CCing Honza/Richard on the LTO options handling stuff, and Marek because this
is ubsan stuff.

Reply via email to