Commit 165b54c3 by Steven Bosscher Committed by Steven Bosscher

cfgcleanup.c (try_simplify_condjump): Don't remove line notes to avoid unreachable code warnings.

	* cfgcleanup.c (try_simplify_condjump): Don't remove line
	notes to avoid unreachable code warnings.
	* toplev.c (backend_init): Don't emit line notes for
	unreachable code warnings.

	* combine.c (distribute_notes): Don't distribute a
	REG_VTABLE_REF note.
	* final.c (final_scan_insn): Don't handle it.
	* rtl.c (reg_note_name): Remove it.
	* rtl.h (enum reg_node): Dito.

	* emit-rtl.c (force_line_numbers, restore_line_number_status):
	Remove.
	* rtl.h (force_line_numbers, restore_line_number_status):
	Remove prototypes.

	* stmt.c (using_eh_for_cleanups_p, using_eh_for_cleanups): Move...
	* tree-eh.c (using_eh_for_cleanups_p): ...here.  Make static.
	(using_eh_for_cleanups): Also moved here.

	* expr.c (expand_expr_real_1) <CASE_LABEL_EXPR>: Die if we see one.
	<SWITCH_EXPR>: Die if we have a non-NULL SWITCH_BODY.  Update calls
	to expand_start_case and add_case_node.
	* stmt.c (struct nesting): Cleanup unused fields condition_code,
	last_unconditional_cleanup, nominal_type, printname, and
	line_number_status.
	(struct fixup_goto): Remove.
	(struct stmt_status): Remove x_goto_fixup_chain field.
	(goto_fixup_chain): Remove.
	(strip_default_case_nodes, group_case_nodes, emit_jump_if_reachable,
	pushcase, pushcase_range): Remove.
	(expand_start_bindings_and_block): Don't set unused fields in
	the nesting stack.
	(expand_start_case, add_case_node): Cleanup unused formal arguments.
	(expand_end_case_type): Don't simplify the case-list.  Use emit_jump
	instead of emit_jump_if_reachable.
	(emit_case_nodes): Likewise.
	* tree-cfg.c (group_case_labels, cleanup_dead_labels): No longer
	static.
	(update_eh_label): Work around left-over exception handing regions.
	* tree-flow.h (group_case_labels, cleanup_dead_labels): Add protos.
	* tree-optimize.c (execute_cleanup_cfg_post_optimizing): New function.
	(pass_cleanup_cfg_post_optimizing): New pass.
	(init_tree_optimization_passes): Run the new pass after all
	optimizations.
	* tree.h (pushcase, pushcase_range): Remove prototypes.
	(expand_start_case, add_case_node): Update prototypes.

cp/
	* cp-tree.h (struct lang_type): Don't have three GTY options on a
	single bit GTY desc.

java/
	* parse.y (java_complete_expand_methods, java_expand_classes): Don't
	abuse restore_line_number_status.

