From 775689606a63636144534eee2d5413cd982e4160 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Mon, 18 Oct 2004 19:29:52 +0000 Subject: [PATCH] re PR middle-end/15014 (labels after are removed even though they are used) 2004-10-18 Andrew Pinski PR middle-end/15014 PR middle-end/16973 * tree-cfg.c (remove_bb): If we have a label expression in the basic block and the label we have taken the address, move the label expression to the basic block which is previous in the linked list. (tree_verify_flow_info): Fix printing out the label name of the problematic label expression. From-SVN: r89237 --- gcc/ChangeLog | 11 +++++++++++ gcc/tree-cfg.c | 25 ++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 074ac3d31175..089ae2b2bb59 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2004-10-18 Andrew Pinski + + PR middle-end/15014 + PR middle-end/16973 + * tree-cfg.c (remove_bb): If we have a label expression in the + basic block and the label we have taken the address, move the + label expression to the basic block which is previous in the + linked list. + (tree_verify_flow_info): Fix printing out the label name of the + problematic label expression. + 2004-10-18 Pat Haugen PR rtl-optimization/18002 diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 72cbbd880448..149be9515a2b 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -1810,12 +1810,25 @@ remove_bb (basic_block bb) } /* Remove all the instructions in the block. */ - for (i = bsi_start (bb); !bsi_end_p (i); bsi_remove (&i)) + for (i = bsi_start (bb); !bsi_end_p (i);) { tree stmt = bsi_stmt (i); - release_defs (stmt); + if (TREE_CODE (stmt) == LABEL_EXPR + && FORCED_LABEL (LABEL_EXPR_LABEL (stmt))) + { + basic_block new_bb = bb->prev_bb; + block_stmt_iterator new_bsi = bsi_after_labels (new_bb); + + bsi_remove (&i); + bsi_insert_after (&new_bsi, stmt, BSI_NEW_STMT); + } + else + { + release_defs (stmt); - set_bb_for_stmt (stmt, NULL); + set_bb_for_stmt (stmt, NULL); + bsi_remove (&i); + } /* Don't warn for removed gotos. Gotos are often removed due to jump threading, thus resulting in bogus warnings. Not great, @@ -3403,8 +3416,9 @@ tree_verify_flow_info (void) if (label_to_block (LABEL_EXPR_LABEL (bsi_stmt (bsi))) != bb) { + tree stmt = bsi_stmt (bsi); error ("Label %s to block does not match in bb %d\n", - IDENTIFIER_POINTER (DECL_NAME (bsi_stmt (bsi))), + IDENTIFIER_POINTER (DECL_NAME (LABEL_EXPR_LABEL (stmt))), bb->index); err = 1; } @@ -3412,8 +3426,9 @@ tree_verify_flow_info (void) if (decl_function_context (LABEL_EXPR_LABEL (bsi_stmt (bsi))) != current_function_decl) { + tree stmt = bsi_stmt (bsi); error ("Label %s has incorrect context in bb %d\n", - IDENTIFIER_POINTER (DECL_NAME (bsi_stmt (bsi))), + IDENTIFIER_POINTER (DECL_NAME (LABEL_EXPR_LABEL (stmt))), bb->index); err = 1; } -- 2.43.5