diff options
author | rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-06 14:46:34 +0000 |
---|---|---|
committer | rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-06 14:46:34 +0000 |
commit | 39257eb5672ddccb54a5527dafc85fc8522f8aa8 (patch) | |
tree | 83547529d1afe3a91257ca4399bfb3001703c6a9 | |
parent | eb7d9cdc889a5abede7c7927d707882401f04654 (diff) | |
download | gcc-39257eb5672ddccb54a5527dafc85fc8522f8aa8.tar.gz |
* haifa-sched.c (restore_bb_notes): Clear bb field of the notes
emited outside of basic block.
* cfgbuild.c (find_bb_boundaries): Clear bb field for insns between
the created blocks.
* rtl.h (delete_insn_chain): Declaration changed.
* cfgrtl.c (delete_insn_chain): Add option to clear bb field for
non-removed insns.
(rtl_delete_block, rtl_merge_blocks): Pass true to delete_insn_chain.
(delete_insn_chain_and_edges, try_redirect_by_replacing_jump,
rtl_tidy_fallthru_edge, cfg_layout_merge_blocks): Pass false
to delete_insn_chain.
(rtl_verify_flow_info_1): Verify that the insns in header and footer
do not have bb field set.
(rtl_verify_flow_info): Verify that insns between basic blocks do not
have bb field set.
* recog.c (peephole2_optimize): Add argument to delete_insn_chain call.
* cfgcleanup.c (try_optimize_cfg): Ditto.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125492 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 20 | ||||
-rw-r--r-- | gcc/cfgbuild.c | 34 | ||||
-rw-r--r-- | gcc/cfgcleanup.c | 2 | ||||
-rw-r--r-- | gcc/cfgrtl.c | 76 | ||||
-rw-r--r-- | gcc/haifa-sched.c | 5 | ||||
-rw-r--r-- | gcc/recog.c | 2 | ||||
-rw-r--r-- | gcc/rtl.h | 2 |
7 files changed, 118 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0d19d01d0d5..24097297e50 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2007-06-06 Zdenek Dvorak <dvorakz@suse.cz> + + * haifa-sched.c (restore_bb_notes): Clear bb field of the notes + emited outside of basic block. + * cfgbuild.c (find_bb_boundaries): Clear bb field for insns between + the created blocks. + * rtl.h (delete_insn_chain): Declaration changed. + * cfgrtl.c (delete_insn_chain): Add option to clear bb field for + non-removed insns. + (rtl_delete_block, rtl_merge_blocks): Pass true to delete_insn_chain. + (delete_insn_chain_and_edges, try_redirect_by_replacing_jump, + rtl_tidy_fallthru_edge, cfg_layout_merge_blocks): Pass false + to delete_insn_chain. + (rtl_verify_flow_info_1): Verify that the insns in header and footer + do not have bb field set. + (rtl_verify_flow_info): Verify that insns between basic blocks do not + have bb field set. + * recog.c (peephole2_optimize): Add argument to delete_insn_chain call. + * cfgcleanup.c (try_optimize_cfg): Ditto. + 2007-06-06 Thomas Neumann <tneumann@users.sourceforge.net> * lambda-code.c (struct lambda_lattice_s): Add a name to the struct. diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c index e564e8b89e3..cb216afa2c7 100644 --- a/gcc/cfgbuild.c +++ b/gcc/cfgbuild.c @@ -630,7 +630,7 @@ find_bb_boundaries (basic_block bb) { basic_block orig_bb = bb; rtx insn = BB_HEAD (bb); - rtx end = BB_END (bb); + rtx end = BB_END (bb), x; rtx table; rtx flow_transfer_insn = NULL_RTX; edge fallthru = NULL; @@ -651,7 +651,16 @@ find_bb_boundaries (basic_block bb) { fallthru = split_block (bb, PREV_INSN (insn)); if (flow_transfer_insn) - BB_END (bb) = flow_transfer_insn; + { + BB_END (bb) = flow_transfer_insn; + + /* Clean up the bb field for the insns between the blocks. */ + for (x = NEXT_INSN (flow_transfer_insn); + x != BB_HEAD (fallthru->dest); + x = NEXT_INSN (x)) + if (!BARRIER_P (x)) + set_block_for_insn (x, NULL); + } bb = fallthru->dest; remove_edge (fallthru); @@ -666,6 +675,14 @@ find_bb_boundaries (basic_block bb) { fallthru = split_block (bb, PREV_INSN (insn)); BB_END (bb) = flow_transfer_insn; + + /* Clean up the bb field for the insns between the blocks. */ + for (x = NEXT_INSN (flow_transfer_insn); + x != BB_HEAD (fallthru->dest); + x = NEXT_INSN (x)) + if (!BARRIER_P (x)) + set_block_for_insn (x, NULL); + bb = fallthru->dest; remove_edge (fallthru); flow_transfer_insn = NULL_RTX; @@ -682,7 +699,18 @@ find_bb_boundaries (basic_block bb) return and barrier, or possibly other sequence not behaving like ordinary jump, we need to take care and move basic block boundary. */ if (flow_transfer_insn) - BB_END (bb) = flow_transfer_insn; + { + BB_END (bb) = flow_transfer_insn; + + /* Clean up the bb field for the insns that do not belong to BB. */ + x = flow_transfer_insn; + while (x != end) + { + x = NEXT_INSN (x); + if (!BARRIER_P (x)) + set_block_for_insn (x, NULL); + } + } /* We've possibly replaced the conditional jump by conditional jump followed by cleanup at fallthru edge, so the outgoing edges may diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 54d2321d60e..dafdcd5df75 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -1999,7 +1999,7 @@ try_optimize_cfg (int mode) { rtx label = BB_HEAD (b); - delete_insn_chain (label, label); + delete_insn_chain (label, label, false); /* In the case label is undeletable, move it after the BASIC_BLOCK note. */ if (NOTE_KIND (BB_HEAD (b)) == NOTE_INSN_DELETED_LABEL) diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index 11deebc2cd9..5655eef1527 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -195,10 +195,11 @@ delete_insn_and_edges (rtx insn) } /* Unlink a chain of insns between START and FINISH, leaving notes - that must be paired. */ + that must be paired. If CLEAR_BB is true, we set bb field for + insns that cannot be removed to NULL. */ void -delete_insn_chain (rtx start, rtx finish) +delete_insn_chain (rtx start, rtx finish, bool clear_bb) { rtx next; @@ -213,6 +214,9 @@ delete_insn_chain (rtx start, rtx finish) else next = delete_insn (start); + if (clear_bb && !INSN_DELETED_P (start)) + set_block_for_insn (start, NULL); + if (start == finish) break; start = next; @@ -229,7 +233,7 @@ delete_insn_chain_and_edges (rtx first, rtx last) && BLOCK_FOR_INSN (last) && BB_END (BLOCK_FOR_INSN (last)) == last) purge = true; - delete_insn_chain (first, last); + delete_insn_chain (first, last, false); if (purge) purge_dead_edges (BLOCK_FOR_INSN (last)); } @@ -370,7 +374,8 @@ rtl_delete_block (basic_block b) /* Selectively delete the entire chain. */ BB_HEAD (b) = NULL; - delete_insn_chain (insn, end); + delete_insn_chain (insn, end, true); + if (b->il.rtl->global_live_at_start) { FREE_REG_SET (b->il.rtl->global_live_at_start); @@ -608,7 +613,7 @@ rtl_merge_blocks (basic_block a, basic_block b) /* Delete everything marked above as well as crap that might be hanging out between the two blocks. */ BB_HEAD (b) = NULL; - delete_insn_chain (del_first, del_last); + delete_insn_chain (del_first, del_last, true); /* Reassociate the insns of B with A. */ if (!b_empty) @@ -745,7 +750,7 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) { rtx insn = src->il.rtl->footer; - delete_insn_chain (kill_from, BB_END (src)); + delete_insn_chain (kill_from, BB_END (src), false); /* Remove barriers but keep jumptables. */ while (insn) @@ -765,7 +770,8 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) } } else - delete_insn_chain (kill_from, PREV_INSN (BB_HEAD (target))); + delete_insn_chain (kill_from, PREV_INSN (BB_HEAD (target)), + false); } /* If this already is simplejump, redirect it. */ @@ -801,13 +807,13 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) INSN_UID (insn), INSN_UID (BB_END (src))); - delete_insn_chain (kill_from, insn); + delete_insn_chain (kill_from, insn, false); /* Recognize a tablejump that we are converting to a simple jump and remove its associated CODE_LABEL and ADDR_VEC or ADDR_DIFF_VEC. */ if (tablejump_p (insn, &label, &table)) - delete_insn_chain (label, table); + delete_insn_chain (label, table, false); barrier = next_nonnote_insn (BB_END (src)); if (!barrier || !BARRIER_P (barrier)) @@ -1217,7 +1223,7 @@ rtl_tidy_fallthru_edge (edge e) /* Selectively unlink the sequence. */ if (q != PREV_INSN (BB_HEAD (c))) - delete_insn_chain (NEXT_INSN (q), PREV_INSN (BB_HEAD (c))); + delete_insn_chain (NEXT_INSN (q), PREV_INSN (BB_HEAD (c)), false); e->flags |= EDGE_FALLTHRU; } @@ -1715,6 +1721,23 @@ rtl_verify_flow_info_1 (void) bb->index); err = 1; } + + for (insn = bb->il.rtl->header; insn; insn = NEXT_INSN (insn)) + if (!BARRIER_P (insn) + && BLOCK_FOR_INSN (insn) != NULL) + { + error ("insn %d in header of bb %d has non-NULL basic block", + INSN_UID (insn), bb->index); + err = 1; + } + for (insn = bb->il.rtl->footer; insn; insn = NEXT_INSN (insn)) + if (!BARRIER_P (insn) + && BLOCK_FOR_INSN (insn) != NULL) + { + error ("insn %d in footer of bb %d has non-NULL basic block", + INSN_UID (insn), bb->index); + err = 1; + } } /* Now check the basic blocks (boundaries etc.) */ @@ -1918,10 +1941,21 @@ rtl_verify_flow_info (void) rtx head = BB_HEAD (bb); rtx end = BB_END (bb); - /* Verify the end of the basic block is in the INSN chain. */ for (x = last_head; x != NULL_RTX; x = PREV_INSN (x)) - if (x == end) - break; + { + /* Verify the end of the basic block is in the INSN chain. */ + if (x == end) + break; + + /* And that the code outside of basic blocks has NULL bb field. */ + if (!BARRIER_P (x) + && BLOCK_FOR_INSN (x) != NULL) + { + error ("insn %d outside of basic blocks has non-NULL bb field", + INSN_UID (x)); + err = 1; + } + } if (!x) { @@ -1955,7 +1989,7 @@ rtl_verify_flow_info (void) err = 1; } - last_head = x; + last_head = PREV_INSN (x); FOR_EACH_EDGE (e, ei, bb->succs) if (e->flags & EDGE_FALLTHRU) @@ -2000,6 +2034,18 @@ rtl_verify_flow_info (void) } } + for (x = last_head; x != NULL_RTX; x = PREV_INSN (x)) + { + /* Check that the code before the first basic block has NULL + bb field. */ + if (!BARRIER_P (x) + && BLOCK_FOR_INSN (x) != NULL) + { + error ("insn %d outside of basic blocks has non-NULL bb field", + INSN_UID (x)); + err = 1; + } + } free (bb_info); num_bb_notes = 0; @@ -2550,7 +2596,7 @@ cfg_layout_merge_blocks (basic_block a, basic_block b) rtx first = BB_END (a), last; last = emit_insn_after_noloc (b->il.rtl->header, BB_END (a)); - delete_insn_chain (NEXT_INSN (first), last); + delete_insn_chain (NEXT_INSN (first), last, false); b->il.rtl->header = NULL; } diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c index 5696db04439..cf026446194 100644 --- a/gcc/haifa-sched.c +++ b/gcc/haifa-sched.c @@ -4080,8 +4080,9 @@ extend_bb (void) /* Don't emit a NOTE if it would end up before a BARRIER. */ && !BARRIER_P (NEXT_INSN (insn)))) { - emit_note_after (NOTE_INSN_DELETED, insn); - /* Make insn to appear outside BB. */ + rtx note = emit_note_after (NOTE_INSN_DELETED, insn); + /* Make insn appear outside BB. */ + set_block_for_insn (note, NULL); BB_END (EXIT_BLOCK_PTR->prev_bb) = insn; } } diff --git a/gcc/recog.c b/gcc/recog.c index 1b81704d537..19b6cb2f89c 100644 --- a/gcc/recog.c +++ b/gcc/recog.c @@ -3214,7 +3214,7 @@ peephole2_optimize (void) try = emit_insn_after_setloc (try, peep2_insn_data[i].insn, INSN_LOCATOR (peep2_insn_data[i].insn)); before_try = PREV_INSN (insn); - delete_insn_chain (insn, peep2_insn_data[i].insn); + delete_insn_chain (insn, peep2_insn_data[i].insn, false); /* Re-insert the EH_REGION notes. */ if (note || (was_call && nonlocal_goto_handler_labels)) diff --git a/gcc/rtl.h b/gcc/rtl.h index 61c40f5e373..2934eabd192 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2062,7 +2062,7 @@ extern rtx emit (rtx); extern rtx delete_insn (rtx); extern rtx entry_of_function (void); extern void emit_insn_at_entry (rtx); -extern void delete_insn_chain (rtx, rtx); +extern void delete_insn_chain (rtx, rtx, bool); extern rtx unlink_insn_chain (rtx, rtx); extern rtx delete_insn_and_edges (rtx); extern void delete_insn_chain_and_edges (rtx, rtx); |