public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rsandifo at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/32406] [4.3 Regression] MIPS: FAIL in nestfunc-6.c at -O3
Date: Sun, 11 Nov 2007 10:07:00 -0000	[thread overview]
Message-ID: <20071111100658.25759.qmail@sourceware.org> (raw)
In-Reply-To: <bug-32406-7151@http.gcc.gnu.org/bugzilla/>



------- Comment #8 from rsandifo at gcc dot gnu dot org  2007-11-11 10:06 -------
Created an attachment (id=14529)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14529&action=view)
Patch that marks $gp as being live on nonlocal jumps

"daney at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
> Created an attachment (id=14528)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14528&action=view)
>  --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14528&action=view)
> Proposed patch second half.
>
> Completely untested patch.  It will probably take me a couple of weeks
> to test it fully.  I will start testing on mipsel-linux...

You might have noticed already, but this patch won't work.
mips_restore_gp restores $gp from the .cprestore save slot,
which doesn't exist unless TARGET_CALL_CLOBBERED_GP.

TBH, I'd forgotten when reviewing the original patch how this is
supposed to work.  If function Inner has a nonlocal jump to function
Outer, Inner is supposed to initialise $gp on Outer's behalf.
The original form of Inner's prologue does do this, thanks to:

static unsigned int
mips_global_pointer (void)
{
  [...]
  /* If the function has a nonlocal goto, $gp must hold the correct
     global pointer for the target function.  */
  if (current_function_has_nonlocal_goto)
    return GLOBAL_POINTER_REGNUM;

but at higher optimisation levels, the instructions get deleted as
dead for -mno-shared, because nothing in the function itself needs $gp.

I think this is a dataflow bug.  (Dataflow generally, that is, not the
new df machinery.)  The code that emits the nonlocal goto records that
the target of the jump uses the frame and stack pointers:

static rtx
expand_builtin_nonlocal_goto (tree exp)
{
  ...
      /* USE of hard_frame_pointer_rtx added for consistency;
         not clear if really needed.  */
      emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
      emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));

but it doesn't record that it also uses the GP register.  The target-
independent code does handle the liveness of GP in other situations,
thanks originally to flow and now to the df machinery, so I think this
is simply an oversight.  It won't matter for most targets, since the
nonlocal jump involves a symbolic access, and most targets use the GP
for all symbolic accesses or for none.

Long-term, it would be nice to get rid of these sorts of USEs and
handle them entirely in the df machinery.  However, given that we
don't do that yet, I think the best fix is to emit a use of
pic_offset_table_rtx:

      if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM
          && fixed_regs[PIC_OFFSET_TABLE_REGNUM])
        emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));

(the condition being the same as that used in flow and df).

I think we can then revert the original patch, which would produce
an unnecessary restore at the target site.

The attached patch seems to work for me, both for o32 and n32.
I'll run some regression tests.

Richard


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32406


  parent reply	other threads:[~2007-11-11 10:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-19 17:53 [Bug target/32406] New: " daney at gcc dot gnu dot org
2007-06-20  2:53 ` [Bug target/32406] " hp at gcc dot gnu dot org
2007-06-20  7:12 ` daney at gcc dot gnu dot org
2007-06-20 12:56 ` richard at codesourcery dot com
2007-06-22  4:55 ` daney at gcc dot gnu dot org
2007-09-29 22:44 ` daney at gcc dot gnu dot org
2007-11-11  6:29 ` daney at gcc dot gnu dot org
2007-11-11  6:33 ` daney at gcc dot gnu dot org
2007-11-11  6:34 ` daney at gcc dot gnu dot org
2007-11-11  7:05 ` daney at gcc dot gnu dot org
2007-11-11 10:07 ` rsandifo at gcc dot gnu dot org [this message]
2007-11-11 10:16 ` rsandifo at nildram dot co dot uk
2007-11-27  5:48 ` mmitchel at gcc dot gnu dot org
2007-11-28 19:46 ` rsandifo at gcc dot gnu dot org
2007-11-28 19:49 ` rsandifo at gcc dot gnu dot org

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=20071111100658.25759.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).