Port-vax archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: gcc-vax in NetBSD-9.0: help needed to test patches



On Sat, 1 Aug 2020, Kalvis Duckmanton wrote:

> It could be the same problem I tripped over, where GCC is trying to optimise a
> bit field extraction by adjusting the source address.  I don't believe that
> this optimisation can be done when compiling position-independent code if the
> source address is given by an external symbol (but happy to take advice from
> GCC experts!).  The attached patch should help.

 Why?  The address of a preemptible symbol necessarily has to come from 
the GOT, but it surely is offsettable.  There will be an extra instruction 
required to add the offset, so whether it makes sense from the performance 
or code size's point of view is another matter, but nothing is supposed to 
break.

 If you choose not to have the extra instruction, then I would suggest 
using a more fine-grained check and only suppress address adjustment for 
non-local symbols, i.e. something like (untested):

  if (REG_P (operands[0])
      || (flag_pic && SYMBOL_REF_P (operands[0])
	  && !(SYMBOL_REF_DECL (operands[0]) 
	       ? targetm.binds_local_p (SYMBOL_REF_DECL (operands[0]))
	       : SYMBOL_REF_LOCAL_P (operands[0])))
    {
      /* ... */

It may make sense to factor all or parts of the complex condition out to a 
helper function.  For local symbols any addend used for address adjustment 
will be combined in the displacement with the PC-relative offset, which is 
a link-time constant (i.e. the adjustment will become an addend to the 
relocation if one is produced).

  Maciej


Home | Main Index | Thread Index | Old Index