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

--- Comment #10 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 14 Jan 2016, jakub at gcc dot gnu.org wrote:

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

As all the -fsanitize stuff is not suitable for the optimize attribute
we need to arrange for some "sanity" across input TUs and properly
compute a link-time sensible value (if possible).  This is usually
done in lto-wrapper.c merge_and_complain.  lto-opts.c should already
stream the input TU flags into the LTO_opts section.

You probably know better what sanitize options can be combined
in which way and what link flag setting is required, thus leaving
to you or Marek to figure out what to do in lto-wrapper.

Reply via email to