This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: When did 'pragma optimize' become available?
- From: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: Jeffrey Walton <noloader at gmail dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 16 Jul 2015 07:46:07 +0200
- Subject: Re: When did 'pragma optimize' become available?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8=UZqiqFce0sM7SDUh7E2Ru8LmfxdyBwFCosj5bcTiGjg at mail dot gmail dot com> <20150713071446 dot GA393 at x4> <CAH8yC8k5Pdc0DcWM-voZ93GpQTN55Rs7ZEBCC9JZm3TWN_wBrQ at mail dot gmail dot com>
On 2015.07.15 at 23:37 -0400, Jeffrey Walton wrote:
> On Mon, Jul 13, 2015 at 3:14 AM, Markus Trippelsdorf
> <markus@trippelsdorf.de> wrote:
> > On 2015.07.12 at 20:32 -0400, Jeffrey Walton wrote:
> >> I've got a crash under GCC 4.9/x86_64 when using -O3. (The crash is
> >> related to an array that's 64-bit aligned, but GCC selects the vmovdqa
> >> instruction, which has 128-bit alignment requirements.)
> >>
> >> It was easy enough to back-off optimizations:
> >>
> >> #pragma GCC optimize push
> >> #pragma GCC optimize ("-O2")
> >>
> >> void xorbuf(byte *buf, const byte *mask, size_t count)
> >> {
> >> ...
> >> }
> >> #pragma GCC optimize pop
> >>
> >
> > This is a bad idea in general, because "pragma GCC optimize" is meant as
> > a compiler debugging aid only. It should _not_ be used in production
> > code.
> > Please fix the underlying issue instead (, or open a bug for it).
>
> We cleared the issue; thanks for the advice.
>
> I have one more question related to the use of '#pragma GCC optimize'.
> I have a zeroizer that must execute due to Certification and
> Accreditation (C&A) requirements. When the zeroizer is removed as a
> dead store, the compiler folks usually say, "but you asked for
> optimizations...".
>
> If we cannot use '#pragma GCC optimize' to turn off the optimizer for
> a function, then how do we tell the compiler to *not* remove the code?
It is hard to tell without seeing the code. But see noclone, noinline
entries at:
http://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
--
Markus