summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-05 19:54:16 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-05 19:54:16 +0000
commit180c5ea0ccdbf6a871e1bd6d2cb929ebfc1c7b31 (patch)
treec1e56a37e6acbf3a34e12021d57db83b3eae63dc
parent753f2949e582336c573fb9e1458146b10a7f5dff (diff)
downloadppe42-gcc-180c5ea0ccdbf6a871e1bd6d2cb929ebfc1c7b31.tar.gz
ppe42-gcc-180c5ea0ccdbf6a871e1bd6d2cb929ebfc1c7b31.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182920 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/profile.c37
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/pr44777.c43
4 files changed, 90 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1e612427ebf..9cbe9c0ffb6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+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-01-05 Jan Hubicka <jh@suse.cz>
PR middle-end/49710
diff --git a/gcc/profile.c b/gcc/profile.c
index 201f6cd3c32..10ab756d567 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -1,6 +1,6 @@
/* Calculate branch probabilities, and basic block execution counts.
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Contributed by James E. Wilson, UC Berkeley/Cygnus Support;
based on some ideas from Dain Samples of UC Berkeley.
@@ -1040,6 +1040,41 @@ 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);
+ gcc_checking_assert (!gsi_end_p (gsi));
+ first = gsi_stmt (gsi);
+ if (is_gimple_debug (first))
+ {
+ gsi_next_nondebug (&gsi);
+ gcc_checking_assert (!gsi_end_p (gsi));
+ 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);
+ }
+ }
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d324db6a2e3..d35dab996b5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/44777
+ * gcc.dg/tree-prof/pr44777.c: New test.
+
2012-01-05 Jan Hubicka <jh@suse.cz>
PR middle-end/49710
diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr44777.c b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
new file mode 100644
index 00000000000..1c4da7f5f7d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c
@@ -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);
+}
OpenPOWER on IntegriCloud