This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: CFG transparent expansion 4
> On Thu, Jun 17, 2004 at 07:28:29PM +0200, Jan Hubicka wrote:
> > + /* label_to_block might put undefined labels into the first basic
> > + block. */
> > + if (!label_for_bb[true_bb->index])
> > + label_for_bb[true_bb->index] = GOTO_DESTINATION (true_branch);
>
> How about pulling out this into a new function, cdl_label_to_block
> or something? You've got 4 or 5 potential uses...
Hi,
this is the patch I am just testing. It seems to be easier to pull it
all together asthere shall be no more users (after this pass, all labels
are defined)
OK, assuming it passes i686-pc-gnu-linux?
2004-06-17 Jan Hubicka <jh@suse.cz>
* tree-cfg.c (label_to_block): Invent the label destination for
undefined labels.
(main_block_label): New function.
(cleanup_dead_labels): Update table in the case label_to_block added
new label.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.14
diff -c -3 -p -r2.14 tree-cfg.c
*** tree-cfg.c 17 Jun 2004 18:13:11 -0000 2.14
--- tree-cfg.c 17 Jun 2004 20:52:15 -0000
*************** make_switch_expr_edges (basic_block bb)
*** 647,653 ****
basic_block
label_to_block (tree dest)
{
! return VARRAY_BB (label_to_block_map, LABEL_DECL_UID (dest));
}
--- 647,667 ----
basic_block
label_to_block (tree dest)
{
! int uid = LABEL_DECL_UID (dest);
!
! /* We would die hard when faced by undefined label. Emit label to
! very first basic block. This will hopefully make even the dataflow
! and undefined variable warnings quite right. */
! if ((errorcount || sorrycount) && uid < 0)
! {
! block_stmt_iterator bsi = bsi_start (BASIC_BLOCK (0));
! tree stmt;
!
! stmt = build1 (LABEL_EXPR, void_type_node, dest);
! bsi_insert_before (&bsi, stmt, BSI_NEW_STMT);
! uid = LABEL_DECL_UID (dest);
! }
! return VARRAY_BB (label_to_block_map, uid);
}
*************** update_eh_label (struct eh_region *regio
*** 784,789 ****
--- 798,815 ----
}
}
+ /* Given LABEL return the first label in the same basic block. */
+ static tree
+ main_block_label (tree label)
+ {
+ basic_block bb = label_to_block (label);
+
+ /* label_to_block possibly inserted undefined label into the chain. */
+ if (!label_for_bb[bb->index])
+ label_for_bb[bb->index] = label;
+ return label_for_bb[bb->index];
+ }
+
/* Cleanup redundant labels. This is a three-steo process:
1) Find the leading label for each block.
2) Redirect all references to labels to the leading labels.
*************** cleanup_dead_labels (void)
*** 843,857 ****
case COND_EXPR:
{
tree true_branch, false_branch;
- basic_block true_bb, false_bb;
true_branch = COND_EXPR_THEN (stmt);
false_branch = COND_EXPR_ELSE (stmt);
- true_bb = label_to_block (GOTO_DESTINATION (true_branch));
- false_bb = label_to_block (GOTO_DESTINATION (false_branch));
! GOTO_DESTINATION (true_branch) = label_for_bb[true_bb->index];
! GOTO_DESTINATION (false_branch) = label_for_bb[false_bb->index];
break;
}
--- 869,882 ----
case COND_EXPR:
{
tree true_branch, false_branch;
true_branch = COND_EXPR_THEN (stmt);
false_branch = COND_EXPR_ELSE (stmt);
! GOTO_DESTINATION (true_branch)
! = main_block_label (GOTO_DESTINATION (true_branch));
! GOTO_DESTINATION (false_branch)
! = main_block_label (GOTO_DESTINATION (false_branch));
break;
}
*************** cleanup_dead_labels (void)
*** 864,875 ****
/* Replace all destination labels. */
for (i = 0; i < n; ++i)
! {
! tree label = CASE_LABEL (TREE_VEC_ELT (vec, i));
!
! CASE_LABEL (TREE_VEC_ELT (vec, i)) =
! label_for_bb[label_to_block (label)->index];
! }
break;
}
--- 889,896 ----
/* Replace all destination labels. */
for (i = 0; i < n; ++i)
! CASE_LABEL (TREE_VEC_ELT (vec, i))
! = main_block_label (CASE_LABEL (TREE_VEC_ELT (vec, i)));
break;
}
*************** cleanup_dead_labels (void)
*** 877,889 ****
/* We have to handle GOTO_EXPRs until they're removed, and we don't
remove them until after we've created the CFG edges. */
case GOTO_EXPR:
! {
! tree label = GOTO_DESTINATION (stmt);
! if (! computed_goto_p (stmt))
! GOTO_DESTINATION (stmt) =
! label_for_bb[label_to_block (label)->index];
! break;
! }
default:
break;
--- 898,909 ----
/* We have to handle GOTO_EXPRs until they're removed, and we don't
remove them until after we've created the CFG edges. */
case GOTO_EXPR:
! if (! computed_goto_p (stmt))
! {
! GOTO_DESTINATION (stmt)
! = main_block_label (GOTO_DESTINATION (stmt));
! break;
! }
default:
break;