public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Kewen Lin <linkw@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-8846] rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072]
Date: Wed, 19 Oct 2022 09:05:21 +0000 (GMT)	[thread overview]
Message-ID: <20221019090521.E9A1E385AC24@sourceware.org> (raw)

https://gcc.gnu.org/g:c7f17493cc26a4395d549547075603a15f4c94a7

commit r12-8846-gc7f17493cc26a4395d549547075603a15f4c94a7
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Mon Sep 26 00:33:18 2022 -0500

    rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072]
    
    As PR96072 shows, the code adding REG_CFA_DEF_CFA reg note
    makes one assumption that we have emitted one insn which
    restores the frame pointer previously.  That part of code
    was guarded with flag frame_pointer_needed before, it was
    consistent, but it was replaced with flag
    frame_pointer_needed_indeed since commit r10-7981.  It
    caused ICE due to unexpected NULL insn.
    
            PR target/96072
    
    gcc/ChangeLog:
    
            * config/rs6000/rs6000-logue.cc (rs6000_emit_epilogue): Update the
            condition for adding REG_CFA_DEF_CFA reg note with
            frame_pointer_needed_indeed.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/pr96072.c: New test.
    
    (cherry picked from commit 5be0950d22209f5ba69d244387228e12389a8470)

Diff:
---
 gcc/config/rs6000/rs6000-logue.cc          |  2 +-
 gcc/testsuite/gcc.target/powerpc/pr96072.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc
index 59fe1c8cb8b..a868ede24fb 100644
--- a/gcc/config/rs6000/rs6000-logue.cc
+++ b/gcc/config/rs6000/rs6000-logue.cc
@@ -4924,7 +4924,7 @@ rs6000_emit_epilogue (enum epilogue_type epilogue_type)
 	 a REG_CFA_DEF_CFA note, but that's OK;  A duplicate is
 	 discarded by dwarf2cfi.cc/dwarf2out.cc, and in any case would
 	 be harmless if emitted.  */
-      if (frame_pointer_needed)
+      if (frame_pointer_needed_indeed)
 	{
 	  insn = get_last_insn ();
 	  add_reg_note (insn, REG_CFA_DEF_CFA,
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96072.c b/gcc/testsuite/gcc.target/powerpc/pr96072.c
new file mode 100644
index 00000000000..10341c91d2f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96072.c
@@ -0,0 +1,14 @@
+/* { dg-options "-O2" } */
+
+/* This used to ICE with the SYSV ABI (PR96072).  */
+
+void
+he (int jn)
+{
+  {
+    int bh[jn];
+    if (jn != 0)
+      goto wa;
+  }
+wa:;
+}

                 reply	other threads:[~2022-10-19  9:05 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=20221019090521.E9A1E385AC24@sourceware.org \
    --to=linkw@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).