From: Jakub Jelinek <jakub@redhat.com>
To: Eric Botcazou <ebotcazou@libertysurf.fr>
Cc: gcc-patches@gcc.gnu.org
Subject: [committed] sparc: Preserve ORIGINAL_REGNO in epilogue_renumber [PR105257]
Date: Tue, 19 Apr 2022 19:06:23 +0200 [thread overview]
Message-ID: <Yl7sD08ICN6XPAjS@tucnak> (raw)
Hi!
The following testcase ICEs, because the pic register is
(reg:DI 24 %i0 [109]) and is used in the delay slot of a return.
We invoke epilogue_renumber and that changes it to
(reg:DI 8 %o0) which no longer satisfies sparc_pic_register_p
predicate, so we don't recognize the insn anymore.
The following patch fixes that by preserving ORIGINAL_REGNO if
specified, so we get (reg:DI 8 %o0 [109]) instead.
Rainer has kindly bootstrapped/regtested this on sparcv9-sun-solaris2.11,
acked by Eric in the PR, committed to trunk.
2022-04-19 Jakub Jelinek <jakub@redhat.com>
PR target/105257
* config/sparc/sparc.cc (epilogue_renumber): If ORIGINAL_REGNO,
use gen_raw_REG instead of gen_rtx_REG and copy over also
ORIGINAL_REGNO. Use return 0; instead of /* fallthrough */.
* gcc.dg/pr105257.c: New test.
--- gcc/config/sparc/sparc.cc.jj 2022-01-18 11:58:59.254986743 +0100
+++ gcc/config/sparc/sparc.cc 2022-04-19 11:12:48.396795736 +0200
@@ -8884,8 +8884,20 @@ epilogue_renumber (rtx *where, int test)
if (REGNO (*where) >= 8 && REGNO (*where) < 24) /* oX or lX */
return 1;
if (! test && REGNO (*where) >= 24 && REGNO (*where) < 32)
- *where = gen_rtx_REG (GET_MODE (*where), OUTGOING_REGNO (REGNO(*where)));
- /* fallthrough */
+ {
+ if (ORIGINAL_REGNO (*where))
+ {
+ rtx n = gen_raw_REG (GET_MODE (*where),
+ OUTGOING_REGNO (REGNO (*where)));
+ ORIGINAL_REGNO (n) = ORIGINAL_REGNO (*where);
+ *where = n;
+ }
+ else
+ *where = gen_rtx_REG (GET_MODE (*where),
+ OUTGOING_REGNO (REGNO (*where)));
+ }
+ return 0;
+
case SCRATCH:
case PC:
case CONST_INT:
--- gcc/testsuite/gcc.dg/pr105257.c.jj 2022-04-19 11:08:15.239628246 +0200
+++ gcc/testsuite/gcc.dg/pr105257.c 2022-04-19 11:10:02.951117000 +0200
@@ -0,0 +1,16 @@
+/* PR target/105257 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-fpic" { target fpic } } */
+
+extern int sigsetjmp (void **, int);
+void *buf[32];
+void (*fn) (void);
+
+const char *
+bar (void)
+{
+ sigsetjmp (buf, 0);
+ fn ();
+ return "";
+}
Jakub
reply other threads:[~2022-04-19 17:07 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=Yl7sD08ICN6XPAjS@tucnak \
--to=jakub@redhat.com \
--cc=ebotcazou@libertysurf.fr \
--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).