This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix -fcompare-debug issue in tree profiler (PR debug/46255)


Hi!

While debug stmts are never considered to need fake edges, it currently
(incorrectly) makes a difference whether a stmt that needs fake edges
was the last one or not.  Fixed by disregarding any debug stmts
at the end of bb.

Bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for trunk?

2010-11-01  Jakub Jelinek  <jakub@redhat.com>

	PR debug/46255
	* tree-cfg.c (gimple_flow_call_edges_add): Use gsi_last_nondebug_bb
	instead of gsi_last_bb.

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

--- gcc/tree-cfg.c.jj	2010-11-01 09:07:24.000000000 +0100
+++ gcc/tree-cfg.c	2010-11-01 14:03:05.000000000 +0100
@@ -6749,7 +6749,7 @@ gimple_flow_call_edges_add (sbitmap bloc
   if (check_last_block)
     {
       basic_block bb = EXIT_BLOCK_PTR->prev_bb;
-      gimple_stmt_iterator gsi = gsi_last_bb (bb);
+      gimple_stmt_iterator gsi = gsi_last_nondebug_bb (bb);
       gimple t = NULL;
 
       if (!gsi_end_p (gsi))
@@ -6783,7 +6783,7 @@ gimple_flow_call_edges_add (sbitmap bloc
       if (blocks && !TEST_BIT (blocks, i))
 	continue;
 
-      gsi = gsi_last_bb (bb);
+      gsi = gsi_last_nondebug_bb (bb);
       if (!gsi_end_p (gsi))
 	{
 	  last_stmt = gsi_stmt (gsi);
--- gcc/testsuite/gcc.dg/pr46255.c.jj	2010-11-01 14:04:55.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr46255.c	2010-11-01 14:04:34.000000000 +0100
@@ -0,0 +1,12 @@
+/* PR debug/46255 */
+/* { dg-do compile } */
+/* { dg-options "-fcompare-debug -fprofile-generate -O" } */
+
+int bar (void);
+
+void
+foo (int i)
+{
+  while (i)
+    i = bar ();
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]