diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2017-12-20 14:48:34 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@gcc.gnu.org> | 2017-12-20 14:48:34 +0000 |
commit | 67a8d7199fe4e474f7bd565161fa2f27d59969fc (patch) | |
tree | 6093bd1b061517b897df00a25e329bbff6c51b48 /gcc/tree-cfg.c | |
parent | 8a91d5455313fb3c4fc07935d848921012cb297f (diff) | |
download | gcc-67a8d7199fe4e474f7bd565161fa2f27d59969fc.zip gcc-67a8d7199fe4e474f7bd565161fa2f27d59969fc.tar.gz gcc-67a8d7199fe4e474f7bd565161fa2f27d59969fc.tar.bz2 |
[SFN] debug markers before labels no more
Make sure that gimple and RTL IRs don't have debug markers before
labels. When we build the CFG, we move labels before any markers
appearing before them. Then, make sure we don't mistakenly
reintroduce them.
This reverts some of the complexity that had been brought about by the
initial SFN patches.
for gcc/ChangeLog
PR bootstrap/83396
* cfgexpand.c (label_rtx_for_bb): Revert SFN changes that
allowed debug stmts before labels.
(expand_gimple_basic_block): Likewise.
* gimple-iterator.c (gimple_find_edge_insert_loc): Likewise.
* gimple-iterator.h (gsi_after_labels): Likewise.
* tree-cfgcleanup (remove_forwarder_block): Likewise, but
rename reused variable, and simplify using gsi_move_before.
* tree-ssa-tail-merge.c (find_duplicate): Likewise.
* tree-cfg.c (make_edges, cleanup_dead_labels): Likewise.
(gimple_can_merge_blocks_p, verify_gimple_in_cfg): Likewise.
(gimple_verify_flow_info, gimple_block_label): Likewise.
(make_blocks): Move debug markers after adjacent labels.
* cfgrtl.c (skip_insns_after_block): Revert SFN changes that
allowed debug insns outside blocks.
* df-scan.c (df_insn_delete): Likewise.
* lra-constraints.c (update_ebb_live_info): Likewise.
* var-tracking.c (get_first_insn, vt_emit_notes): Likewise.
(vt_initialize, delete_vta_debug_insns): Likewise.
(reemit_marker_as_note): Drop BB parm. Adjust callers.
From-SVN: r255895
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 101 |
1 files changed, 63 insertions, 38 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 48fbe52..ae5335b 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -636,6 +636,67 @@ make_blocks_1 (gimple_seq seq, basic_block bb) static void make_blocks (gimple_seq seq) { + /* Look for debug markers right before labels, and move the debug + stmts after the labels. Accepting labels among debug markers + adds no value, just complexity; if we wanted to annotate labels + with view numbers (so sequencing among markers would matter) or + somesuch, we're probably better off still moving the labels, but + adding other debug annotations in their original positions or + emitting nonbind or bind markers associated with the labels in + the original position of the labels. + + Moving labels would probably be simpler, but we can't do that: + moving labels assigns label ids to them, and doing so because of + debug markers makes for -fcompare-debug and possibly even codegen + differences. So, we have to move the debug stmts instead. To + that end, we scan SEQ backwards, marking the position of the + latest (earliest we find) label, and moving debug stmts that are + not separated from it by nondebug nonlabel stmts after the + label. */ + if (MAY_HAVE_DEBUG_MARKER_STMTS) + { + gimple_stmt_iterator label = gsi_none (); + + for (gimple_stmt_iterator i = gsi_last (seq); !gsi_end_p (i); gsi_prev (&i)) + { + gimple *stmt = gsi_stmt (i); + + /* If this is the first label we encounter (latest in SEQ) + before nondebug stmts, record its position. */ + if (is_a <glabel *> (stmt)) + { + if (gsi_end_p (label)) + label = i; + continue; + } + + /* Without a recorded label position to move debug stmts to, + there's nothing to do. */ + if (gsi_end_p (label)) + continue; + + /* Move the debug stmt at I after LABEL. */ + if (is_gimple_debug (stmt)) + { + gcc_assert (gimple_debug_nonbind_marker_p (stmt)); + /* As STMT is removed, I advances to the stmt after + STMT, so the gsi_prev in the for "increment" + expression gets us to the stmt we're to visit after + STMT. LABEL, however, would advance to the moved + stmt if we passed it to gsi_move_after, so pass it a + copy instead, so as to keep LABEL pointing to the + LABEL. */ + gimple_stmt_iterator copy = label; + gsi_move_after (&i, ©); + continue; + } + + /* There aren't any (more?) debug stmts before label, so + there isn't anything else to move after it. */ + label = gsi_none (); + } + } + make_blocks_1 (seq, ENTRY_BLOCK_PTR_FOR_FN (cfun)); } @@ -1005,11 +1066,7 @@ make_edges (void) tree target; if (!label_stmt) - { - if (is_gimple_debug (gsi_stmt (gsi))) - continue; - break; - } + break; target = gimple_label_label (label_stmt); @@ -1519,9 +1576,6 @@ 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)); @@ -1682,12 +1736,6 @@ 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)); @@ -1863,8 +1911,6 @@ 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; @@ -5431,7 +5477,6 @@ verify_gimple_in_cfg (struct function *fn, bool verify_nothrow) err |= err2; } - bool label_allowed = true; for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple *stmt = gsi_stmt (gsi); @@ -5448,19 +5493,6 @@ verify_gimple_in_cfg (struct function *fn, bool verify_nothrow) err2 = true; } - /* Labels may be preceded only by debug markers, not debug bind - or source bind or any other statements. */ - if (gimple_code (stmt) == GIMPLE_LABEL) - { - if (!label_allowed) - { - error ("gimple label in the middle of a basic block"); - err2 = true; - } - } - else if (!gimple_debug_begin_stmt_p (stmt)) - label_allowed = false; - err2 |= verify_gimple_stmt (stmt); err2 |= verify_location (&blocks, gimple_location (stmt)); @@ -5584,10 +5616,6 @@ 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); @@ -5912,10 +5940,8 @@ gimple_block_label (basic_block bb) tree label; glabel *stmt; - for (i = s; !gsi_end_p (i); gsi_next (&i)) + for (i = s; !gsi_end_p (i); first = false, gsi_next (&i)) { - if (is_gimple_debug (gsi_stmt (i))) - continue; stmt = dyn_cast <glabel *> (gsi_stmt (i)); if (!stmt) break; @@ -5926,7 +5952,6 @@ gimple_block_label (basic_block bb) gsi_move_before (&i, &s); return label; } - first = false; } label = create_artificial_label (UNKNOWN_LOCATION); |