gcc optimizer bug and registerised/mangler compilation

Simon Marlow simonmarhaskell at gmail.com
Wed Jul 25 11:28:40 EDT 2007


Joe Buehler wrote:
> There is an optimizer bug in gcc that prevents my compiling
> for hppa using optimization (via C and the mangler -- there
> is no native code generator for hppa).
> 
> Bug 32820 has been filed against gcc for this.  It is present
> in gcc versions going *way* back.
> 
> I am a little puzzled though, in that the many versions of gcc
> that I have tried on sunos/sparc -- all the way back to 2.95 -- exhibit
> the same bug.
> 
> The miscompiled routine is stg_returnToStackTop (there are others but
> I didn't bother tracking them all down).  One of the global
> register variables is not set when optimization is turned on.
> 
> How did this ever work on the Sun Sparc platform?  Does the native
> code generator for sun sparc predate even gcc 2.95?

Is this perhaps related to the following comment in TailCalls.h?

/*
   NOTE about __DISCARD__():

   On x86_64 this is necessary to work around bugs in the register
   variable support in gcc.  Without the __DISCARD__() call, gcc will
   silently throw away assignements to global register variables that
   happen before the jump.

   Here's the example:

   extern void g(void);
   static void f(void) {
     R1 = g;
     __DISCARD__()
     goto *R1;
   }

   without the dummy function call, gcc throws away the assignment to R1
   (gcc 3.4.3) gcc bug #20359.
*/

Cheers,
	Simon



More information about the Cvs-ghc mailing list