public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/c++-modules] MIPS: Fix __builtin_longjmp (PR 64242)
Date: Fri, 28 Aug 2020 16:02:29 +0000 (GMT)	[thread overview]
Message-ID: <20200828160229.D4964386186A@sourceware.org> (raw)

https://gcc.gnu.org/g:68e605c93d57c17f07edd50f7e1c80f9216befd2

commit 68e605c93d57c17f07edd50f7e1c80f9216befd2
Author: Andrew Pinski <apinski@marvell.com>
Date:   Tue Aug 25 14:17:52 2020 +0800

    MIPS: Fix __builtin_longjmp (PR 64242)
    
    The problem here is mips has its own builtin_longjmp
    pattern and it was not fixed when expand_builtin_longjmp
    was fixed.  We need to read the new fp and gp before
    restoring the stack as the buffer might be a local
    variable.
    
    2020-08-25  Andrew Pinski  <apinski@marvell.com>
    
    gcc/ChangeLog:
    
            PR middle-end/64242
            * config/mips/mips.md (builtin_longjmp): Restore the frame
            pointer and stack pointer and gp.

Diff:
---
 gcc/config/mips/mips.md | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md
index 6383a31a5e3..2e75a720fa9 100644
--- a/gcc/config/mips/mips.md
+++ b/gcc/config/mips/mips.md
@@ -6562,9 +6562,19 @@
 
   /* This bit is similar to expand_builtin_longjmp except that it
      restores $gp as well.  */
-  mips_emit_move (hard_frame_pointer_rtx, fp);
   mips_emit_move (pv, lab);
+  /* Restore the frame pointer and stack pointer and gp.  We must use a
+     temporary since the setjmp buffer may be a local.  */
+  fp = copy_to_reg (fp);
+  gpv = copy_to_reg (gpv);
   emit_stack_restore (SAVE_NONLOCAL, stack);
+
+  /* Ensure the frame pointer move is not optimized.  */
+  emit_insn (gen_blockage ());
+  emit_clobber (hard_frame_pointer_rtx);
+  emit_clobber (frame_pointer_rtx);
+  emit_clobber (gp);
+  mips_emit_move (hard_frame_pointer_rtx, fp);
   mips_emit_move (gp, gpv);
   emit_use (hard_frame_pointer_rtx);
   emit_use (stack_pointer_rtx);


                 reply	other threads:[~2020-08-28 16:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200828160229.D4964386186A@sourceware.org \
    --to=nathan@gcc.gnu.org \
    --cc=gcc-cvs@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).