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: Painful problems with -fpic implementation on powerpc-sysv



  In message <199808190652.QAA15243@geoffk.wattle.id.au>you write:
  > 
  > This is an analysis of two very nasty bugs with -fpic/-fPIC and
  > optimisation on powerpc SVR4 ABI targets.
  > 
  > Two testcases for the bugs are attached below, called 'test3.c' and
  > 'test4.c'.  The original files were from TclX 8.0.
  > 
  > If these are compiled with 'gcc -O2 -fpic test3.c -S', gcc fails with
  > an internal compiler error.  For test3.c, it's:
[ ... ]

  > The underlying problem for both of these is the same.
  > 
  > The powerpc -fpic implementation works by allocating a pseudo to hold
  > the GOT pointer, when required, (in the routine rs6000_got_register).
  > In rs6000_finalise_pic, the pseudo is initialised.  The result is used
  > in the movsi_got_internal insn.
  > 
  > There are two problems with this:
  > 
  > 1. rs6000_finalise_pic is run before reload.  But sometimes reload can
  >    create a new memory reference (see, for instance, test4.c).  So
  >    rs6000_finalise_pic does not know where all the memory references
  >    are, or even if there are any at all.
  > 
  > 2. Worse, rs6000_finalise_pic is actually run before scheduling, and
  >    so the scheduler can get the dependencies wrong if new memory
  >    references appear later.  For instance, in test3.c after local
  >    register allocation, there is:
First, having the PIC register be a pseudo is bad.  This is the core
problem that we need to fix.

We should select a callee saved register and reserve it for PIC.

This is non-optimal, but will work.  Trying to allocate the PIC reg
via a pseudo will not because we can not allocate a pseudo for the
PIC register during the reload pass (or anytime after flow).

I think addressing this core problem will go a long way towards fixing
the various PIC related issues on the powerpc.


Jeff


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