This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] doc: discourage use of __attribute__((optimize())) in production code
- From: Trevor Saunders <tbsaunde at tbsaunde dot org>
- To: Markus Trippelsdorf <markus at trippelsdorf dot de>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Andi Kleen <andi at firstfloor dot org>, Gerald Pfeifer <gerald at pfeifer dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 14 Dec 2015 13:57:02 -0500
- Subject: Re: [PATCH] doc: discourage use of __attribute__((optimize())) in production code
- Authentication-results: sourceware.org; auth=none
- References: <20151213081911 dot GA320 at x4> <87mvtet8t6 dot fsf at tassilo dot jf dot intel dot com> <CAFiYyc25Q7kMkjvbTfgBqUELyw4mop6ysT7aAJAz2NruV7sa2w at mail dot gmail dot com> <20151214161453 dot GA16122 at tsaunders-iceball dot corp dot tor1 dot mozilla dot com> <20151214164057 dot GD1409 at x4>
On Mon, Dec 14, 2015 at 05:40:57PM +0100, Markus Trippelsdorf wrote:
> On 2015.12.14 at 11:20 -0500, Trevor Saunders wrote:
> > On Mon, Dec 14, 2015 at 10:01:27AM +0100, Richard Biener wrote:
> > > On Sun, Dec 13, 2015 at 9:03 PM, Andi Kleen <andi@firstfloor.org> wrote:
> > > > Markus Trippelsdorf <markus@trippelsdorf.de> writes:
> > > >
> > > >> Many developers are still using __attribute__((optimize())) in
> > > >> production code, although it quite broken.
> > > >
> > > > Wo reads documentation? @) If you want to discourage it better warn once
> > > > at runtime.
> > >
> > > We're also quite heavily using it in LTO internally now.
> >
> > besides that does this really make sense? I suspect very few people are
> > using this for the fun of it. I'd guess most usage is to disable
> > optimizations to work around bugs, or maybe trying to get a very hot
> > function optimized more. Either way I suspect its only used by people
> > with good reason and this would just really iritate them.
>
> Well, if you look at bugzilla you'll find several wrong code bugs caused
> by this attribute, e.g.: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59262
is that wrong code? it looks to me like somebody thinks its missed
optimization, and personally I'd say its not a bug just not fully
expected behavior.
> Also Richi stated in the past (I quote):
> »I consider the optimize attribute code seriously broken and
> unmaintained (but sometimes useful for debugging - and only that).«
>
> https://gcc.gnu.org/ml/gcc/2012-07/msg00201.html
I'm certainly not recommending its use, and noting in docs that its
results can be suprising seems reasonable, but runtime warnings seems
likely to annoy users.
Trev
>
> --
> Markus