]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072]
authorKewen Lin <linkw@linux.ibm.com>
Mon, 26 Sep 2022 05:33:18 +0000 (00:33 -0500)
committerKewen Lin <linkw@linux.ibm.com>
Wed, 19 Oct 2022 07:54:35 +0000 (02:54 -0500)
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)

gcc/config/rs6000/rs6000-logue.cc
gcc/testsuite/gcc.target/powerpc/pr96072.c [new file with mode: 0644]

index 59fe1c8cb8bb9b262bb83cc8eaeb456e9f174c2c..a868ede24fb0d755a53cef69cac70566561946c2 100644 (file)
@@ -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 (file)
index 0000000..10341c9
--- /dev/null
@@ -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:;
+}