aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2017-12-12 02:15:30 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2017-12-12 02:15:30 +0000
commit65f4b8759bda30d63404acb381b24a2ec960e667 (patch)
treec93804c181ab43d09f05acc90198b1f0fdd213e8 /gcc/tree-cfg.c
parent36f52e8f0812546e6cb533b384b29f56570624ff (diff)
downloadgcc-65f4b8759bda30d63404acb381b24a2ec960e667.zip
gcc-65f4b8759bda30d63404acb381b24a2ec960e667.tar.gz
gcc-65f4b8759bda30d63404acb381b24a2ec960e667.tar.bz2
[SFN] not-quite-boilerplate changes in preparation to introduce nonbind markers
This patch adjusts numerous parts of the compiler that would malfunction should they find debug markers at points where they may be introduced. The changes purport to allow the compiler to pass bootstrap-debug-lean (-fcompare-debug in stage3) at various optimization levels, as well as bootstrap-debug-lib (-fcompare-debug for target libraries), even after the compiler is changed so that debug markers are introduced in code streams at spots where earlier debug stmts, insns and notes wouldn't normally appear. This patch depends on an earlier SFN boilerplate patch, and on another SFN patch that introduces new RTL insn-walking functions. for gcc/ChangeLog * cfgcleanup.c (delete_unreachable_blocks): Use alternate block removal order if MAY_HAVE_DEBUG_BIND_INSNS. * cfgexpand.c (label_rtx_for_bb): Skip debug insns. * cfgrtl.c (try_redirect_by_replacing_jump): Skip debug insns. (rtl_tidy_fallthru_edge): Likewise. (rtl_verify_fallthru): Likewise. (rtl_verify_bb_layout): Likewise. (skip_insns_after_block): Likewise. (duplicate_insn_chain): Use DEBUG_BIND_INSN_P. * dwarf2out.c: Include print-rtl.h. (dwarf2out_next_real_insn): New. (dwarf2out_var_location): Call it. Disregard begin stmt markers. Dump debug binds in asm comments. * gimple-iterator.c (gimple_find_edge_insert_loc): Skip debug stmts. * gimple-iterator.h (gsi_start_bb_nondebug): Remove; adjust callers to use gsi_start_nondebug_bb instead. (gsi_after_labels): Skip gimple debug stmts. (gsi_start_nondebug): New. * gimple-loop-interchange.c (find_deps_in_bb_for_stmt): Adjust. (proper_loop_form_for_interchange): Adjust. * gimple-low.c (gimple_seq_may_fallthru): Take last nondebug stmt. * gimple.h (gimple_seq_last_nondebug_stmt): New. * gimplify.c (last_stmt_in_scope): Skip debug stmts. (collect_fallthrough_labels): Likewise. (should_warn_for_implicit_fallthrough): Likewise. (warn_implicit_fallthrough_r): Likewise. (expand_FALLTHROUGH_r): Likewise. * graphite-isl-ast-to-gimple.c (gsi_insert_earliest): Adjust. (graphite_copy_stmts_from_block): Skip nonbind markers. * haifa-sched.c (sched_extend_bb): Skip debug insns. * ipa-icf-gimple.c (func_checker::compare_bb): Adjust. * jump.c (clean_barriers): Skip debug insns. * omp-expand.c (expand_parallel_call): Skip debug insns. (expand_task_call): Likewise. (remove_exit_barrier): Likewise. (expand_omp_taskreg): Likewise. (expand_omp_for_init_counts): Likewise. (expand_omp_for_generic): Likewise. (expand_omp_for_static_nochunk): Likewise. (expand_omp_for_static_chunk): Likewise. (expand_omp_simd): Likewise. (expand_omp_taskloop_for_outer): Likewise. (expand_omp_taskloop_for_inner): Likewise. (expand_oacc_for): Likewise. (expand_omp_sections): Likewise. (expand_omp_single): Likewise. (expand_omp_synch): Likewise. (expand_omp_atomic_load): Likewise. (expand_omp_atomic_store): Likewise. (expand_omp_atomic_fetch_op): Likewise. (expand_omp_atomic_pipeline): Likewise. (expand_omp_atomic_mutex): Likewise. (expand_omp_target): Likewise. (grid_expand_omp_for_loop): Likewise. (grid_expand_target_grid_body): Likewise. (build_omp_regions_1): Likewise. * omp-low.c (check_combined_parallel): Skip debug stmts. * postreload.c (fixup_debug_insns): Skip nonbind debug insns. * regcprop.c (find_oldest_value_reg): Ensure REGNO is not a pseudo. * sese.c (sese_trivially_empty_bb_p): Call is_gimple_debug in test. * tree-cfg.c (make_blobs_1): Skip debug stmts. (make_edges): Likewise. (cleanup_dead_labels): Likewise. (gimple_can_merge_blocks_p): Likewise. (stmt_starts_bb_p): Likewise. (gimple_block_label): Likewise. (gimple_redirect_edge_and_branch): Likewise. * tree-cfgcleanup.c (remove_forwarder_block): Rearrange skipping of debug stmts. (execute_cleanup_cfg_post_optimizing): Dump enumerated decls with TDF_SLIM. * tree-pretty-print (print_declaration): Omit initializer in slim dumps. * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Mark begin stmt markers. (eliminate_unnecessary_stmts): Stabilize block removal order. * tree-ssa-tail-merge.c (find_duplicate): Skip debug stmts. * var-tracking.c (get_first_insn): New. (vt_emit_notes): Call it. (vt_initialize): Walk any insns before the first BB. (delete_debug_insns): Likewise. From-SVN: r255566
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c52
1 files changed, 45 insertions, 7 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 00f8661..b00a291 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -561,14 +561,22 @@ make_blocks_1 (gimple_seq seq, basic_block bb)
{
gimple_stmt_iterator i = gsi_start (seq);
gimple *stmt = NULL;
+ gimple *prev_stmt = NULL;
bool start_new_block = true;
bool first_stmt_of_seq = true;
while (!gsi_end_p (i))
{
- gimple *prev_stmt;
-
- prev_stmt = stmt;
+ /* PREV_STMT should only be set to a debug stmt if the debug
+ stmt is before nondebug stmts. Once stmt reaches a nondebug
+ nonlabel, prev_stmt will be set to it, so that
+ stmt_starts_bb_p will know to start a new block if a label is
+ found. However, if stmt was a label after debug stmts only,
+ keep the label in prev_stmt even if we find further debug
+ stmts, for there may be other labels after them, and they
+ should land in the same block. */
+ if (!prev_stmt || !stmt || !is_gimple_debug (stmt))
+ prev_stmt = stmt;
stmt = gsi_stmt (i);
if (stmt && is_gimple_call (stmt))
@@ -583,6 +591,7 @@ make_blocks_1 (gimple_seq seq, basic_block bb)
gsi_split_seq_before (&i, &seq);
bb = create_basic_block (seq, bb);
start_new_block = false;
+ prev_stmt = NULL;
}
/* Now add STMT to BB and create the subgraphs for special statement
@@ -996,7 +1005,11 @@ make_edges (void)
tree target;
if (!label_stmt)
- break;
+ {
+ if (is_gimple_debug (gsi_stmt (gsi)))
+ continue;
+ break;
+ }
target = gimple_label_label (label_stmt);
@@ -1506,6 +1519,9 @@ cleanup_dead_labels (void)
for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
{
+ if (is_gimple_debug (gsi_stmt (i)))
+ continue;
+
tree label;
glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (i));
@@ -1666,6 +1682,12 @@ cleanup_dead_labels (void)
for (i = gsi_start_bb (bb); !gsi_end_p (i); )
{
+ if (is_gimple_debug (gsi_stmt (i)))
+ {
+ gsi_next (&i);
+ continue;
+ }
+
tree label;
glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (i));
@@ -1841,6 +1863,8 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b)
gsi_next (&gsi))
{
tree lab;
+ if (is_gimple_debug (gsi_stmt (gsi)))
+ continue;
glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (gsi));
if (!label_stmt)
break;
@@ -2642,6 +2666,13 @@ stmt_starts_bb_p (gimple *stmt, gimple *prev_stmt)
if (stmt == NULL)
return false;
+ /* PREV_STMT is only set to a debug stmt if the debug stmt is before
+ any nondebug stmts in the block. We don't want to start another
+ block in this case: the debug stmt will already have started the
+ one STMT would start if we weren't outputting debug stmts. */
+ if (prev_stmt && is_gimple_debug (prev_stmt))
+ return false;
+
/* Labels start a new basic block only if the preceding statement
wasn't a label of the same type. This prevents the creation of
consecutive blocks that have nothing but a single label. */
@@ -5488,6 +5519,10 @@ gimple_verify_flow_info (void)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
tree label;
+
+ if (is_gimple_debug (gsi_stmt (gsi)))
+ continue;
+
gimple *prev_stmt = stmt;
stmt = gsi_stmt (gsi);
@@ -5557,7 +5592,7 @@ gimple_verify_flow_info (void)
}
}
- gsi = gsi_last_bb (bb);
+ gsi = gsi_last_nondebug_bb (bb);
if (gsi_end_p (gsi))
continue;
@@ -5812,8 +5847,10 @@ gimple_block_label (basic_block bb)
tree label;
glabel *stmt;
- for (i = s; !gsi_end_p (i); first = false, gsi_next (&i))
+ for (i = s; !gsi_end_p (i); gsi_next (&i))
{
+ if (is_gimple_debug (gsi_stmt (i)))
+ continue;
stmt = dyn_cast <glabel *> (gsi_stmt (i));
if (!stmt)
break;
@@ -5824,6 +5861,7 @@ gimple_block_label (basic_block bb)
gsi_move_before (&i, &s);
return label;
}
+ first = false;
}
label = create_artificial_label (UNKNOWN_LOCATION);
@@ -5899,7 +5937,7 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
return ret;
}
- gsi = gsi_last_bb (bb);
+ gsi = gsi_last_nondebug_bb (bb);
stmt = gsi_end_p (gsi) ? NULL : gsi_stmt (gsi);
switch (stmt ? gimple_code (stmt) : GIMPLE_ERROR_MARK)