This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
edge creation cleanup
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com
- Subject: edge creation cleanup
- From: Jan Hubicka <jh at suse dot cz>
- Date: Wed, 25 Jul 2001 11:04:02 +0200
Hi,
an cleanup to avoid creating new edges by hand.
Bootstrapped/regtested i686
Honza
St čec 25 00:44:07 CEST 2001 Jan Hubicka <jh@suse.cz>
* flow.c (make_edge): Return the new edge.
(split_block, split_edge, redirect_edge_and_branch_force):
Use make edge.
* basic-block.h (make_edge): Update prototype.
*** flow.c.old Tue Jul 24 17:13:33 2001
--- flow.c Wed Jul 25 00:37:12 2001
*************** make_edges (label_value_list, min, max)
*** 1332,1340 ****
}
/* Create an edge between two basic blocks. FLAGS are auxiliary information
! about the edge that is accumulated between calls. */
! void
make_edge (edge_cache, src, dst, flags)
sbitmap *edge_cache;
basic_block src, dst;
--- 1345,1356 ----
}
/* Create an edge between two basic blocks. FLAGS are auxiliary information
! about the edge that is accumulated between calls.
!
! Return new edge created, NULL if edge has not been created, because
! equivalent already exist. */
! edge
make_edge (edge_cache, src, dst, flags)
sbitmap *edge_cache;
basic_block src, dst;
*************** make_edge (edge_cache, src, dst, flags)
*** 1359,1365 ****
/* The edge exists; early exit if no work to do. */
if (flags == 0)
! return;
/* FALLTHRU */
case 0:
--- 1375,1381 ----
/* The edge exists; early exit if no work to do. */
if (flags == 0)
! return NULL;
/* FALLTHRU */
case 0:
*************** make_edge (edge_cache, src, dst, flags)
*** 1367,1373 ****
if (e->dest == dst)
{
e->flags |= flags;
! return;
}
break;
}
--- 1383,1389 ----
if (e->dest == dst)
{
e->flags |= flags;
! return NULL;
}
break;
}
*************** make_edge (edge_cache, src, dst, flags)
*** 1386,1391 ****
--- 1402,1409 ----
if (use_edge_cache)
SET_BIT (edge_cache[src->index], dst->index);
+
+ return e;
}
/* Create an edge from a basic block to a label. */
*************** split_block (bb, insn)
*** 1497,1504 ****
/* Create the new structures. */
new_bb = (basic_block) obstack_alloc (&flow_obstack, sizeof (*new_bb));
- new_edge = (edge) xcalloc (1, sizeof (*new_edge));
- n_edges++;
memset (new_bb, 0, sizeof (*new_bb));
--- 1515,1520 ----
*************** split_block (bb, insn)
*** 1507,1521 ****
bb->end = insn;
new_bb->succ = bb->succ;
! bb->succ = new_edge;
! new_bb->pred = new_edge;
new_bb->count = bb->count;
new_bb->frequency = bb->frequency;
new_bb->loop_depth = bb->loop_depth;
! new_edge->src = bb;
! new_edge->dest = new_bb;
! new_edge->flags = EDGE_FALLTHRU;
new_edge->probability = REG_BR_PROB_BASE;
new_edge->count = bb->count;
--- 1523,1535 ----
bb->end = insn;
new_bb->succ = bb->succ;
! bb->succ = NULL;
! new_bb->pred = NULL;
new_bb->count = bb->count;
new_bb->frequency = bb->frequency;
new_bb->loop_depth = bb->loop_depth;
! new_edge = make_edge (NULL, bb, new_bb, EDGE_FALLTHRU);
new_edge->probability = REG_BR_PROB_BASE;
new_edge->count = bb->count;
*************** block_label (block)
*** 1591,1597 ****
if (block == EXIT_BLOCK_PTR)
return NULL_RTX;
if (GET_CODE (block->head) != CODE_LABEL)
! block->head = emit_label_before (gen_label_rtx (), block->head);
return block->head;
}
--- 1605,1615 ----
if (block == EXIT_BLOCK_PTR)
return NULL_RTX;
if (GET_CODE (block->head) != CODE_LABEL)
! {
! block->head = emit_label_before (gen_label_rtx (), block->head);
! if (basic_block_for_insn)
! set_block_for_insn (block->head, block);
! }
return block->head;
}
*************** redirect_edge_and_branch_force (e, targe
*** 1904,1922 ****
/* Create the new structures. */
new_bb = (basic_block) obstack_alloc (&flow_obstack, sizeof (*new_bb));
- new_edge = (edge) xcalloc (1, sizeof (*new_edge));
- n_edges++;
memset (new_bb, 0, sizeof (*new_bb));
new_bb->end = new_bb->head = e->src->end;
new_bb->succ = NULL;
! new_bb->pred = new_edge;
new_bb->count = e->count;
new_bb->frequency = e->probability * e->src->frequency / REG_BR_PROB_BASE;
new_bb->loop_depth = e->dest->loop_depth;
! new_edge->flags = EDGE_FALLTHRU;
new_edge->probability = e->probability;
new_edge->count = e->count;
--- 1907,1923 ----
/* Create the new structures. */
new_bb = (basic_block) obstack_alloc (&flow_obstack, sizeof (*new_bb));
memset (new_bb, 0, sizeof (*new_bb));
new_bb->end = new_bb->head = e->src->end;
new_bb->succ = NULL;
! new_bb->pred = NULL;
new_bb->count = e->count;
new_bb->frequency = e->probability * e->src->frequency / REG_BR_PROB_BASE;
new_bb->loop_depth = e->dest->loop_depth;
! new_edge = make_edge (NULL, e->src, new_bb, EDGE_FALLTHRU);
new_edge->probability = e->probability;
new_edge->count = e->count;
*************** redirect_edge_and_branch_force (e, targe
*** 1929,1941 ****
COPY_REG_SET (new_bb->global_live_at_end, new_bb->global_live_at_start);
}
- /* Wire edge in. */
- new_edge->src = e->src;
- new_edge->dest = new_bb;
- new_edge->succ_next = e->src->succ;
- e->src->succ = new_edge;
- new_edge->pred_next = NULL;
-
/* Redirect old edge. */
redirect_edge_succ (e, target);
redirect_edge_pred (e, new_bb);
--- 1930,1935 ----
*************** split_edge (edge_in)
*** 1997,2004 ****
/* Create the new structures. */
bb = (basic_block) obstack_alloc (&flow_obstack, sizeof (*bb));
- edge_out = (edge) xcalloc (1, sizeof (*edge_out));
- n_edges++;
memset (bb, 0, sizeof (*bb));
--- 1991,1996 ----
*************** split_edge (edge_in)
*** 2012,2034 ****
}
/* Wire them up. */
- bb->succ = edge_out;
bb->count = edge_in->count;
bb->frequency = (edge_in->probability * edge_in->src->frequency
/ REG_BR_PROB_BASE);
edge_in->flags &= ~EDGE_CRITICAL;
! edge_out->pred_next = old_succ->pred;
! edge_out->succ_next = NULL;
! edge_out->src = bb;
! edge_out->dest = old_succ;
! edge_out->flags = EDGE_FALLTHRU;
edge_out->probability = REG_BR_PROB_BASE;
edge_out->count = edge_in->count;
- old_succ->pred = edge_out;
-
/* Tricky case -- if there existed a fallthru into the successor
(and we're not it) we must add a new unconditional jump around
the new block we're actually interested in.
--- 2004,2019 ----
}
/* Wire them up. */
bb->count = edge_in->count;
bb->frequency = (edge_in->probability * edge_in->src->frequency
/ REG_BR_PROB_BASE);
edge_in->flags &= ~EDGE_CRITICAL;
! edge_out = make_edge (NULL, bb, old_succ, EDGE_FALLTHRU);
edge_out->probability = REG_BR_PROB_BASE;
edge_out->count = edge_in->count;
/* Tricky case -- if there existed a fallthru into the successor
(and we're not it) we must add a new unconditional jump around
the new block we're actually interested in.
*** basic-block.h.cfg Tue Jul 24 23:32:11 2001
--- basic-block.h Tue Jul 24 23:32:16 2001
*************** extern void connect_infinite_loops_to_ex
*** 292,298 ****
extern int flow_call_edges_add PARAMS ((sbitmap));
extern rtx flow_delete_insn PARAMS ((rtx));
extern void flow_delete_insn_chain PARAMS ((rtx, rtx));
! extern void make_edge PARAMS ((sbitmap *, basic_block,
basic_block, int));
extern void remove_edge PARAMS ((edge));
extern void redirect_edge_succ PARAMS ((edge, basic_block));
--- 292,298 ----
extern int flow_call_edges_add PARAMS ((sbitmap));
extern rtx flow_delete_insn PARAMS ((rtx));
extern void flow_delete_insn_chain PARAMS ((rtx, rtx));
! extern edge make_edge PARAMS ((sbitmap *, basic_block,
basic_block, int));
extern void remove_edge PARAMS ((edge));
extern void redirect_edge_succ PARAMS ((edge, basic_block));