Commit bd454efd by Steven Bosscher Committed by Steven Bosscher

basic-block.h (struct edge_def): Remove crossing_edge.

	* basic-block.h (struct edge_def): Remove crossing_edge.
	(EDGE_CROSSING): New define.
	(EDGE_ALL_FLAGS): Update.
	* bb-reorder.c (find_traces_1_round, better_edge_p,
	find_rarely_executed_basic_blocks_and_cr, fix_up_fall_thru_edges,
	find_jump_block, fix_crossing_conditional_branches,
	fix_crossing_unconditional_branches, add_reg_crossing_jump_notes):
	Replace all occurences of crossing_edge with an edge flag check
	or set/reset.
	* cfgcleanup.c (try_simplify_condjump, try_forward_edges,
	try_crossjump_bb): Likewise.
	* cfglayout.c (fixup_reorder_chain): Likewise.
	* cfgrtl.c (force_nonfallthru_and_redirect,
	commit_one_edge_insertion): Likewise.

	* Makefile.in (cfganal.o): Depend on TIMEVAR_H.
	* tree-flow.h (compute_dominance_frontiers): Move prototype...
	* basic-block.h:  ...here.
	* tree-cfg.c (compute_dominance_frontiers_1,
	compute_dominance_frontiers): Move from here...
	* cfganal.c: ...to here.  Include timevar.h.

