This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] cfgrtl.c: Remove commit_edge_insertions_watch_calls.
- From: Kazu Hirata <kazu at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: jh at suse dot cz
- Date: Mon, 29 May 2006 06:04:35 -0700
- Subject: [patch] cfgrtl.c: Remove commit_edge_insertions_watch_calls.
Hi,
Attached is a patch to remove commit_edge_insertions_watch_calls as it
is unused.
Once it is removed, then commit_one_edge_insertion is always called
with its second argument being false, allowing me to remove the first
"if" statement in commit_one_edge_insertion and adjust the caller of
the function.
Once the "if" statement is removed, then both "before" and "after" are
NULL_RTX at the beginning of the new first "if" statement, so we can remove
if (!before && !after)
Unfortunately, this causes indentation changes, but I hope the patch
is otherwise self-explanatory.
According to
http://gcc.gnu.org/viewcvs/trunk/gcc/cfgrtl.c?r1=50355&r2=50354&pathrev=50355
Honza added commit_edge_insertions_watch_calls and one use of it in
profile.c, but the use has since been removed.
Tested on x86_64-pc-linux-gnu. OK to apply?
Kazu Hirata
2006-05-29 Kazu Hirata <kazu@codesourcery.com>
* basic-block.h: Remove the prototype for
commit_edge_insertions_watch_calls.
* cfgrtl.c (commit_edge_insertion): Drop the last argument.
Simplify.
(commit_edge_insertions_watch_calls): Remove.
(commit_edge_insertions): Adjust the call to
commit_one_edge_insertion.
Index: basic-block.h
===================================================================
*** basic-block.h (revision 114181)
--- basic-block.h (working copy)
***************
*** 488,494 ****
extern void insert_insn_on_edge (rtx, edge);
extern void commit_edge_insertions (void);
- extern void commit_edge_insertions_watch_calls (void);
extern void remove_fake_edges (void);
extern void remove_fake_exit_edges (void);
--- 488,493 ----
Index: cfgrtl.c
===================================================================
*** cfgrtl.c (revision 114181)
--- cfgrtl.c (working copy)
***************
*** 63,69 ****
static int can_delete_note_p (rtx);
static int can_delete_label_p (rtx);
! static void commit_one_edge_insertion (edge, int);
static basic_block rtl_split_edge (edge);
static bool rtl_move_block_after (basic_block, basic_block);
static int rtl_verify_flow_info (void);
--- 63,69 ----
static int can_delete_note_p (rtx);
static int can_delete_label_p (rtx);
! static void commit_one_edge_insertion (edge);
static basic_block rtl_split_edge (edge);
static bool rtl_move_block_after (basic_block, basic_block);
static int rtl_verify_flow_info (void);
***************
*** 1339,1345 ****
/* Update the CFG for the instructions queued on edge E. */
static void
! commit_one_edge_insertion (edge e, int watch_calls)
{
rtx before = NULL_RTX, after = NULL_RTX, insns, tmp, last;
basic_block bb = NULL;
--- 1339,1345 ----
/* Update the CFG for the instructions queued on edge E. */
static void
! commit_one_edge_insertion (edge e)
{
rtx before = NULL_RTX, after = NULL_RTX, insns, tmp, last;
basic_block bb = NULL;
***************
*** 1348,1450 ****
insns = e->insns.r;
e->insns.r = NULL_RTX;
! /* Special case -- avoid inserting code between call and storing
! its return value. */
! if (watch_calls && (e->flags & EDGE_FALLTHRU)
! && single_pred_p (e->dest)
! && e->src != ENTRY_BLOCK_PTR
! && CALL_P (BB_END (e->src)))
! {
! rtx next = next_nonnote_insn (BB_END (e->src));
!
! after = BB_HEAD (e->dest);
! /* The first insn after the call may be a stack pop, skip it. */
! while (next
! && keep_with_call_p (next))
! {
! after = next;
! next = next_nonnote_insn (next);
! }
! bb = e->dest;
! }
! if (!before && !after)
{
! /* Figure out where to put these things. If the destination has
! one predecessor, insert there. Except for the exit block. */
! if (single_pred_p (e->dest) && e->dest != EXIT_BLOCK_PTR)
! {
! bb = e->dest;
!
! /* Get the location correct wrt a code label, and "nice" wrt
! a basic block note, and before everything else. */
! tmp = BB_HEAD (bb);
! if (LABEL_P (tmp))
! tmp = NEXT_INSN (tmp);
! if (NOTE_INSN_BASIC_BLOCK_P (tmp))
! tmp = NEXT_INSN (tmp);
! if (tmp == BB_HEAD (bb))
! before = tmp;
! else if (tmp)
! after = PREV_INSN (tmp);
! else
! after = get_last_insn ();
! }
! /* If the source has one successor and the edge is not abnormal,
! insert there. Except for the entry block. */
! else if ((e->flags & EDGE_ABNORMAL) == 0
! && single_succ_p (e->src)
! && e->src != ENTRY_BLOCK_PTR)
! {
! bb = e->src;
! /* It is possible to have a non-simple jump here. Consider a target
! where some forms of unconditional jumps clobber a register. This
! happens on the fr30 for example.
! We know this block has a single successor, so we can just emit
! the queued insns before the jump. */
! if (JUMP_P (BB_END (bb)))
! before = BB_END (bb);
! else
! {
! /* We'd better be fallthru, or we've lost track of
! what's what. */
! gcc_assert (e->flags & EDGE_FALLTHRU);
! after = BB_END (bb);
! }
! }
! /* Otherwise we must split the edge. */
else
{
! bb = split_edge (e);
after = BB_END (bb);
! if (flag_reorder_blocks_and_partition
! && targetm.have_named_sections
! && e->src != ENTRY_BLOCK_PTR
! && BB_PARTITION (e->src) == BB_COLD_PARTITION
! && !(e->flags & EDGE_CROSSING))
! {
! rtx bb_note, cur_insn;
!
! bb_note = NULL_RTX;
! for (cur_insn = BB_HEAD (bb); cur_insn != NEXT_INSN (BB_END (bb));
! cur_insn = NEXT_INSN (cur_insn))
! if (NOTE_P (cur_insn)
! && NOTE_LINE_NUMBER (cur_insn) == NOTE_INSN_BASIC_BLOCK)
! {
! bb_note = cur_insn;
! break;
! }
!
! if (JUMP_P (BB_END (bb))
! && !any_condjump_p (BB_END (bb))
! && (single_succ_edge (bb)->flags & EDGE_CROSSING))
! REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST
! (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
! }
}
}
--- 1348,1428 ----
insns = e->insns.r;
e->insns.r = NULL_RTX;
! /* Figure out where to put these things. If the destination has one
! predecessor, insert there. Except for the exit block. */
! if (single_pred_p (e->dest) && e->dest != EXIT_BLOCK_PTR)
{
! bb = e->dest;
! /* Get the location correct wrt a code label, and "nice" wrt
! a basic block note, and before everything else. */
! tmp = BB_HEAD (bb);
! if (LABEL_P (tmp))
! tmp = NEXT_INSN (tmp);
! if (NOTE_INSN_BASIC_BLOCK_P (tmp))
! tmp = NEXT_INSN (tmp);
! if (tmp == BB_HEAD (bb))
! before = tmp;
! else if (tmp)
! after = PREV_INSN (tmp);
! else
! after = get_last_insn ();
! }
! /* If the source has one successor and the edge is not abnormal,
! insert there. Except for the entry block. */
! else if ((e->flags & EDGE_ABNORMAL) == 0
! && single_succ_p (e->src)
! && e->src != ENTRY_BLOCK_PTR)
! {
! bb = e->src;
! /* It is possible to have a non-simple jump here. Consider a
! target where some forms of unconditional jumps clobber a
! register. This happens on the fr30 for example.
! We know this block has a single successor, so we can just
! emit the queued insns before the jump. */
! if (JUMP_P (BB_END (bb)))
! before = BB_END (bb);
else
{
! /* We'd better be fallthru, or we've lost track of
! what's what. */
! gcc_assert (e->flags & EDGE_FALLTHRU);
!
after = BB_END (bb);
+ }
+ }
+ /* Otherwise we must split the edge. */
+ else
+ {
+ bb = split_edge (e);
+ after = BB_END (bb);
! if (flag_reorder_blocks_and_partition
! && targetm.have_named_sections
! && e->src != ENTRY_BLOCK_PTR
! && BB_PARTITION (e->src) == BB_COLD_PARTITION
! && !(e->flags & EDGE_CROSSING))
! {
! rtx bb_note, cur_insn;
!
! bb_note = NULL_RTX;
! for (cur_insn = BB_HEAD (bb); cur_insn != NEXT_INSN (BB_END (bb));
! cur_insn = NEXT_INSN (cur_insn))
! if (NOTE_P (cur_insn)
! && NOTE_LINE_NUMBER (cur_insn) == NOTE_INSN_BASIC_BLOCK)
! {
! bb_note = cur_insn;
! break;
! }
!
! if (JUMP_P (BB_END (bb))
! && !any_condjump_p (BB_END (bb))
! && (single_succ_edge (bb)->flags & EDGE_CROSSING))
! REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST
! (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
}
}
***************
*** 1504,1555 ****
if (e->insns.r)
{
changed = true;
! commit_one_edge_insertion (e, false);
! }
! }
!
! if (!changed)
! return;
!
! blocks = sbitmap_alloc (last_basic_block);
! sbitmap_zero (blocks);
! FOR_EACH_BB (bb)
! if (bb->aux)
! {
! SET_BIT (blocks, bb->index);
! /* Check for forgotten bb->aux values before commit_edge_insertions
! call. */
! gcc_assert (bb->aux == &bb->aux);
! bb->aux = NULL;
! }
! find_many_sub_basic_blocks (blocks);
! sbitmap_free (blocks);
! }
!
! /* Update the CFG for all queued instructions, taking special care of inserting
! code on edges between call and storing its return value. */
!
! void
! commit_edge_insertions_watch_calls (void)
! {
! basic_block bb;
! sbitmap blocks;
! bool changed = false;
!
! #ifdef ENABLE_CHECKING
! verify_flow_info ();
! #endif
!
! FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
! {
! edge e;
! edge_iterator ei;
!
! FOR_EACH_EDGE (e, ei, bb->succs)
! if (e->insns.r)
! {
! changed = true;
! commit_one_edge_insertion (e, true);
}
}
--- 1482,1488 ----
if (e->insns.r)
{
changed = true;
! commit_one_edge_insertion (e);
}
}