public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Re: Is it a gcc bug? Optimization doesn't work
@ 2004-09-22 14:18 lapo.pasqui
  2004-09-22 18:16 ` Muthukumar Ratty
  0 siblings, 1 reply; 2+ messages in thread
From: lapo.pasqui @ 2004-09-22 14:18 UTC (permalink / raw)
  To: Muthukumar Ratty; +Cc: gcc-help

What do you mean with "dead"
The getc, putc functions are defined here and used by another files.

============================================================
Da: Muthukumar Ratty <muthu@iqmail.net>
Data: 2004/09/21 mar PM 11:51:35 GMT+02:00
A: lapo <lapo.pasqui@tele2.it>
Cc: <gcc-help@gcc.gnu.org>
Oggetto: Re: Is it a gcc bug? Optimization doesn't work



I guess it eliminates the dead code. Try to use the getc, putc functions,
it will not be eliminated then.




On Tue, 21 Sep 2004, lapo wrote:

> Alle 14:10, mercoledì 15 settembre 2004, lapo.pasqui@tele2.it ha scritto:
> Does anybody like to answer this question?
> I'd rather prefer not to open an insane bug against the gcc.
> Thanks
>   Lapo
> > Hi all,
> > I've upgraded my cross gcc compiler from version 3.3.1 to 3.4.1 and I've
> > noticed a few unresolved symbols on a project (u-boot) used to compile
> > without any problem. After a quick investigation I've noticed the
> > optimization flag -0s caused a few functions not to be in the .o files.
> > Here's a code that reproduces the problem
> >
> > unsigned long get_version(void);
> > int getc(void);
> > int tstc(void);
> > void putc(const char);
> >
> > void app_startup(char **);
> >
> > enum {
> > XF_get_version ,
> > XF_getc ,
> > XF_tstc ,
> > XF_putc ,
> >  XF_MAX
> > };
> >
> > typedef unsigned int size_t;
> > typedef struct global_data
> > {
> >    void **jt;
> > } gd_t;
> >
> > static void __attribute__((unused)) dummy(void)
> > {
> > asm volatile ( "        .globl " "get_version" "\n" "get_version" ":\n" "
> >     lwz     %%r11, %0(%%r29)\n" "   lwz     %%r11, %1(%%r11)\n" "   mtctr
> > %%r11\n" "      bctr\n" : : "i"(((size_t) &((gd_t *)0)->jt)),
> > "i"(XF_get_version * sizeof(void *)) : "r11"); asm volatile ( "
> > .globl " "getc" "\n" "getc" ":\n" "     lwz     %%r11, %0(%%r29)\n" "   lwz
> >     %%r11, %1(%%r11)\n" "   mtctr   %%r11\n" "      bctr\n" : :
> > "i"(((size_t) &((gd_t *)0)->jt)), "i"(XF_getc * sizeof(void *)) : "r11");
> > asm volatile ( "        .globl " "tstc" "\n" "tstc" ":\n" "     lwz
> > %%r11, %0(%%r29)\n" "   lwz     %%r11, %1(%%r11)\n" "   mtctr   %%r11\n" "
> >     bctr\n" : : "i"(((size_t) &((gd_t *)0)->jt)), "i"(XF_tstc * sizeof(void
> > *)) : "r11"); asm volatile ( "        .globl " "putc" "\n" "putc" ":\n" "
> >   lwz     %%r11, %0(%%r29)\n" "   lwz     %%r11, %1(%%r11)\n" "   mtctr
> > %%r11\n" "      bctr\n" : : "i"(((size_t) &((gd_t *)0)->jt)), "i"(XF_putc *
> > sizeof(void *)) : "r11"); }
> >
> > extern unsigned long __bss_start, _end;
> >
> > void app_startup(char **argv)
> > {
> >  unsigned long * cp = &__bss_start;
> >  while (cp < &_end) {
> >   *cp++ = 0;
> >  }
> >
> > }
> >
> > Compiling it with optimization less then 2 (e.g. powerpc-linux-gcc  stubs.i
> > -c -O1), I get this symbols
> >
> > nm -C --defined-only stub.o
> >
> > 00000044 T app_startup
> > 00000000 t dummy
> > 00000010 T getc
> > 00000000 T get_version
> > 00000030 T putc
> > 00000020 T tstc
> >
> >
> > Instead, using a different optimization (e.g. powerpc-linux-gcc  stubs.i -c
> > -O2), I get this symbols
> >
> > nm -C --defined-only stub.o
> > 00000000 T app_startup
> >
> > Using a previous version of gcc, I've not this different behaviour
> >
> > My questions are (as I'm not am assembler guru):
> >
> > Can you see anything wrong on this code that some new feature of the gcc
> > try to overcome? Is it indeed a regression of gcc 3.4.1
> >
> >
> >
> >
> > -------------------------------------------------
> > WebMail Tele2 http://www.tele2.it
> > -------------------------------------------------
>

============================================================


-------------------------------------------------
WebMail Tele2 http://www.tele2.it
-------------------------------------------------

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Re: Is it a gcc bug? Optimization doesn't work
  2004-09-22 14:18 Re: Is it a gcc bug? Optimization doesn't work lapo.pasqui
@ 2004-09-22 18:16 ` Muthukumar Ratty
  0 siblings, 0 replies; 2+ messages in thread
From: Muthukumar Ratty @ 2004-09-22 18:16 UTC (permalink / raw)
  To: lapo.pasqui; +Cc: Muthukumar Ratty, gcc-help



