This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Verify DECL_DEBUG/VALUE_EXPR have no associated blocks
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 20 Mar 2013 14:21:19 +0100 (CET)
- Subject: [PATCH] Verify DECL_DEBUG/VALUE_EXPR have no associated blocks
This adds verification and simplifies clear_unused_block_pointer
accordingly (as previously discussed).
Bootstrap and regtest pending on x86_64-unknown-linux-gnu.
Richard.
2013-03-20 Richard Biener <rguenther@suse.de>
* tree-cfg.c (verify_expr_no_block): New function.
(verify_expr_location_1): Verify that neither DECL_DEBUG_EXPR
nor DECL_VALUE_EXPR have locations with associated blocks.
* tree-ssa-live.c (clear_unused_block_pointer_1): Remove.
(clear_unused_block_pointer): Remove code dealing with
blocks in DECL_DEBUG_EXPR locations.
Index: trunk/gcc/tree-cfg.c
===================================================================
*** trunk.orig/gcc/tree-cfg.c 2013-03-20 14:13:26.000000000 +0100
--- trunk/gcc/tree-cfg.c 2013-03-20 14:17:36.152250539 +0100
*************** verify_location (pointer_set_t *blocks,
*** 4536,4541 ****
--- 4536,4559 ----
return false;
}
+ /* Called via walk_tree. Verify that expressions have no blocks. */
+
+ static tree
+ verify_expr_no_block (tree *tp, int *walk_subtrees, void *)
+ {
+ if (!EXPR_P (*tp))
+ {
+ *walk_subtrees = false;
+ return NULL;
+ }
+
+ location_t loc = EXPR_LOCATION (*tp);
+ if (LOCATION_BLOCK (loc) != NULL)
+ return *tp;
+
+ return NULL;
+ }
+
/* Called via walk_tree. Verify locations of expressions. */
static tree
*************** verify_expr_location_1 (tree *tp, int *w
*** 4547,4553 ****
&& DECL_HAS_DEBUG_EXPR_P (*tp))
{
tree t = DECL_DEBUG_EXPR (*tp);
! tree addr = walk_tree (&t, verify_expr_location_1, blocks, NULL);
if (addr)
return addr;
}
--- 4565,4581 ----
&& DECL_HAS_DEBUG_EXPR_P (*tp))
{
tree t = DECL_DEBUG_EXPR (*tp);
! tree addr = walk_tree (&t, verify_expr_no_block, NULL, NULL);
! if (addr)
! return addr;
! }
! if ((TREE_CODE (*tp) == VAR_DECL
! || TREE_CODE (*tp) == PARM_DECL
! || TREE_CODE (*tp) == RESULT_DECL)
! && DECL_HAS_VALUE_EXPR_P (*tp))
! {
! tree t = DECL_VALUE_EXPR (*tp);
! tree addr = walk_tree (&t, verify_expr_no_block, NULL, NULL);
if (addr)
return addr;
}
Index: trunk/gcc/tree-ssa-live.c
===================================================================
*** trunk.orig/gcc/tree-ssa-live.c 2013-03-20 14:13:26.000000000 +0100
--- trunk/gcc/tree-ssa-live.c 2013-03-20 14:15:21.630755347 +0100
*************** clear_unused_block_pointer_1 (tree *tp,
*** 620,630 ****
if (EXPR_P (*tp) && TREE_BLOCK (*tp)
&& !TREE_USED (TREE_BLOCK (*tp)))
TREE_SET_BLOCK (*tp, NULL);
- if (TREE_CODE (*tp) == VAR_DECL && DECL_HAS_DEBUG_EXPR_P (*tp))
- {
- tree debug_expr = DECL_DEBUG_EXPR (*tp);
- walk_tree (&debug_expr, clear_unused_block_pointer_1, NULL, NULL);
- }
return NULL_TREE;
}
--- 620,625 ----
*************** clear_unused_block_pointer (void)
*** 636,650 ****
{
basic_block bb;
gimple_stmt_iterator gsi;
- tree t;
- unsigned i;
-
- FOR_EACH_LOCAL_DECL (cfun, i, t)
- if (TREE_CODE (t) == VAR_DECL && DECL_HAS_DEBUG_EXPR_P (t))
- {
- tree debug_expr = DECL_DEBUG_EXPR (t);
- walk_tree (&debug_expr, clear_unused_block_pointer_1, NULL, NULL);
- }
FOR_EACH_BB (bb)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
--- 631,636 ----