This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tuples] Partial gcov-4.c fix
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Diego Novillo <dnovillo at google dot com>, Aldy Hernandez <aldyh at redhat dot com>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Fri, 18 Jul 2008 10:54:00 -0400
- Subject: [tuples] Partial gcov-4.c fix
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
This patch fixes some issues in gcov-4.c, the remaining ones
(test_ifelse1) is harder. The important difference is that the trunk
doesn't generate artificial GOTO_EXPRs for COND_EXPR during gimplification
and so the GOTO_EXPR after the THEN sequence to label_cont doesn't have
locus. But on the tuples branch we create them early and thus they
get annotated.
@@ -672,13 +667,13 @@ test_ifelse1 (int i, int j)
<bb 2>:
[gcov-4.c : 131] result = 0;
- [gcov-4.c : 132] if (i != 0)
+ [gcov-4.c : 132] if ([gcov-4.c : 132] i != 0)
goto <bb 3>;
else
goto <bb 9>;
<bb 3>:
- [gcov-4.c : 133] if (j != 0)
+ [gcov-4.c : 133] if ([gcov-4.c : 133] j != 0)
goto <bb 4>;
else
goto <bb 6>;
@@ -687,17 +682,17 @@ test_ifelse1 (int i, int j)
PROF_edge_counter.127 = *.LPBX1[33];
PROF_edge_counter.127 = PROF_edge_counter.127 + 1;
*.LPBX1[33] = PROF_edge_counter.127;
- [gcov-4.c : 134] result.34 = do_something (4);
+ [gcov-4.c : 134] result.34 = [gcov-4.c : 134] do_something (4);
<bb 5>:
[gcov-4.c : 134] result = result.34;
- [gcov-4.c : 133] goto <bb 8>;
+ goto <bb 8>;
<bb 6>:
PROF_edge_counter.127 = *.LPBX1[34];
PROF_edge_counter.127 = PROF_edge_counter.127 + 1;
*.LPBX1[34] = PROF_edge_counter.127;
- [gcov-4.c : 136] result.35 = do_something (1024);
+ [gcov-4.c : 136] result.35 = [gcov-4.c : 136] do_something (1024);
<bb 7>:
[gcov-4.c : 136] result = result.35;
@@ -709,10 +704,10 @@ test_ifelse1 (int i, int j)
PROF_edge_counter.127 = *.LPBX1[36];
PROF_edge_counter.127 = PROF_edge_counter.127 + 1;
*.LPBX1[36] = PROF_edge_counter.127;
- [gcov-4.c : 132] goto <bb 14>;
+ goto <bb 14>;
<bb 9>:
- [gcov-4.c : 138] if (j != 0)
+ [gcov-4.c : 138] if ([gcov-4.c : 138] j != 0)
goto <bb 10>;
else
goto <bb 12>;
The bad effect of this is that say lines 132 and 133 are counted
in multiple blocks. I wonder if should_carry_location_p couldn't
return false even for GIMPLE_GOTO and let gimplify_expr set it
when gimplifying GOTO_EXPR.
2008-07-18 Jakub Jelinek <jakub@redhat.com>
* gimplify.c (gimplify_cond_expr): Don't optimize GOTO_EXPRs
if -O0 and GOTO_EXPR has different locus from COND_EXPR.
(gimplify_expr) <case LABEL_EXPR>: Set GIMPLE_LABEL's location
if LABEL_EXPR had it set.
--- gcc/gimplify.c.jj 2008-07-18 13:46:25.000000000 +0200
+++ gcc/gimplify.c 2008-07-18 15:51:05.000000000 +0200
@@ -2949,7 +2949,13 @@ gimplify_cond_expr (tree *expr_p, gimple
&& TREE_CODE (TREE_OPERAND (expr, 1)) == GOTO_EXPR
&& TREE_CODE (GOTO_DESTINATION (TREE_OPERAND (expr, 1))) == LABEL_DECL
&& (DECL_CONTEXT (GOTO_DESTINATION (TREE_OPERAND (expr, 1)))
- == current_function_decl))
+ == current_function_decl)
+ /* For -O0 avoid this optimization if the COND_EXPR and GOTO_EXPR
+ have different locations. */
+ && (optimize
+ || !EXPR_HAS_LOCATION (expr)
+ || !EXPR_HAS_LOCATION (TREE_OPERAND (expr, 1))
+ || EXPR_LOCATION (expr) == EXPR_LOCATION (TREE_OPERAND (expr, 1))))
{
label_true = GOTO_DESTINATION (TREE_OPERAND (expr, 1));
have_then_clause_p = true;
@@ -2960,7 +2966,13 @@ gimplify_cond_expr (tree *expr_p, gimple
&& TREE_CODE (TREE_OPERAND (expr, 2)) == GOTO_EXPR
&& TREE_CODE (GOTO_DESTINATION (TREE_OPERAND (expr, 2))) == LABEL_DECL
&& (DECL_CONTEXT (GOTO_DESTINATION (TREE_OPERAND (expr, 2)))
- == current_function_decl))
+ == current_function_decl)
+ /* For -O0 avoid this optimization if the COND_EXPR and GOTO_EXPR
+ have different locations. */
+ && (optimize
+ || !EXPR_HAS_LOCATION (expr)
+ || !EXPR_HAS_LOCATION (TREE_OPERAND (expr, 2))
+ || EXPR_LOCATION (expr) == EXPR_LOCATION (TREE_OPERAND (expr, 2))))
{
label_false = GOTO_DESTINATION (TREE_OPERAND (expr, 2));
have_else_clause_p = true;
@@ -6434,6 +6446,9 @@ gimplify_expr (tree *expr_p, gimple_seq
== current_function_decl);
gimplify_seq_add_stmt (pre_p,
gimple_build_label (LABEL_EXPR_LABEL (*expr_p)));
+ if (EXPR_HAS_LOCATION (*expr_p))
+ gimple_set_location (gimple_seq_last_stmt (*pre_p),
+ EXPR_LOCATION (*expr_p));
break;
case CASE_LABEL_EXPR:
Jakub