]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/44777 (ICE: SIGSEGV with -fprofile-use in gcc.c-torture...
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Feb 2012 21:34:21 +0000 (22:34 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 9 Feb 2012 21:34:21 +0000 (22:34 +0100)
Backported from mainline
2012-01-05  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/44777
* profile.c (branch_prob): Split bbs that have exit edge
and need a fake entry edge too.

* gcc.dg/tree-prof/pr44777.c: New test.

From-SVN: r184070

gcc/ChangeLog
gcc/profile.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-prof/pr44777.c [new file with mode: 0644]

index 71004dbb61dc87b10d29d053945cf7d71b391c09..a21fe5f49b4985375b863e2de04be079e0f22c72 100644 (file)
@@ -1,3 +1,12 @@
+2012-02-09  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2012-01-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/44777
+       * profile.c (branch_prob): Split bbs that have exit edge
+       and need a fake entry edge too.
+
 2012-02-09  Peter Bergner  <bergner@vnet.ibm.com>
 
        Backport from mainline 
index ac460464697cef6abbb60cb8bce2fac952a26c97..db395f83e2c9b7914138060caaf4392eb7088c00 100644 (file)
@@ -989,6 +989,45 @@ branch_prob (void)
            fprintf (dump_file, "Adding fake entry edge to bb %i\n",
                     bb->index);
          make_edge (ENTRY_BLOCK_PTR, bb, EDGE_FAKE);
+         /* Avoid bbs that have both fake entry edge and also some
+            exit edge.  One of those edges wouldn't be added to the
+            spanning tree, but we can't instrument any of them.  */
+         if (have_exit_edge || need_exit_edge)
+           {
+             gimple_stmt_iterator gsi;
+             gimple first;
+             tree fndecl;
+
+             gsi = gsi_after_labels (bb);
+#ifdef ENABLE_CHECKING
+             gcc_assert (!gsi_end_p (gsi));
+#endif
+             first = gsi_stmt (gsi);
+             if (is_gimple_debug (first))
+               {
+                 gsi_next_nondebug (&gsi);
+#ifdef ENABLE_CHECKING
+                 gcc_assert (!gsi_end_p (gsi));
+#endif
+                 first = gsi_stmt (gsi);
+               }
+             /* Don't split the bbs containing __builtin_setjmp_receiver
+                or __builtin_setjmp_dispatcher calls.  These are very
+                special and don't expect anything to be inserted before
+                them.  */
+             if (!is_gimple_call (first)
+                 || (fndecl = gimple_call_fndecl (first)) == NULL
+                 || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL
+                 || (DECL_FUNCTION_CODE (fndecl) != BUILT_IN_SETJMP_RECEIVER
+                     && (DECL_FUNCTION_CODE (fndecl)
+                         != BUILT_IN_SETJMP_DISPATCHER)))
+               {
+                 if (dump_file)
+                   fprintf (dump_file, "Splitting bb %i after labels\n",
+                            bb->index);
+                 split_block_after_labels (bb);
+               }
+           }
        }
     }
 
index 067b36a951b822a5ad145ff99f2eac9d313cd63d..1324a9c41d4a38b62de87d029b838f534c9a5e05 100644 (file)
@@ -1,3 +1,11 @@
+2012-02-09  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2012-01-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/44777
+       * gcc.dg/tree-prof/pr44777.c: New test.
+
 2012-02-09  Peter Bergner  <bergner@vnet.ibm.com>
 
        Backport from mainline 
diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr44777.c b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
new file mode 100644 (file)
index 0000000..1c4da7f
--- /dev/null
@@ -0,0 +1,43 @@
+/* PR middle-end/44777 */
+/* { dg-options "-O0" } */
+/* A variant of gcc.c-torture/execute/comp-goto-2.c.  */
+
+extern void abort (void);
+extern void exit (int);
+
+#ifdef STACK_SIZE
+#define DEPTH ((STACK_SIZE) / 512 + 1)
+#else
+#define DEPTH 1000
+#endif
+
+#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)
+int
+x (int a)
+{
+  __label__ xlab;
+  void y (int a)
+    {
+      void *x = &&llab;
+      if (a==-1)
+       goto *x;
+      if (a==0)
+       goto xlab;
+    llab:
+      y (a-1);
+    }
+  y (a);
+ xlab:;
+  return a;
+}
+#endif
+
+int
+main ()
+{
+#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)
+  if (x (DEPTH) != DEPTH)
+    abort ();
+#endif
+  exit (0);
+}