On Tue, Jun 08, 2010 at 10:27:03PM +0930, Alan Modra wrote:
> PowerPC64 gcc support for a larger TOC via -mcmodel option.
[snip]

I'm having second thoughts about the optimization I added to PowerPC64
gcc with the patch hunk below.  Its effect is to use a more efficient
TOC/GOT pointer relative address calculation on references known to be
local, rather than loading an address out of the TOC/GOT.  ie.

  addis rx,2,s...@toc@ha
  addi ry,rx,s...@toc@l

instead of

  addis rx,2,s...@got@ha
  ld ry,s...@got@l(rx)

This saves a word in the TOC/GOT and is a little faster too.  However,
there is a problem:  If people build PowerPC64 shared libraries
without -fpic/-fPIC then gcc will emit code that requires text relocs
to properly support ELF shared library semantics, and I don't intend
to change ld and ld.so to do that.

It may be better to not do this optimization in gcc at all, especially
since we can do the same transformation in ld.  This would mean
PowerPC64 gcc would lose -mcmodel=medium, retaining -mcmodel=small and
-mcmodel=large.  If there are no dissenting opinions I'll prepare a
gcc patch to do that.

> +       || (TARGET_CMODEL == CMODEL_MEDIUM
> +           && GET_CODE (operands[1]) == SYMBOL_REF
> +           && !CONSTANT_POOL_ADDRESS_P (operands[1])
> +           && SYMBOL_REF_LOCAL_P (operands[1])
> +           && offsettable_ok_by_alignment (SYMBOL_REF_DECL (operands[1]))))

-- 
Alan Modra
Australia Development Lab, IBM

Reply via email to