> static void __attribute__((unused)) dummy(void)
> {

Why is the above marked *unused*. Thats the reason for that code to be
eliminated.

Regards,
Muthu.



On Wed, 22 Sep 2004 lapo.pasqui@tele2.it wrote:

> What do you mean with "dead"
> The getc, putc functions are defined here and used by another files.
>
> ============================================================
> Da: Muthukumar Ratty <muthu@iqmail.net>
> Data: 2004/09/21 mar PM 11:51:35 GMT+02:00
> A: lapo <lapo.pasqui@tele2.it>
> Cc: <gcc-help@gcc.gnu.org>
> Oggetto: Re: Is it a gcc bug? Optimization doesn't work
>
>
>
> I guess it eliminates the dead code. Try to use the getc, putc functions,
> it will not be eliminated then.
>
>
>
>
> On Tue, 21 Sep 2004, lapo wrote:
>
> > Alle 14:10, mercoledì 15 settembre 2004, lapo.pasqui@tele2.it ha scritto:
> > Does anybody like to answer this question?
> > I'd rather prefer not to open an insane bug against the gcc.
> > Thanks
> >   Lapo
> > > Hi all,
> > > I've upgraded my cross gcc compiler from version 3.3.1 to 3.4.1 and I've
> > > noticed a few unresolved symbols on a project (u-boot) used to compile
> > > without any problem. After a quick investigation I've noticed the
> > > optimization flag -0s caused a few functions not to be in the .o files.
> > > Here's a code that reproduces the problem
> > >
> > > unsigned long get_version(void);
> > > int getc(void);
> > > int tstc(void);
> > > void putc(const char);
> > >
> > > void app_startup(char **);
> > >
> > > enum {
> > > XF_get_version ,
> > > XF_getc ,
> > > XF_tstc ,
> > > XF_putc ,
> > >  XF_MAX
> > > };
> > >
> > > typedef unsigned int size_t;
> > > typedef struct global_data
> > > {
> > >    void **jt;
> > > } gd_t;
> > >
> > > static void __attribute__((unused)) dummy(void)
> > > {
> > > asm volatile ( "        .globl " "get_version" "\n" "get_version" ":\n" "
> > >     lwz     %%r11, %0(%%r29)\n" "   lwz     %%r11, %1(%%r11)\n" "   mtctr
> > > %%r11\n" "      bctr\n" : : "i"(((size_t) &((gd_t *)0)->jt)),
> > > "i"(XF_get_version * sizeof(void *)) : "r11"); asm volatile ( "
> > > .globl " "getc" "\n" "getc" ":\n" "     lwz     %%r11, %0(%%r29)\n" "   lwz
> > >     %%r11, %1(%%r11)\n" "   mtctr   %%r11\n" "      bctr\n" : :
> > > "i"(((size_t) &((gd_t *)0)->jt)), "i"(XF_getc * sizeof(void *)) : "r11");
> > > asm volatile ( "        .globl " "tstc" "\n" "tstc" ":\n" "     lwz
> > > %%r11, %0(%%r29)\n" "   lwz     %%r11, %1(%%r11)\n" "   mtctr   %%r11\n" "
> > >     bctr\n" : : "i"(((size_t) &((gd_t *)0)->jt)), "i"(XF_tstc * sizeof(void
> > > *)) : "r11"); asm volatile ( "        .globl " "putc" "\n" "putc" ":\n" "
> > >   lwz     %%r11, %0(%%r29)\n" "   lwz     %%r11, %1(%%r11)\n" "   mtctr
> > > %%r11\n" "      bctr\n" : : "i"(((size_t) &((gd_t *)0)->jt)), "i"(XF_putc *
> > > sizeof(void *)) : "r11"); }
> > >
> > > extern unsigned long __bss_start, _end;
> > >
> > > void app_startup(char **argv)
> > > {
> > >  unsigned long * cp = &__bss_start;
> > >  while (cp < &_end) {
> > >   *cp++ = 0;
> > >  }
> > >
> > > }
> > >
> > > Compiling it with optimization less then 2 (e.g. powerpc-linux-gcc  stubs.i
> > > -c -O1), I get this symbols
> > >
> > > nm -C --defined-only stub.o
> > >
> > > 00000044 T app_startup
> > > 00000000 t dummy
> > > 00000010 T getc
> > > 00000000 T get_version
> > > 00000030 T putc
> > > 00000020 T tstc
> > >
> > >
> > > Instead, using a different optimization (e.g. powerpc-linux-gcc  stubs.i -c
> > > -O2), I get this symbols
> > >
> > > nm -C --defined-only stub.o
> > > 00000000 T app_startup
> > >
> > > Using a previous version of gcc, I've not this different behaviour
> > >
> > > My questions are (as I'm not am assembler guru):
> > >
> > > Can you see anything wrong on this code that some new feature of the gcc
> > > try to overcome? Is it indeed a regression of gcc 3.4.1
> > >
> > >
> > >
> > >
> > > -------------------------------------------------
> > > WebMail Tele2 http://www.tele2.it
> > > -------------------------------------------------
> >
>
> ============================================================
>
>
> -------------------------------------------------
> WebMail Tele2 http://www.tele2.it
> -------------------------------------------------
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-22 18:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-22 14:18 Re: Is it a gcc bug? Optimization doesn't work lapo.pasqui
2004-09-22 18:16 ` Muthukumar Ratty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).