[PATCH] Fix debug info for expr and jump stmt
Dehao Chen
dehao@google.com
Fri Oct 26 23:36:00 GMT 2012
Hi,
I've updated the patch:
1. abandon the changes in cfgexpand.c
2. set the block for trees when lowering gimple stmt.
3. add a unittest.
However, this patch will trigger two lto bug when asserting
LTO_NO_PREVAIL for TREE_CHAIN. After debugging for a while, I found
that the problem was also there even without the patch. This patch
just reveal the problem by moving a decl into cache so that it will be
checked. As I'm not familiar with LTO, not quite sure what the root
problem is. Can anyone help take a look?
Thanks,
Dehao
gcc/ChangeLog:
2012-10-25 Dehao Chen <dehao@google.com>
* tree-eh.c (do_return_redirection): Set location for jump statement.
(do_goto_redirection): Likewise.
(frob_into_branch_around): Likewise.
(lower_try_finally_nofallthru): Likewise.
(lower_try_finally_copy): Likewise.
(lower_try_finally_switch): Likewise.
* gimple-low.c (tree_set_block_r): New callback function.
(lower_stmt): Set block for tested expr.
gcc/testsuite/ChangeLog:
2012-10-25 Dehao Chen <dehao@google.com>
* g++.dg/debug/dwarf2/block.C: New testcase.
-------------- next part --------------
Index: gcc/tree-eh.c
===================================================================
--- gcc/tree-eh.c (revision 192809)
+++ gcc/tree-eh.c (working copy)
@@ -739,6 +739,7 @@ do_return_redirection (struct goto_queue_node *q,
gimple_seq_add_seq (&q->repl_stmt, mod);
x = gimple_build_goto (finlab);
+ gimple_set_location (x, q->location);
gimple_seq_add_stmt (&q->repl_stmt, x);
}
@@ -758,6 +759,7 @@ do_goto_redirection (struct goto_queue_node *q, tr
gimple_seq_add_seq (&q->repl_stmt, mod);
x = gimple_build_goto (finlab);
+ gimple_set_location (x, q->location);
gimple_seq_add_stmt (&q->repl_stmt, x);
}
@@ -857,6 +859,7 @@ frob_into_branch_around (gimple tp, eh_region regi
if (!over)
over = create_artificial_label (loc);
x = gimple_build_goto (over);
+ gimple_set_location (x, loc);
gimple_seq_add_stmt (&cleanup, x);
}
gimple_seq_add_seq (&eh_seq, cleanup);
@@ -1085,6 +1088,7 @@ lower_try_finally_nofallthru (struct leh_state *st
emit_post_landing_pad (&eh_seq, tf->region);
x = gimple_build_goto (lab);
+ gimple_set_location (x, gimple_location (tf->try_finally_expr));
gimple_seq_add_stmt (&eh_seq, x);
}
}
@@ -1223,6 +1227,7 @@ lower_try_finally_copy (struct leh_state *state, s
tmp = lower_try_finally_fallthru_label (tf);
x = gimple_build_goto (tmp);
+ gimple_set_location (x, tf_loc);
gimple_seq_add_stmt (&new_stmt, x);
}
@@ -1395,6 +1400,7 @@ lower_try_finally_switch (struct leh_state *state,
tmp = lower_try_finally_fallthru_label (tf);
x = gimple_build_goto (tmp);
+ gimple_set_location (x, tf_loc);
gimple_seq_add_stmt (&switch_body, x);
}
@@ -1423,6 +1429,7 @@ lower_try_finally_switch (struct leh_state *state,
gimple_seq_add_stmt (&eh_seq, x);
x = gimple_build_goto (finally_label);
+ gimple_set_location (x, tf_loc);
gimple_seq_add_stmt (&eh_seq, x);
tmp = build_int_cst (integer_type_node, eh_index);
Index: gcc/gimple-low.c
===================================================================
--- gcc/gimple-low.c (revision 192809)
+++ gcc/gimple-low.c (working copy)
@@ -331,7 +331,18 @@ lower_omp_directive (gimple_stmt_iterator *gsi, st
gsi_next (gsi);
}
+/* Call back function to set the block for expr. */
+static tree
+tree_set_block_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
+ void *data)
+{
+ tree block = (tree) data;
+ if (CAN_HAVE_LOCATION_P (*tp))
+ TREE_SET_BLOCK (*tp, block);
+ return NULL_TREE;
+}
+
/* Lower statement GSI. DATA is passed through the recursion. We try to
track the fallthruness of statements and get rid of unreachable return
statements in order to prevent the EH lowering pass from adding useless
@@ -343,8 +354,11 @@ static void
lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
{
gimple stmt = gsi_stmt (*gsi);
+ unsigned i;
gimple_set_block (stmt, data->block);
+ for (i = 0; i < gimple_num_ops (stmt); i++)
+ walk_tree (gimple_op_ptr (stmt, i), tree_set_block_r, data->block, NULL);
switch (gimple_code (stmt))
{
Index: gcc/testsuite/g++.dg/debug/dwarf2/block.C
===================================================================
--- gcc/testsuite/g++.dg/debug/dwarf2/block.C (revision 0)
+++ gcc/testsuite/g++.dg/debug/dwarf2/block.C (revision 0)
@@ -0,0 +1,29 @@
+// Compiler should not generate too many lexical blocks for this function.
+// { dg-do compile { target { i?86-*-* x86_64-*-* } } }
+// { dg-options "-O0 -fno-exceptions -g -dA" }
+
+union UElement {
+ void* pointer;
+ int integer;
+};
+struct UColToken {
+ unsigned source;
+ unsigned char **rulesToParseHdl;
+};
+
+int uhash_hashTokens(const union UElement k)
+{
+ int hash = 0;
+ struct UColToken *key = (struct UColToken *)k.pointer;
+ if (key != 0) {
+ int len = (key->source & 0xFF000000)>>24;
+ int inc = ((len - 32) / 32) + 1;
+ const unsigned char *p = (key->source & 0x00FFFFFF)
+ + *(key->rulesToParseHdl);
+ const unsigned char *limit = p + len;
+ hash = *p + *limit;
+ }
+ return hash;
+}
+
+// { dg-final { scan-assembler-not "LBB10" } }
More information about the Gcc-patches
mailing list