From-SVN: r86228
parent f80fd742
2004-09-19 Steven Bosscher <stevenb@suse.de>
* basic-block.h (struct edge_def): Remove crossing_edge.
(EDGE_CROSSING): New define.
(EDGE_ALL_FLAGS): Update.
* bb-reorder.c (find_traces_1_round, better_edge_p,
find_rarely_executed_basic_blocks_and_cr, fix_up_fall_thru_edges,
find_jump_block, fix_crossing_conditional_branches,
fix_crossing_unconditional_branches, add_reg_crossing_jump_notes):
Replace all occurences of crossing_edge with an edge flag check
or set/reset.
* cfgcleanup.c (try_simplify_condjump, try_forward_edges,
try_crossjump_bb): Likewise.
* cfglayout.c (fixup_reorder_chain): Likewise.
* cfgrtl.c (force_nonfallthru_and_redirect,
commit_one_edge_insertion): Likewise.
* Makefile.in (cfganal.o): Depend on TIMEVAR_H.
* tree-flow.h (compute_dominance_frontiers): Move prototype...
* basic-block.h: ...here.
* tree-cfg.c (compute_dominance_frontiers_1,
compute_dominance_frontiers): Move from here...
* cfganal.c: ...to here. Include timevar.h.
2004-08-18 James E Wilson <wilson@specifixinc.com> 2004-08-18 James E Wilson <wilson@specifixinc.com>
* config/mips/mips.h (ASM_SPEC): In comment, change -meabi= to -mabi=. * config/mips/mips.h (ASM_SPEC): In comment, change -meabi= to -mabi=.
......
...@@ -1974,7 +1974,8 @@ cfgrtl.o : cfgrtl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(FLAGS ...@@ -1974,7 +1974,8 @@ cfgrtl.o : cfgrtl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(FLAGS
insn-config.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h $(RECOG_H) \ insn-config.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h $(RECOG_H) \
function.h except.h $(GGC_H) $(TM_P_H) insn-config.h $(EXPR_H) function.h except.h $(GGC_H) $(TM_P_H) insn-config.h $(EXPR_H)
cfganal.o : cfganal.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ cfganal.o : cfganal.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(BASIC_BLOCK_H) hard-reg-set.h insn-config.h $(RECOG_H) $(GGC_H) $(TM_P_H) $(BASIC_BLOCK_H) hard-reg-set.h insn-config.h $(RECOG_H) $(GGC_H) $(TM_P_H) \
$(TIMEVAR_H)
cfgbuild.o : cfgbuild.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(FLAGS_H) \ cfgbuild.o : cfgbuild.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(FLAGS_H) \
insn-config.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h $(RECOG_H) \ insn-config.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h $(RECOG_H) \
function.h except.h $(GGC_H) function.h except.h $(GGC_H)
......
...@@ -149,8 +149,6 @@ struct edge_def GTY((chain_next ("%h.pred_next"))) ...@@ -149,8 +149,6 @@ struct edge_def GTY((chain_next ("%h.pred_next")))
int probability; /* biased by REG_BR_PROB_BASE */ int probability; /* biased by REG_BR_PROB_BASE */
gcov_type count; /* Expected number of executions calculated gcov_type count; /* Expected number of executions calculated
in profile.c */ in profile.c */
bool crossing_edge; /* Crosses between hot and cold sections, when
we do partitioning. */
}; };
typedef struct edge_def *edge; typedef struct edge_def *edge;
...@@ -174,7 +172,10 @@ typedef struct edge_def *edge; ...@@ -174,7 +172,10 @@ typedef struct edge_def *edge;
predicate is zero. */ predicate is zero. */
#define EDGE_EXECUTABLE 4096 /* Edge is executable. Only #define EDGE_EXECUTABLE 4096 /* Edge is executable. Only
valid during SSA-CCP. */ valid during SSA-CCP. */
#define EDGE_ALL_FLAGS 8191 #define EDGE_CROSSING 8192 /* Edge crosses between hot
and cold sections, when we
do partitioning. */
#define EDGE_ALL_FLAGS 16383
#define EDGE_COMPLEX (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH) #define EDGE_COMPLEX (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH)
...@@ -444,6 +445,7 @@ extern void flow_preorder_transversal_compute (int *); ...@@ -444,6 +445,7 @@ extern void flow_preorder_transversal_compute (int *);
extern int dfs_enumerate_from (basic_block, int, extern int dfs_enumerate_from (basic_block, int,
bool (*)(basic_block, void *), bool (*)(basic_block, void *),
basic_block *, int, void *); basic_block *, int, void *);
extern void compute_dominance_frontiers (bitmap *);
extern void dump_edge_info (FILE *, edge, int); extern void dump_edge_info (FILE *, edge, int);
extern void brief_dump_cfg (FILE *); extern void brief_dump_cfg (FILE *);
extern void clear_edges (void); extern void clear_edges (void);
......
...@@ -688,7 +688,7 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th, ...@@ -688,7 +688,7 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th,
&& !(e->flags & EDGE_COMPLEX) && !(e->flags & EDGE_COMPLEX)
&& !e->dest->rbi->visited && !e->dest->rbi->visited
&& !e->dest->pred->pred_next && !e->dest->pred->pred_next
&& !e->crossing_edge && !(e->flags & EDGE_CROSSING)
&& e->dest->succ && e->dest->succ
&& (e->dest->succ->flags & EDGE_CAN_FALLTHRU) && (e->dest->succ->flags & EDGE_CAN_FALLTHRU)
&& !(e->dest->succ->flags & EDGE_COMPLEX) && !(e->dest->succ->flags & EDGE_COMPLEX)
...@@ -880,8 +880,8 @@ better_edge_p (basic_block bb, edge e, int prob, int freq, int best_prob, ...@@ -880,8 +880,8 @@ better_edge_p (basic_block bb, edge e, int prob, int freq, int best_prob,
if (!is_better_edge if (!is_better_edge
&& flag_reorder_blocks_and_partition && flag_reorder_blocks_and_partition
&& cur_best_edge && cur_best_edge
&& cur_best_edge->crossing_edge && (cur_best_edge->flags & EDGE_CROSSING)
&& !e->crossing_edge) && !(e->flags & EDGE_CROSSING))
is_better_edge = true; is_better_edge = true;
return is_better_edge; return is_better_edge;
...@@ -1304,7 +1304,7 @@ find_rarely_executed_basic_blocks_and_crossing_edges (edge *crossing_edges, ...@@ -1304,7 +1304,7 @@ find_rarely_executed_basic_blocks_and_crossing_edges (edge *crossing_edges,
&& e->dest != EXIT_BLOCK_PTR && e->dest != EXIT_BLOCK_PTR
&& e->src->partition != e->dest->partition) && e->src->partition != e->dest->partition)
{ {
e->crossing_edge = true; e->flags |= EDGE_CROSSING;
if (i == *max_idx) if (i == *max_idx)
{ {
*max_idx *= 2; *max_idx *= 2;
...@@ -1314,7 +1314,7 @@ find_rarely_executed_basic_blocks_and_crossing_edges (edge *crossing_edges, ...@@ -1314,7 +1314,7 @@ find_rarely_executed_basic_blocks_and_crossing_edges (edge *crossing_edges,
crossing_edges[i++] = e; crossing_edges[i++] = e;
} }
else else
e->crossing_edge = false; e->flags &= ~EDGE_CROSSING;
} }
} }
*n_crossing_edges = i; *n_crossing_edges = i;
...@@ -1472,7 +1472,7 @@ fix_up_fall_thru_edges (void) ...@@ -1472,7 +1472,7 @@ fix_up_fall_thru_edges (void)
{ {
/* Check to see if the fall-thru edge is a crossing edge. */ /* Check to see if the fall-thru edge is a crossing edge. */
if (fall_thru->crossing_edge) if (fall_thru->flags & EDGE_CROSSING)
{ {
/* The fall_thru edge crosses; now check the cond jump edge, if /* The fall_thru edge crosses; now check the cond jump edge, if
it exists. */ it exists. */
...@@ -1485,7 +1485,7 @@ fix_up_fall_thru_edges (void) ...@@ -1485,7 +1485,7 @@ fix_up_fall_thru_edges (void)
if (cond_jump) if (cond_jump)
{ {
if (!cond_jump->crossing_edge) if (!(cond_jump->flags & EDGE_CROSSING))
cond_jump_crosses = false; cond_jump_crosses = false;
/* We know the fall-thru edge crosses; if the cond /* We know the fall-thru edge crosses; if the cond
...@@ -1513,8 +1513,8 @@ fix_up_fall_thru_edges (void) ...@@ -1513,8 +1513,8 @@ fix_up_fall_thru_edges (void)
e = fall_thru; e = fall_thru;
fall_thru = cond_jump; fall_thru = cond_jump;
cond_jump = e; cond_jump = e;
cond_jump->crossing_edge = true; cond_jump->flags |= EDGE_CROSSING;
fall_thru->crossing_edge = false; fall_thru->flags &= ~EDGE_CROSSING;
} }
} }
} }
...@@ -1537,7 +1537,7 @@ fix_up_fall_thru_edges (void) ...@@ -1537,7 +1537,7 @@ fix_up_fall_thru_edges (void)
partition as bb it's falling through from. */ partition as bb it's falling through from. */
new_bb->partition = cur_bb->partition; new_bb->partition = cur_bb->partition;
new_bb->succ->crossing_edge = true; new_bb->succ->flags |= EDGE_CROSSING;
} }
/* Add barrier after new jump */ /* Add barrier after new jump */
...@@ -1574,7 +1574,7 @@ find_jump_block (basic_block jump_dest) ...@@ -1574,7 +1574,7 @@ find_jump_block (basic_block jump_dest)
rtx insn; rtx insn;
for (e = jump_dest->pred; e; e = e->pred_next) for (e = jump_dest->pred; e; e = e->pred_next)
if (e->crossing_edge) if (e->flags & EDGE_CROSSING)
{ {
basic_block src = e->src; basic_block src = e->src;
...@@ -1643,9 +1643,9 @@ fix_crossing_conditional_branches (void) ...@@ -1643,9 +1643,9 @@ fix_crossing_conditional_branches (void)
/* We already took care of fall-through edges, so only one successor /* We already took care of fall-through edges, so only one successor
can be a crossing edge. */ can be a crossing edge. */
if (succ1 && succ1->crossing_edge) if (succ1 && (succ1->flags & EDGE_CROSSING))
crossing_edge = succ1; crossing_edge = succ1;
else if (succ2 && succ2->crossing_edge) else if (succ2 && (succ2->flags & EDGE_CROSSING))
crossing_edge = succ2; crossing_edge = succ2;
if (crossing_edge) if (crossing_edge)
...@@ -1758,8 +1758,8 @@ fix_crossing_conditional_branches (void) ...@@ -1758,8 +1758,8 @@ fix_crossing_conditional_branches (void)
else else
new_edge = new_bb->succ; new_edge = new_bb->succ;
crossing_edge->crossing_edge = false; crossing_edge->flags &= ~EDGE_CROSSING;
new_edge->crossing_edge = true; new_edge->flags |= EDGE_CROSSING;
} }
} }
} }
...@@ -1790,7 +1790,7 @@ fix_crossing_unconditional_branches (void) ...@@ -1790,7 +1790,7 @@ fix_crossing_unconditional_branches (void)
this point, no crossing jumps should be conditional. */ this point, no crossing jumps should be conditional. */
if (JUMP_P (last_insn) if (JUMP_P (last_insn)
&& succ->crossing_edge) && (succ->flags & EDGE_CROSSING))
{ {
rtx label2, table; rtx label2, table;
...@@ -1858,7 +1858,7 @@ add_reg_crossing_jump_notes (void) ...@@ -1858,7 +1858,7 @@ add_reg_crossing_jump_notes (void)
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
for (e = bb->succ; e; e = e->succ_next) for (e = bb->succ; e; e = e->succ_next)
if (e->crossing_edge if ((e->flags & EDGE_CROSSING)
&& JUMP_P (BB_END (e->src))) && JUMP_P (BB_END (e->src)))
REG_NOTES (BB_END (e->src)) = gen_rtx_EXPR_LIST (REG_CROSSING_JUMP, REG_NOTES (BB_END (e->src)) = gen_rtx_EXPR_LIST (REG_CROSSING_JUMP,
NULL_RTX, NULL_RTX,
......
...@@ -31,6 +31,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -31,6 +31,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "recog.h" #include "recog.h"
#include "toplev.h" #include "toplev.h"
#include "tm_p.h" #include "tm_p.h"
#include "timevar.h"
/* Store the data structures necessary for depth-first search. */ /* Store the data structures necessary for depth-first search. */
struct depth_first_search_dsS { struct depth_first_search_dsS {
...@@ -1041,3 +1042,81 @@ dfs_enumerate_from (basic_block bb, int reverse, ...@@ -1041,3 +1042,81 @@ dfs_enumerate_from (basic_block bb, int reverse,
rslt[sp]->flags &= ~BB_VISITED; rslt[sp]->flags &= ~BB_VISITED;
return tv; return tv;
} }
/* Computing the Dominance Frontier:
As described in Morgan, section 3.5, this may be done simply by
walking the dominator tree bottom-up, computing the frontier for
the children before the parent. When considering a block B,
there are two cases:
(1) A flow graph edge leaving B that does not lead to a child
of B in the dominator tree must be a block that is either equal
to B or not dominated by B. Such blocks belong in the frontier
of B.
(2) Consider a block X in the frontier of one of the children C
of B. If X is not equal to B and is not dominated by B, it
is in the frontier of B. */
static void
compute_dominance_frontiers_1 (bitmap *frontiers, basic_block bb, sbitmap done)
{
edge e;
basic_block c;
SET_BIT (done, bb->index);
/* Do the frontier of the children first. Not all children in the
dominator tree (blocks dominated by this one) are children in the
CFG, so check all blocks. */
for (c = first_dom_son (CDI_DOMINATORS, bb);
c;
c = next_dom_son (CDI_DOMINATORS, c))
{
if (! TEST_BIT (done, c->index))
compute_dominance_frontiers_1 (frontiers, c, done);
}
/* Find blocks conforming to rule (1) above. */
for (e = bb->succ; e; e = e->succ_next)
{
if (e->dest == EXIT_BLOCK_PTR)
continue;
if (get_immediate_dominator (CDI_DOMINATORS, e->dest) != bb)
bitmap_set_bit (frontiers[bb->index], e->dest->index);
}
/* Find blocks conforming to rule (2). */
for (c = first_dom_son (CDI_DOMINATORS, bb);
c;
c = next_dom_son (CDI_DOMINATORS, c))
{
int x;
EXECUTE_IF_SET_IN_BITMAP (frontiers[c->index], 0, x,
{
if (get_immediate_dominator (CDI_DOMINATORS, BASIC_BLOCK (x)) != bb)
bitmap_set_bit (frontiers[bb->index], x);
});
}
}
void
compute_dominance_frontiers (bitmap *frontiers)
{
sbitmap done = sbitmap_alloc (last_basic_block);
timevar_push (TV_DOM_FRONTIERS);
sbitmap_zero (done);
compute_dominance_frontiers_1 (frontiers, ENTRY_BLOCK_PTR->succ->dest, done);
sbitmap_free (done);
timevar_pop (TV_DOM_FRONTIERS);
}
...@@ -154,7 +154,7 @@ try_simplify_condjump (basic_block cbranch_block) ...@@ -154,7 +154,7 @@ try_simplify_condjump (basic_block cbranch_block)
if (flag_reorder_blocks_and_partition if (flag_reorder_blocks_and_partition
&& (jump_block->partition != jump_dest_block->partition && (jump_block->partition != jump_dest_block->partition
|| cbranch_jump_edge->crossing_edge)) || (cbranch_jump_edge->flags & EDGE_CROSSING)))
return false; return false;
/* The conditional branch must target the block after the /* The conditional branch must target the block after the
...@@ -461,7 +461,7 @@ try_forward_edges (int mode, basic_block b) ...@@ -461,7 +461,7 @@ try_forward_edges (int mode, basic_block b)
may_thread |= target->flags & BB_DIRTY; may_thread |= target->flags & BB_DIRTY;
if (FORWARDER_BLOCK_P (target) if (FORWARDER_BLOCK_P (target)
&& !target->succ->crossing_edge && !(target->succ->flags & EDGE_CROSSING)
&& target->succ->dest != EXIT_BLOCK_PTR) && target->succ->dest != EXIT_BLOCK_PTR)
{ {
/* Bypass trivial infinite loops. */ /* Bypass trivial infinite loops. */
...@@ -1674,7 +1674,7 @@ try_crossjump_bb (int mode, basic_block bb) ...@@ -1674,7 +1674,7 @@ try_crossjump_bb (int mode, basic_block bb)
if (flag_reorder_blocks_and_partition if (flag_reorder_blocks_and_partition
&& (bb->pred->src->partition != bb->pred->pred_next->src->partition && (bb->pred->src->partition != bb->pred->pred_next->src->partition
|| bb->pred->crossing_edge)) || (bb->pred->flags & EDGE_CROSSING)))
return false; return false;
/* It is always cheapest to redirect a block that ends in a branch to /* It is always cheapest to redirect a block that ends in a branch to
......
...@@ -723,7 +723,8 @@ fixup_reorder_chain (void) ...@@ -723,7 +723,8 @@ fixup_reorder_chain (void)
/* If the "jumping" edge is a crossing edge, and the fall /* If the "jumping" edge is a crossing edge, and the fall
through edge is non-crossing, leave things as they are. */ through edge is non-crossing, leave things as they are. */
else if (e_taken->crossing_edge && !e_fall->crossing_edge) else if ((e_taken->flags & EDGE_CROSSING)
&& !(e_fall->flags & EDGE_CROSSING))
continue; continue;
/* Otherwise we can try to invert the jump. This will /* Otherwise we can try to invert the jump. This will
...@@ -814,7 +815,7 @@ fixup_reorder_chain (void) ...@@ -814,7 +815,7 @@ fixup_reorder_chain (void)
} }
if (JUMP_P (BB_END (bb)) if (JUMP_P (BB_END (bb))
&& !any_condjump_p (BB_END (bb)) && !any_condjump_p (BB_END (bb))
&& bb->succ->crossing_edge ) && (bb->succ->flags & EDGE_CROSSING))
REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST
(REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb))); (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
} }
......
...@@ -1114,7 +1114,7 @@ force_nonfallthru_and_redirect (edge e, basic_block target) ...@@ -1114,7 +1114,7 @@ force_nonfallthru_and_redirect (edge e, basic_block target)
} }
if (JUMP_P (BB_END (jump_block)) if (JUMP_P (BB_END (jump_block))
&& !any_condjump_p (BB_END (jump_block)) && !any_condjump_p (BB_END (jump_block))
&& jump_block->succ->crossing_edge ) && (jump_block->succ->flags & EDGE_CROSSING))
REG_NOTES (BB_END (jump_block)) = gen_rtx_EXPR_LIST REG_NOTES (BB_END (jump_block)) = gen_rtx_EXPR_LIST
(REG_CROSSING_JUMP, NULL_RTX, (REG_CROSSING_JUMP, NULL_RTX,
REG_NOTES (BB_END (jump_block))); REG_NOTES (BB_END (jump_block)));
...@@ -1602,7 +1602,7 @@ commit_one_edge_insertion (edge e, int watch_calls) ...@@ -1602,7 +1602,7 @@ commit_one_edge_insertion (edge e, int watch_calls)
&& targetm.have_named_sections && targetm.have_named_sections
&& e->src != ENTRY_BLOCK_PTR && e->src != ENTRY_BLOCK_PTR
&& e->src->partition == COLD_PARTITION && e->src->partition == COLD_PARTITION
&& !e->crossing_edge) && !(e->flags & EDGE_CROSSING))
{ {
rtx bb_note, new_note, cur_insn; rtx bb_note, new_note, cur_insn;
...@@ -1621,7 +1621,7 @@ commit_one_edge_insertion (edge e, int watch_calls) ...@@ -1621,7 +1621,7 @@ commit_one_edge_insertion (edge e, int watch_calls)
NOTE_BASIC_BLOCK (new_note) = bb; NOTE_BASIC_BLOCK (new_note) = bb;
if (JUMP_P (BB_END (bb)) if (JUMP_P (BB_END (bb))
&& !any_condjump_p (BB_END (bb)) && !any_condjump_p (BB_END (bb))
&& bb->succ->crossing_edge ) && (bb->succ->flags & EDGE_CROSSING))
REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST
(REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb))); (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
if (after == bb_note) if (after == bb_note)
...@@ -1986,7 +1986,7 @@ rtl_verify_flow_info_1 (void) ...@@ -1986,7 +1986,7 @@ rtl_verify_flow_info_1 (void)
if (e->flags & EDGE_FALLTHRU) if (e->flags & EDGE_FALLTHRU)
{ {
n_fallthru++, fallthru = e; n_fallthru++, fallthru = e;
if (e->crossing_edge if ((e->flags & EDGE_CROSSING)
|| (e->src->partition != e->dest->partition || (e->src->partition != e->dest->partition
&& e->src != ENTRY_BLOCK_PTR && e->src != ENTRY_BLOCK_PTR
&& e->dest != EXIT_BLOCK_PTR)) && e->dest != EXIT_BLOCK_PTR))
......
...@@ -2171,84 +2171,6 @@ phi_alternatives_equal (basic_block dest, edge e1, edge e2) ...@@ -2171,84 +2171,6 @@ phi_alternatives_equal (basic_block dest, edge e1, edge e2)
} }
/* Computing the Dominance Frontier:
As described in Morgan, section 3.5, this may be done simply by
walking the dominator tree bottom-up, computing the frontier for
the children before the parent. When considering a block B,
there are two cases:
(1) A flow graph edge leaving B that does not lead to a child
of B in the dominator tree must be a block that is either equal
to B or not dominated by B. Such blocks belong in the frontier
of B.
(2) Consider a block X in the frontier of one of the children C
of B. If X is not equal to B and is not dominated by B, it
is in the frontier of B. */
static void
compute_dominance_frontiers_1 (bitmap *frontiers, basic_block bb, sbitmap done)
{
edge e;
basic_block c;
SET_BIT (done, bb->index);
/* Do the frontier of the children first. Not all children in the
dominator tree (blocks dominated by this one) are children in the
CFG, so check all blocks. */
for (c = first_dom_son (CDI_DOMINATORS, bb);
c;
c = next_dom_son (CDI_DOMINATORS, c))
{
if (! TEST_BIT (done, c->index))
compute_dominance_frontiers_1 (frontiers, c, done);
}
/* Find blocks conforming to rule (1) above. */
for (e = bb->succ; e; e = e->succ_next)
{
if (e->dest == EXIT_BLOCK_PTR)
continue;
if (get_immediate_dominator (CDI_DOMINATORS, e->dest) != bb)
bitmap_set_bit (frontiers[bb->index], e->dest->index);
}
/* Find blocks conforming to rule (2). */
for (c = first_dom_son (CDI_DOMINATORS, bb);
c;
c = next_dom_son (CDI_DOMINATORS, c))
{
int x;
EXECUTE_IF_SET_IN_BITMAP (frontiers[c->index], 0, x,
{
if (get_immediate_dominator (CDI_DOMINATORS, BASIC_BLOCK (x)) != bb)
bitmap_set_bit (frontiers[bb->index], x);
});
}
}
void
compute_dominance_frontiers (bitmap *frontiers)
{
sbitmap done = sbitmap_alloc (last_basic_block);
timevar_push (TV_DOM_FRONTIERS);
sbitmap_zero (done);
compute_dominance_frontiers_1 (frontiers, ENTRY_BLOCK_PTR->succ->dest, done);
sbitmap_free (done);
timevar_pop (TV_DOM_FRONTIERS);
}
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
Debugging functions Debugging functions
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
......
...@@ -489,7 +489,6 @@ extern void bsi_insert_on_edge (edge, tree); ...@@ -489,7 +489,6 @@ extern void bsi_insert_on_edge (edge, tree);
extern void bsi_commit_edge_inserts (int *); extern void bsi_commit_edge_inserts (int *);
extern void notice_special_calls (tree); extern void notice_special_calls (tree);
extern void clear_special_calls (void); extern void clear_special_calls (void);
extern void compute_dominance_frontiers (bitmap *);
extern void verify_stmts (void); extern void verify_stmts (void);
extern tree tree_block_label (basic_block bb); extern tree tree_block_label (basic_block bb);
extern void extract_true_false_edges_from_block (basic_block, edge *, edge *); extern void extract_true_false_edges_from_block (basic_block, edge *, edge *);
......
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