On Thu, 31 Jan 2019, Jakub Jelinek wrote: > Hi! > > As mentioned in the PR, we refuse to inline with -fsanitize=address > no_sanitize_address functions into functions without that attribute, > which is good and has been requested in PR59600. > We also refuse to inline functions without that attribute into > no_sanitize_address functions, which is ok if it is optimization matter > only, we will just address sanitize the callee and not the caller. > But if such callee has always_inline attribute, this causes errors, and > e.g. means one can't use target intrinsics in functions with > no_sanitize_address attribute, as we refuse to inline any of those. > > The following patch allows inlining always_inline functions in that > situation, the end result is that both the caller and callee which becomes > one function will not be sanitized (still errors if always_inline, > no_sanitize_address is being inlined into normal function, that is just user > error). > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK. Richard. > 2019-01-30 Jakub Jelinek <ja...@redhat.com> > > PR sanitizer/89124 > * ipa-inline.c (sanitize_attrs_match_for_inline_p): Allow inlining > always_inline callees into no_sanitize_address callers. > > * c-c++-common/asan/pr89124.c: New test. > > --- gcc/ipa-inline.c.jj 2019-01-10 11:43:08.956466913 +0100 > +++ gcc/ipa-inline.c 2019-01-30 22:21:57.319026848 +0100 > @@ -264,6 +264,12 @@ sanitize_attrs_match_for_inline_p (const > if (!caller || !callee) > return true; > > + /* Allow inlining always_inline functions into no_sanitize_address > + functions. */ > + if (!sanitize_flags_p (SANITIZE_ADDRESS, caller) > + && lookup_attribute ("always_inline", DECL_ATTRIBUTES (callee))) > + return true; > + > return ((sanitize_flags_p (SANITIZE_ADDRESS, caller) > == sanitize_flags_p (SANITIZE_ADDRESS, callee)) > && (sanitize_flags_p (SANITIZE_POINTER_COMPARE, caller) > --- gcc/testsuite/c-c++-common/asan/pr89124.c.jj 2019-01-30 > 22:23:27.018546142 +0100 > +++ gcc/testsuite/c-c++-common/asan/pr89124.c 2019-01-30 22:23:05.568900221 > +0100 > @@ -0,0 +1,14 @@ > +/* PR sanitizer/89124 */ > +/* { dg-do compile } */ > + > +static int inline __attribute__ ((always_inline)) > +foo (int x) > +{ > + return x + 1; > +} > + > +__attribute__ ((no_sanitize_address)) int > +bar (int x) > +{ > + return foo (x); > +} > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)