From-SVN: r84849
parent cd0408d8
2004-07-17 Steven Bosscher <stevenb@suse.de>
* cfgcleanup.c (try_simplify_condjump): Don't remove line
notes to avoid unreachable code warnings.
* toplev.c (backend_init): Don't emit line notes for
unreachable code warnings.
* combine.c (distribute_notes): Don't distribute a
REG_VTABLE_REF note.
* final.c (final_scan_insn): Don't handle it.
* rtl.c (reg_note_name): Remove it.
* rtl.h (enum reg_node): Dito.
* emit-rtl.c (force_line_numbers, restore_line_number_status):
Remove.
* rtl.h (force_line_numbers, restore_line_number_status):
Remove prototypes.
* stmt.c (using_eh_for_cleanups_p, using_eh_for_cleanups): Move...
* tree-eh.c (using_eh_for_cleanups_p): ...here. Make static.
(using_eh_for_cleanups): Also moved here.
* expr.c (expand_expr_real_1) <CASE_LABEL_EXPR>: Die if we see one.
<SWITCH_EXPR>: Die if we have a non-NULL SWITCH_BODY. Update calls
to expand_start_case and add_case_node.
* stmt.c (struct nesting): Cleanup unused fields condition_code,
last_unconditional_cleanup, nominal_type, printname, and
line_number_status.
(struct fixup_goto): Remove.
(struct stmt_status): Remove x_goto_fixup_chain field.
(goto_fixup_chain): Remove.
(strip_default_case_nodes, group_case_nodes, emit_jump_if_reachable,
pushcase, pushcase_range): Remove.
(expand_start_bindings_and_block): Don't set unused fields in
the nesting stack.
(expand_start_case, add_case_node): Cleanup unused formal arguments.
(expand_end_case_type): Don't simplify the case-list. Use emit_jump
instead of emit_jump_if_reachable.
(emit_case_nodes): Likewise.
* tree-cfg.c (group_case_labels, cleanup_dead_labels): No longer
static.
(update_eh_label): Work around left-over exception handing regions.
* tree-flow.h (group_case_labels, cleanup_dead_labels): Add protos.
* tree-optimize.c (execute_cleanup_cfg_post_optimizing): New function.
(pass_cleanup_cfg_post_optimizing): New pass.
(init_tree_optimization_passes): Run the new pass after all
optimizations.
* tree.h (pushcase, pushcase_range): Remove prototypes.
(expand_start_case, add_case_node): Update prototypes.
2004-07-16 Krister Walfridsson <cato@df.lth.se>
* tree-inline.c (estimate_num_insns_1): Correct increase of count.
......
......@@ -122,8 +122,6 @@ try_simplify_condjump (basic_block cbranch_block)
basic_block jump_block, jump_dest_block, cbranch_dest_block;
edge cbranch_jump_edge, cbranch_fallthru_edge;
rtx cbranch_insn;
rtx insn, next;
rtx end;
/* Verify that there are exactly two successors. */
if (!cbranch_block->succ
......@@ -186,26 +184,6 @@ try_simplify_condjump (basic_block cbranch_block)
cbranch_fallthru_edge->flags &= ~EDGE_FALLTHRU;
update_br_prob_note (cbranch_block);
end = BB_END (jump_block);
/* Deleting a block may produce unreachable code warning even when we are
not deleting anything live. Suppress it by moving all the line number
notes out of the block. */
for (insn = BB_HEAD (jump_block); insn != NEXT_INSN (BB_END (jump_block));
insn = next)
{
next = NEXT_INSN (insn);
if (NOTE_P (insn) && NOTE_LINE_NUMBER (insn) > 0)
{
if (insn == BB_END (jump_block))
{
BB_END (jump_block) = PREV_INSN (insn);
if (insn == end)
break;
}
reorder_insns_nobb (insn, insn, end);
end = insn;
}
}
/* Delete the block with the unconditional jump, and clean up the mess. */
delete_basic_block (jump_block);
tidy_fallthru_edge (cbranch_jump_edge);
......
......@@ -11698,12 +11698,6 @@ distribute_notes (rtx notes, rtx from_insn, rtx i3, rtx i2)
/* Just get rid of this note, as it is unused later anyway. */
break;
case REG_VTABLE_REF:
/* ??? Should remain with *a particular* memory load. Given the
nature of vtable data, the last insn seems relatively safe. */
place = i3;
break;
case REG_NON_LOCAL_GOTO:
if (JUMP_P (i3))
place = i3;
......
2004-07-16 Steven Bosscher <stevenb@suse.de>
* cp-tree.h (struct lang_type): Don't have three GTY options on a
single bit GTY desc.
2004-07-16 Richard Henderson <rth@redhat.com>
* cp-lang.c (LANG_HOOKS_TREE_INLINING_COPY_RES_DECL_FOR_INLINING): Die.
......
......@@ -1033,7 +1033,7 @@ struct lang_type GTY(())
{
union lang_type_u
{
struct lang_type_header GTY((tag ("2"))) h;
struct lang_type_header GTY((skip (""))) h;
struct lang_type_class GTY((tag ("1"))) c;
struct lang_type_ptrmem GTY((tag ("0"))) ptrmem;
} GTY((desc ("%h.h.is_lang_type_class"))) u;
......
......@@ -5438,27 +5438,6 @@ init_emit_once (int line_numbers)
pic_offset_table_rtx = gen_raw_REG (Pmode, PIC_OFFSET_TABLE_REGNUM);
}
/* Query and clear/ restore no_line_numbers. This is used by the
switch / case handling in stmt.c to give proper line numbers in
warnings about unreachable code. */
int
force_line_numbers (void)
{
int old = no_line_numbers;
no_line_numbers = 0;
if (old)
force_next_line_note ();
return old;
}
void
restore_line_number_status (int old_value)
{
no_line_numbers = old_value;
}
/* Produce exact duplicate of insn INSN after AFTER.
Care updating of libcall regions if present. */
......
......@@ -8541,6 +8541,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
case WITH_CLEANUP_EXPR:
case CLEANUP_POINT_EXPR:
case TARGET_EXPR:
case CASE_LABEL_EXPR:
case VA_ARG_EXPR:
/* Lowered by gimplify.c. */
abort ();
......@@ -8561,10 +8562,11 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
abort ();
case SWITCH_EXPR:
expand_start_case (0, SWITCH_COND (exp), integer_type_node,
"switch");
expand_start_case (SWITCH_COND (exp));
/* The switch body is lowered in gimplify.c, we should never have
switches with a non-NULL SWITCH_BODY here. */
if (SWITCH_BODY (exp))
expand_expr_stmt (SWITCH_BODY (exp));
abort ();
if (SWITCH_LABELS (exp))
{
tree duplicate = 0;
......@@ -8623,7 +8625,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
}
}
add_case_node (case_low, case_high, CASE_LABEL (elt), &duplicate, true);
add_case_node (case_low, case_high, CASE_LABEL (elt), &duplicate);
if (duplicate)
abort ();
}
......@@ -8635,16 +8637,6 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
expand_label (TREE_OPERAND (exp, 0));
return const0_rtx;
case CASE_LABEL_EXPR:
{
tree duplicate = 0;
add_case_node (CASE_LOW (exp), CASE_HIGH (exp), CASE_LABEL (exp),
&duplicate, false);
if (duplicate)
abort ();
return const0_rtx;
}
case ASM_EXPR:
expand_asm_expr (exp);
return const0_rtx;
......
......@@ -1999,7 +1999,6 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
rtx body = PATTERN (insn);
int insn_code_number;
const char *template;
rtx note;
/* An INSN, JUMP_INSN or CALL_INSN.
First check for special kinds that recog doesn't recognize. */
......@@ -2549,18 +2548,6 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
dwarf2out_frame_debug (insn);
#endif
#if 0
/* It's not at all clear why we did this and doing so used to
interfere with tests that used REG_WAS_0 notes, which are
now gone, so let's try with this out. */
/* Mark this insn as having been output. */
INSN_DELETED_P (insn) = 1;
#endif
/* Emit information for vtable gc. */
note = find_reg_note (insn, REG_VTABLE_REF, NULL_RTX);
current_output_insn = debug_insn = 0;
}
}
......
......@@ -1066,7 +1066,7 @@ compare_case_labels (const void *p1, const void *p2)
return tree_int_cst_compare (CASE_LOW (case1), CASE_LOW (case2));
}
/* Sort the case labels in LABEL_VEC in ascending order. */
/* Sort the case labels in LABEL_VEC in place in ascending order. */
void
sort_case_labels (tree label_vec)
......
2004-07-16 Steven Bosscher <stevenb@suse.de>
* parse.y (java_complete_expand_methods, java_expand_classes): Don't
abuse restore_line_number_status.
2004-07-15 Frank Ch. Eigler <fche@redhat.com>
g++/15861
......
......@@ -7742,21 +7742,9 @@ java_complete_expand_methods (tree class_decl)
/* Now do the constructors */
for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
{
int no_body;
if (!DECL_CONSTRUCTOR_P (decl))
continue;
no_body = !DECL_FUNCTION_BODY (decl);
/* Don't generate debug info on line zero when expanding a
generated constructor. */
if (no_body)
restore_line_number_status (1);
java_complete_expand_method (decl);
if (no_body)
restore_line_number_status (0);
}
/* First, do the ordinary methods. */
......@@ -9032,9 +9020,7 @@ java_expand_classes (void)
{
if (DECL_CONSTRUCTOR_P (d))
{
restore_line_number_status (1);
java_complete_expand_method (d);
restore_line_number_status (0);
break; /* There is only one constructor. */
}
}
......@@ -9056,11 +9042,7 @@ java_expand_classes (void)
for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
{
if (DECL_RESULT (d) == NULL_TREE)
{
restore_line_number_status (1);
java_complete_expand_method (d);
restore_line_number_status (0);
}
java_complete_expand_method (d);
}
}
}
......@@ -9089,9 +9071,7 @@ java_expand_classes (void)
if (DECL_RESULT (d) == NULL_TREE)
{
something_changed = 1;
restore_line_number_status (1);
java_complete_expand_method (d);
restore_line_number_status (0);
}
}
}
......
......@@ -136,8 +136,7 @@ const char * const reg_note_name[] =
"REG_VALUE_PROFILE", "REG_NOALIAS", "REG_SAVE_AREA", "REG_BR_PRED",
"REG_FRAME_RELATED_EXPR", "REG_EH_CONTEXT", "REG_EH_REGION",
"REG_SAVE_NOTE", "REG_MAYBE_DEAD", "REG_NORETURN",
"REG_NON_LOCAL_GOTO", "REG_CROSSING_JUMP", "REG_SETJMP", "REG_ALWAYS_RETURN",
"REG_VTABLE_REF"
"REG_NON_LOCAL_GOTO", "REG_CROSSING_JUMP", "REG_SETJMP", "REG_ALWAYS_RETURN"
};
......
......@@ -865,11 +865,7 @@ enum reg_note
REG_SETJMP,
/* Indicate calls that always returns. */
REG_ALWAYS_RETURN,
/* Indicate that the memory load references a vtable. The expression
is of the form (plus (symbol_ref vtable_sym) (const_int offset)). */
REG_VTABLE_REF
REG_ALWAYS_RETURN
};
/* The base value for branch probability notes. */
......@@ -2200,11 +2196,6 @@ extern void remove_insn (rtx);
extern void emit_insn_after_with_line_notes (rtx, rtx, rtx);
extern enum rtx_code classify_insn (rtx);
extern rtx emit (rtx);
/* Query and clear/ restore no_line_numbers. This is used by the
switch / case handling in stmt.c to give proper line numbers in
warnings about unreachable code. */
int force_line_numbers (void);
void restore_line_number_status (int old_value);
extern void renumber_insns (FILE *);
extern void remove_unnecessary_notes (void);
extern rtx delete_insn (rtx);
......
......@@ -1926,8 +1926,7 @@ backend_init (void)
/* Enable line number info for traceback. */
|| debug_info_level > DINFO_LEVEL_NONE
#endif
|| flag_test_coverage
|| warn_notreached);
|| flag_test_coverage);
init_regs ();
init_fake_stack_mems ();
......
......@@ -99,8 +99,6 @@ static void tree_cfg2vcg (FILE *);
static void tree_merge_blocks (basic_block, basic_block);
static bool tree_can_merge_blocks_p (basic_block, basic_block);
static void remove_bb (basic_block);
static void group_case_labels (void);
static void cleanup_dead_labels (void);
static bool cleanup_control_flow (void);
static bool cleanup_control_expr_graph (basic_block, block_stmt_iterator);
static edge find_taken_edge_cond_expr (basic_block, tree);
......@@ -769,7 +767,16 @@ update_eh_label (struct eh_region *region)
tree old_label = get_eh_region_tree_label (region);
if (old_label)
{
tree new_label = label_for_bb[label_to_block (old_label)->index];
tree new_label;
basic_block bb = label_to_block (old_label);
/* ??? After optimizing, there may be EH regions with labels
that have already been removed from the function body, so
there is no basic block for them. */
if (! bb)
return;
new_label = label_for_bb[bb->index];
set_eh_region_tree_label (region, new_label);
}
}
......@@ -791,7 +798,7 @@ main_block_label (tree label)
2) Redirect all references to labels to the leading labels.
3) Cleanup all useless labels. */
static void
void
cleanup_dead_labels (void)
{
basic_block bb;
......@@ -924,7 +931,7 @@ cleanup_dead_labels (void)
same label.
Eg. three separate entries 1: 2: 3: become one entry 1..3: */
static void
void
group_case_labels (void)
{
basic_block bb;
......
......@@ -37,8 +37,15 @@ Boston, MA 02111-1307, USA. */
#include "langhooks.h"
#include "ggc.h"
/* HACK */
extern int using_eh_for_cleanups_p;
/* Nonzero if we are using EH to handle cleanups. */
static int using_eh_for_cleanups_p = 0;
void
using_eh_for_cleanups (void)
{
using_eh_for_cleanups_p = 1;
}
/* Misc functions used in this file. */
......
......@@ -473,6 +473,8 @@ extern void dump_cfg_stats (FILE *);
extern void debug_cfg_stats (void);
extern void debug_loop_ir (void);
extern void print_loop_ir (FILE *);
extern void cleanup_dead_labels (void);
extern void group_case_labels (void);
extern void cleanup_tree_cfg (void);
extern tree first_stmt (basic_block);
extern tree last_stmt (basic_block);
......
......@@ -101,6 +101,35 @@ static struct tree_opt_pass pass_all_optimizations =
0 /* todo_flags_finish */
};
/* Pass: cleanup the CFG just before expanding trees to RTL.
This is just a round of label cleanups and case node grouping
because after the tree optimizers have run such cleanups may
be necessary. */
static void
execute_cleanup_cfg_post_optimizing (void)
{
cleanup_tree_cfg ();
cleanup_dead_labels ();
group_case_labels ();
}
static struct tree_opt_pass pass_cleanup_cfg_post_optimizing =
{
NULL, /* name */
NULL, /* gate */
execute_cleanup_cfg_post_optimizing, /* execute */
NULL, /* sub */
NULL, /* next */
0, /* static_pass_number */
0, /* tv_id */
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
0 /* todo_flags_finish */
};
/* Pass: do the actions required to finish with tree-ssa optimization
passes. */
......@@ -324,6 +353,7 @@ init_tree_optimization_passes (void)
NEXT_PASS (pass_del_ssa);
NEXT_PASS (pass_nrv);
NEXT_PASS (pass_remove_useless_vars);
NEXT_PASS (pass_cleanup_cfg_post_optimizing);
*p = NULL;
p = &pass_loop.sub;
......
......@@ -3352,12 +3352,12 @@ extern void warn_about_unused_variables (tree);
extern int is_body_block (tree);
extern struct nesting * current_nesting_level (void);
extern void expand_start_case (int, tree, tree, const char *);
extern void expand_start_case (tree);
extern void expand_end_case_type (tree, tree);
#define expand_end_case(cond) expand_end_case_type (cond, NULL)
extern int add_case_node (tree, tree, tree, tree *, bool);
extern int pushcase (tree, tree (*) (tree, tree), tree, tree *);
extern int pushcase_range (tree, tree, tree (*) (tree, tree), tree, tree *);
extern int add_case_node (tree, tree, tree, tree *);
/* In tree-eh.c */
extern void using_eh_for_cleanups (void);
/* In fold-const.c */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment