This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to avoid constant propagation into functions?
- From: Alexander Monakov <amonakov at ispras dot ru>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, 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 16:12:37 +0300 (MSK)
- Subject: Re: How to avoid constant propagation into functions?
- Authentication-results: sourceware.org; auth=none
- References: <nvi02s93wk5vagpi308y18xq.1480955596148@email.android.com> <2a24da63-8776-2f69-283a-cd11e63d7241@gjlay.de> <ab1d7722-ba83-5ddc-de7a-631e3ea971ee@gjlay.de> <20161207121400.GM2767@gate.crashing.org> <a9965b35-2dff-6d95-d95b-2f1720b53383@gjlay.de> <20161207124232.GN2767@gate.crashing.org> <alpine.LNX.2.20.13.1612071558360.19597@monopod.intra.ispras.ru> <87inqv4pk3.fsf@mid.deneb.enyo.de> <AF361A33-8414-48A0-81E2-3D391D38FFA8@gmail.com> <alpine.LNX.2.20.13.1612072051270.19597@monopod.intra.ispras.ru> <CAFiYyc1zU5ub=7_VBGo9zWQBmKHXcMKKLctbt8UFstzW3C_DgA@mail.gmail.com>
On Fri, 9 Dec 2016, Richard Biener wrote:
> 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.
For general uses, i.e. for testcases that ought to be portable across different
compilers, I believe making a call through a volatile pointer already places a
sufficient compiler barrier to prevent both caller- and callee-side analysis.
That is, where you have
int foo(int);
foo(arg);
you could transform it to
int foo(int);
int (* volatile vpfoo)(int) = foo;
vpfoo(arg);
While this also has an effect of forcing the call to be indirect, I think
usually that should be acceptable.
But for uses in the gcc testsuite, I believe an attribute is still needed.
Alexander