This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PIC register allocation by reload (Was: Re: egcs-1.2 stuff)


> Date: Thu, 06 May 1999 23:44:47 +0200
> From: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
> Cc: amylaar@cygnus.co.uk, law@cygnus.com, ghazi@snafu.Rutgers.EDU,
>         davem@cobaltmicro.com, egcs@egcs.cygnus.com
> 
> At 23:15 06.05.99 , Geoff Keating wrote:
> >Is this testcase already in the test suite?  It's stripped-down code
> >from kaffe's implementation of GNU zip.
> 
> Geoff,
> 
> this testcase is not in the testsuite, but it also no longer FAILs with the 
> current cvs-egcs, reload got a _lot_ smarter since egcs-1.1. But there's 
> one testcase in the testsuite which still shows this problem with -fpic on 
> PPC, attached below.
...

The canonical example of this sort of thing is this:

extern int v;
void f(void)
{
  asm ("" : : "r"(&v));
}

because until it actually parses the asm, reload can't tell that it's
not

extern int v;
void f(void)
{
  asm ("" : : "i"(&v));
}

which does not need the GOT register---this is not a hypothetical
example, the first one happens in glibc somewhere, and you use the
second one to override -fpic on a section of code which you know will
be in writable memory, like (on ppc):

static const double real_params[] = { 1, 2, 3.141 };

const double * params(void) __attribute__((section(".wcode"), const));
const double * params(void)
{
  const double *result;
  /* Just like `return real_params', except that it is not PIC and
     so will be faster under these circumstances (it saves building
     a stack frame, for instance).  */
  asm ("lis %0,%1@ha ; addi %0,%0,%1@lo" : "=b"(result) : "i"(real_params));
  return result;
}


-- 
Geoffrey Keating <geoffk@ozemail.com.au>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]