public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Edelsohn <dje.gcc@gmail.com>
To: Alan Modra <amodra@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RS6000] ABI_V4 init of toc section
Date: Mon, 01 Feb 2016 18:02:00 -0000	[thread overview]
Message-ID: <CAGWvnymtP0BjkOacnjisxz2p7DqWLctv_aYE7ChO3yy6rf1NAA@mail.gmail.com> (raw)
In-Reply-To: <20160129163824.GQ17028@bubble.grove.modra.org>

On Fri, Jan 29, 2016 at 11:38 AM, Alan Modra <amodra@gmail.com> wrote:
> Since 4c4a180d, LTO has turned off flag_pic when linking a fixed
> position executable.  This results in flag_pic being zero in
> rs6000_file_start, and no definition of ".LCTOC1".
>
> However, when we get to actually emitting code, flag_pic may be on
> again, and references made to ".LCTOC1".  How flag_pic comes to be
> enabled again is quite a story.  It goes like this..  If a function is
> compiled with -fPIC then sysv4.h SUBTARGET_OVERRIDE_OPTIONS will set
> TARGET_RELOCATABLE.  Conversely, if TARGET_RELOCATABLE is set and
> flag_pic is zero, then SUBTARGET_OVERRIDE_OPTIONS will set flag_pic=2.
> It also happens that TARGET_RELOCATABLE is a bit in rs6000_isa_flags,
> which is handled by rs6000_function_specific_save and
> rs6000_function_specific_restore.  That last fact means lto streaming
> keeps track of the state of TARGET_RELOCATABLE for functions, and when
> options are restored for a given function we'll set flag_pic=2 if the
> function was originally compiled with -fPIC.  That's bad because it
> defeats the purpose of the 4c4a180d lto change, resulting in worse
> optimization of ppc32 executables.  What's more, we don't seem to turn
> off flag_pic once it is on.
>
> We should really untangle the flag_pic/TARGET_RELOCATABLE mess, but
> that change is probably a little dangerous for stage4.  Instead, this
> patch removes the toc symbol initialization from file_start and does
> so when the first item is emitted to the toc, or after the function
> epilogue in the cases where we emit code to initialize a toc pointer
> but don't actually use it (-O0 mostly, I think).
>
> Bootstrapped and regression tested powerpc64-linux biarch with all
> languages enabled.  OK to apply?
>
>         PR target/68662
>         * config/rs6000/rs6000.c (need_toc_init): New var, set it
>         whenever toc_label_name used.
>         (rs6000_file_start): Don't set up toc section here,
>         (rs6000_output_function_epilogue): do so here instead,
>         (rs6000_xcoff_file_start): and here.
>         * config/rs6000/rs6000.md (load_toc_aix_si): Set need_toc_init.
>         (load_toc_aix_di): Likewise.

This is okay as an interim fix for GCC 6.

Thanks, David

      parent reply	other threads:[~2016-02-01 18:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29 16:38 Alan Modra
2016-01-29 18:20 ` David Edelsohn
2016-01-30  9:44   ` Alan Modra
2016-02-01  0:38     ` Alan Modra
2016-02-01 18:02 ` David Edelsohn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGWvnymtP0BjkOacnjisxz2p7DqWLctv_aYE7ChO3yy6rf1NAA@mail.gmail.com \
    --to=dje.gcc@gmail.com \
    --cc=amodra@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).