This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC-3.4 reorders asm() with -O2
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Michael Eager <eager at mvista dot com>
- Cc: gcc <gcc at gcc dot gnu dot org>
- Date: Sat, 24 Jan 2004 02:20:06 +0100
- Subject: Re: GCC-3.4 reorders asm() with -O2
- References: <4011C72C.613E25@mvista.com>
> GCC-3.4 orders asm() outside of functions differently depending on
> whether code is compiled -O1 or -O2. This behavior has changed from
> gcc-3.3.1.
See our changes page:
http://gcc.gnu.org/gcc-3.4/changes.html, specially the section about
unit-at-a-time...
Honza
>
> Here's a small piece of C code (extracted from glibc):
>
> initfini.c:
> asm ("\n/*@HEADER_ENDS*/");
>
> asm ("\n/*@TESTS_BEGIN*/");
> void dummy (void) { }
> asm ("\n/*@TESTS_END*/");
>
> asm ("\n/*@_init_PROLOG_BEGINS*/");
>
>
> When compiled with -O1, the output is
>
>
> /*@HEADER_ENDS*/
>
> /*@TESTS_BEGIN*/
> #NO_APP
> . . .
> .type dummy, @function
> dummy:
> . . .
> #APP
>
> /*@TESTS_END*/
>
> /*@_init_PROLOG_BEGINS*/
>
>
> With -O2 (or -O3), the output is
>
> #APP
>
> /*@HEADER_ENDS*/
>
> /*@TESTS_BEGIN*/
>
> /*@TESTS_END*/
>
> /*@_init_PROLOG_BEGINS*/
> #NO_APP
> . . .
> .type dummy, @function
> dummy:
> . . .
> .end dummy
>
> So, this is different behavior between gcc-3.3.1 and gcc-3.4.
> Is there any guarantee that asm() outside of a function will
> not be reordered with respect to functions?
> Is there any way to suppress this reordering?
>
> --
> Michael Eager eager@mvista.com 408-328-8426
> MontaVista Software, Inc. 1237 E. Arques Ave., Sunnyvale, CA 94085