]> gcc.gnu.org Git - gcc.git/commit
Darwin, rs6000: Amend lo_sum use for forced constants [PR104117].
authorIain Sandoe <iain@sandoe.co.uk>
Mon, 7 Feb 2022 15:36:35 +0000 (15:36 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Thu, 14 Apr 2022 05:28:15 +0000 (06:28 +0100)
commit53254184bda6305ac38e6e37480303b9f167b5ae
treea86832009dd760e89cd6884a3463b5bb624ebef7
parent94c9c6acdc14de186abe4ea59c54920fbfb60beb
Darwin, rs6000: Amend lo_sum use for forced constants [PR104117].

Two issues resulted in this PR, which manifests when we force a constant into
memory in LRA (in PIC code on Darwin).  The presence of such forced constants
is quite dependent on other RTL optimisations, and it is easy for the issue to
become latent for a specific case.

First, in the Darwin-specific rs6000 backend code, we were not being careful
enough in rejecting invalid symbolic addresses.  Specifically, when generating
PIC code, we require a SYMBOL_REF to be wrapped in an UNSPEC_MACHOPIC_OFFSET.

We now split the Darwin high/low selectors into two:
 1. One that handles non-PIC addresses (kernel mode, mdynamic-no-pic).
 2. One that handles PIC addresses and rejects SYMBOL_REFs unless they are
    suitably wrapped in the MACHOPIC_OFFSET unspec.

The second case is handled by providing a new predicate (macho_pic_address)
that checks the requirements.

Backported from 4c3792d448964f7bd99e7eac2c29c9eb7c2bfb84 and
f1b3e3853329b58fb2e50c17487df2ecbc4a5608

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Vladimir Makarov <vmakarov@redhat.com>
PR target/104117

gcc/ChangeLog:

* config/rs6000/rs6000.c (darwin_rs6000_legitimate_lo_sum_const_p):
Check for UNSPEC_MACHOPIC_OFFSET wrappers on symbolic addresses when
emitting PIC code.
(legitimate_lo_sum_address_p): Likewise.
(rs6000_legitimize_address): Do not apply the TLS processing to
Darwin.
* config/rs6000/darwin.md (@machopic_high_<mode>): New.
(@machopic_low_<mode>): New.
* config/rs6000/predicates.md (macho_pic_address): New.
gcc/config/rs6000/darwin.md
gcc/config/rs6000/predicates.md
gcc/config/rs6000/rs6000.c
This page took 0.063156 seconds and 6 git commands to generate.