This is the mail archive of the
mailing list for the GCC project.
Re: How to avoid constant propagation into functions?
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Alexander Monakov <amonakov at ispras dot ru>, Jan Hubicka <hubicka at ucw dot cz>
- Cc: Florian Weimer <fw at deneb dot enyo dot de>, Segher Boessenkool <segher at kernel dot crashing dot org>, Georg-Johann Lay <avr at gjlay dot de>, Tim Prince <n8tm at aol dot com>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Fri, 9 Dec 2016 09:41:25 +0100
- Subject: Re: How to avoid constant propagation into functions?
- Authentication-results: sourceware.org; auth=none
- References: <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <20161207121400.GM2767@gate.crashing.org> <email@example.com> <20161207124232.GN2767@gate.crashing.org> <alpine.LNX.firstname.lastname@example.org> <email@example.com> <AF361A33-8414-48A0-81E2-3D391D38FFA8@gmail.com> <alpine.LNX.firstname.lastname@example.org>
On Wed, Dec 7, 2016 at 7:04 PM, Alexander Monakov <email@example.com> wrote:
> On Wed, 7 Dec 2016, Richard Biener wrote:
>> >Agreed, that's what I've been using in the past for glibc test cases.
>> >If that doesn't work, we'll need something else. Separate compilation
>> >of test cases just to thwart compiler optimizations is a significant
>> >burden, and will stop working once we have LTO anyway.
>> >What about making the function definitions weak? Would that be more
>> Adding attribute((used)) should do the trick. It introduces unknown callers and thus without cloning disables IPA.
> Hm, depending on the case I think this may be not enough: it thwarts IPA on the
> callee side, but still allows the compiler to optimize the caller: for example,
> deduce that callee is pure/const (in which case optimizations in the caller may
> cause it to be called fewer times than intended or never at all), apply IPA-RA, or
> (perhaps in future) deduce that the callee always returns non-NULL and optimize
> the caller accordingly. I think attribute-weak works to suppress IPA on the
> caller side, but that is not a good solution because it also has an effect on
> linking semantics, may be not available on non-ELF platforms, etc.
Right, 'used' thwarts IPA on the callee side only. noclone and
noinline are attributes
affecting the caller side but we indeed miss attributes for the
properties you mention
above. I suppose adding a catch-all attribute for caller side effects
(like we have 'used'
for the callee side) would be a good idea.