Hi!

We ICE on the following testcase, because we have abnormal edges
from both __morestack call (which is before prologue) and call
to the nested function (which is in between prologue and epilogue)
to a label reachable through non-local goto.  This is something
dwarf2cfi doesn't allow, it doesn't know what CFI state should
be at that label.
As __morestack really doesn't do non-local gotos and while it probably
can throw, it is never something that can be caught in the function that
calls __morestack, the following patch fixes it by telling middle-end
that __morestack can't do nl goto.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-02-20  Jakub Jelinek  <ja...@redhat.com>

        PR target/79494
        * config/i386/i386.c (ix86_expand_split_stack_prologue): Call
        make_reg_eh_region_note_nothrow_nononlocal on call_insn.
        * config/rs6000/rs6000.c: Include except.h.
        (rs6000_expand_split_stack_prologue): Call
        make_reg_eh_region_note_nothrow_nononlocal on the call insn.

        * gcc.dg/pr79494.c: New test.

--- gcc/config/i386/i386.c.jj   2017-02-20 13:51:22.000000000 +0100
+++ gcc/config/i386/i386.c      2017-02-20 15:26:04.184793980 +0100
@@ -15057,6 +15057,8 @@ ix86_expand_split_stack_prologue (void)
   add_function_usage_to (call_insn, call_fusage);
   if (!TARGET_64BIT)
     add_reg_note (call_insn, REG_ARGS_SIZE, GEN_INT (0));
+  /* Indicate that this function can't jump to non-local gotos.  */
+  make_reg_eh_region_note_nothrow_nononlocal (as_a <rtx_insn *> (call_insn));
 
   /* In order to make call/return prediction work right, we now need
      to execute a return instruction.  See
--- gcc/config/rs6000/rs6000.c.jj       2017-02-18 14:12:36.000000000 +0100
+++ gcc/config/rs6000/rs6000.c  2017-02-20 15:47:56.602798893 +0100
@@ -66,6 +66,7 @@
 #include "builtins.h"
 #include "context.h"
 #include "tree-pass.h"
+#include "except.h"
 #if TARGET_XCOFF
 #include "xcoffout.h"  /* get declarations of xcoff_*_section_name */
 #endif
@@ -31680,6 +31681,8 @@ rs6000_expand_split_stack_prologue (void
      split_stack_return use r0.  */
   use_reg (&call_fusage, r0);
   add_function_usage_to (insn, call_fusage);
+  /* Indicate that this function can't jump to non-local gotos.  */
+  make_reg_eh_region_note_nothrow_nononlocal (insn);
   emit_insn (gen_frame_load (r0, r1, info->lr_save_offset));
   insn = emit_move_insn (lr, r0);
   add_reg_note (insn, REG_CFA_RESTORE, lr);
--- gcc/testsuite/gcc.dg/pr79494.c.jj   2017-02-20 15:51:12.970247250 +0100
+++ gcc/testsuite/gcc.dg/pr79494.c      2017-02-20 15:52:59.753859680 +0100
@@ -0,0 +1,22 @@
+/* PR target/79494 */
+/* { dg-do compile } */
+/* { dg-require-effective-target split_stack } */
+/* { dg-options "-O2 -fsplit-stack" } */
+
+void
+foo (int a)
+{
+  __label__ lab;
+  __attribute__((noinline, noclone)) void bar (int b)
+  {
+    switch (b)
+      {
+      case 1:
+       goto lab;
+      case 2:
+       goto lab;
+      }
+  }
+  bar (a);
+lab:;
+}

        Jakub

Reply via email to