summaryrefslogtreecommitdiff
path: root/gcc/cfglayout.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-17 02:31:56 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-17 02:31:56 +0000
commitb3d6de8978fd2208885e98b19a91c9d29c170af5 (patch)
tree94c8895c6dde3b282518d4c9951067cd0ac517fd /gcc/cfglayout.c
parent5e7d465f337d9d419b2528ad819390067caeca95 (diff)
downloadgcc-b3d6de8978fd2208885e98b19a91c9d29c170af5.tar.gz
Revert "Basic block renumbering removal", and two followup patches.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53537 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfglayout.c')
-rw-r--r--gcc/cfglayout.c74
1 files changed, 32 insertions, 42 deletions
diff --git a/gcc/cfglayout.c b/gcc/cfglayout.c
index 0421a729246..2820f0d5d96 100644
--- a/gcc/cfglayout.c
+++ b/gcc/cfglayout.c
@@ -86,8 +86,8 @@ skip_insns_after_block (bb)
rtx insn, last_insn, next_head, prev;
next_head = NULL_RTX;
- if (bb->next_bb != EXIT_BLOCK_PTR)
- next_head = bb->next_bb->head;
+ if (bb->index + 1 != n_basic_blocks)
+ next_head = BASIC_BLOCK (bb->index + 1)->head;
for (last_insn = insn = bb->end; (insn = NEXT_INSN (insn)) != 0; )
{
@@ -176,7 +176,7 @@ label_for_bb (bb)
if (GET_CODE (label) != CODE_LABEL)
{
if (rtl_dump_file)
- fprintf (rtl_dump_file, "Emitting label for block %d\n", bb->sindex);
+ fprintf (rtl_dump_file, "Emitting label for block %d\n", bb->index);
label = block_label (bb);
}
@@ -191,10 +191,11 @@ static void
record_effective_endpoints ()
{
rtx next_insn = get_insns ();
- basic_block bb;
-
- FOR_ALL_BB (bb)
+ int i;
+
+ for (i = 0; i < n_basic_blocks; i++)
{
+ basic_block bb = BASIC_BLOCK (i);
rtx end;
if (PREV_INSN (bb->head) && next_insn != bb->head)
@@ -356,15 +357,15 @@ scope_to_insns_finalize ()
static void
fixup_reorder_chain ()
{
- basic_block bb, prev_bb;
+ basic_block bb;
int index;
rtx insn = NULL;
/* First do the bulk reordering -- rechain the blocks without regard to
the needed changes to jumps and labels. */
- for (bb = ENTRY_BLOCK_PTR->next_bb, index = 0;
- bb;
+ for (bb = BASIC_BLOCK (0), index = 0;
+ bb != 0;
bb = RBI (bb)->next, index++)
{
if (RBI (bb)->header)
@@ -393,7 +394,7 @@ fixup_reorder_chain ()
}
}
- if (index != num_basic_blocks)
+ if (index != n_basic_blocks)
abort ();
NEXT_INSN (insn) = function_footer;
@@ -411,7 +412,7 @@ fixup_reorder_chain ()
/* Now add jumps and labels as needed to match the blocks new
outgoing edges. */
- for (bb = ENTRY_BLOCK_PTR->next_bb; bb ; bb = RBI (bb)->next)
+ for (bb = BASIC_BLOCK (0); bb ; bb = RBI (bb)->next)
{
edge e_fall, e_taken, e;
rtx bb_end_insn;
@@ -522,39 +523,29 @@ fixup_reorder_chain ()
}
/* Put basic_block_info in the new order. */
+
if (rtl_dump_file)
{
fprintf (rtl_dump_file, "Reordered sequence:\n");
- for (bb = ENTRY_BLOCK_PTR->next_bb, index = 0;
- bb;
- bb = RBI (bb)->next, index ++)
+ for (bb = BASIC_BLOCK (0), index = 0; bb; bb = RBI (bb)->next, index ++)
{
fprintf (rtl_dump_file, " %i ", index);
if (RBI (bb)->original)
fprintf (rtl_dump_file, "duplicate of %i ",
- RBI (bb)->original->sindex);
+ RBI (bb)->original->index);
else if (forwarder_block_p (bb) && GET_CODE (bb->head) != CODE_LABEL)
fprintf (rtl_dump_file, "compensation ");
else
- fprintf (rtl_dump_file, "bb %i ", bb->sindex);
+ fprintf (rtl_dump_file, "bb %i ", bb->index);
fprintf (rtl_dump_file, " [%i]\n", bb->frequency);
}
}
- prev_bb = ENTRY_BLOCK_PTR;
- bb = ENTRY_BLOCK_PTR->next_bb;
- index = 0;
-
- for (; bb; prev_bb = bb, bb = RBI (bb)->next, index++)
+ for (bb = BASIC_BLOCK (0), index = 0; bb; bb = RBI (bb)->next, index ++)
{
- bb->sindex = index;
+ bb->index = index;
BASIC_BLOCK (index) = bb;
-
- bb->prev_bb = prev_bb;
- prev_bb->next_bb = bb;
}
- prev_bb->next_bb = EXIT_BLOCK_PTR;
- EXIT_BLOCK_PTR->prev_bb = prev_bb;
}
/* Perform sanity checks on the insn chain.
@@ -597,10 +588,11 @@ verify_insn_chain ()
static void
cleanup_unconditional_jumps ()
{
- basic_block bb;
-
- FOR_ALL_BB (bb)
+ int i;
+ for (i = 0; i < n_basic_blocks; i++)
{
+ basic_block bb = BASIC_BLOCK (i);
+
if (!bb->succ)
continue;
if (bb->succ->flags & EDGE_FALLTHRU)
@@ -608,14 +600,13 @@ cleanup_unconditional_jumps ()
if (!bb->succ->succ_next)
{
rtx insn;
- if (GET_CODE (bb->head) != CODE_LABEL && forwarder_block_p (bb)
- && bb->prev_bb != ENTRY_BLOCK_PTR)
+ if (GET_CODE (bb->head) != CODE_LABEL && forwarder_block_p (bb) && i)
{
- basic_block prev = bb->prev_bb;
+ basic_block prev = BASIC_BLOCK (--i);
if (rtl_dump_file)
fprintf (rtl_dump_file, "Removing forwarder BB %i\n",
- bb->sindex);
+ bb->index);
redirect_edge_succ (bb->pred, bb->succ->dest);
flow_delete_block (bb);
@@ -627,7 +618,7 @@ cleanup_unconditional_jumps ()
if (rtl_dump_file)
fprintf (rtl_dump_file, "Removing jump %i in BB %i\n",
- INSN_UID (jump), bb->sindex);
+ INSN_UID (jump), bb->index);
delete_insn (jump);
bb->succ->flags |= EDGE_FALLTHRU;
}
@@ -672,7 +663,7 @@ fixup_fallthru_exit_predecessor ()
if (bb && RBI (bb)->next)
{
- basic_block c = ENTRY_BLOCK_PTR->next_bb;
+ basic_block c = BASIC_BLOCK (0);
while (RBI (c)->next != bb)
c = RBI (c)->next;
@@ -822,14 +813,14 @@ cfg_layout_redirect_edge (e, dest)
edge e;
basic_block dest;
{
+ int old_index = dest->index;
basic_block src = e->src;
- basic_block old_next_bb = src->next_bb;
/* Redirect_edge_and_branch may decide to turn branch into fallthru edge
in the case the basic block appears to be in sequence. Avoid this
transformation. */
- src->next_bb = NULL;
+ dest->index = n_basic_blocks + 1;
if (e->flags & EDGE_FALLTHRU)
{
/* In case we are redirecting fallthru edge to the branch edge
@@ -855,7 +846,7 @@ cfg_layout_redirect_edge (e, dest)
delete_barrier (NEXT_INSN (src->end));
src->succ->flags |= EDGE_FALLTHRU;
}
- src->next_bb = old_next_bb;
+ dest->index = old_index;
}
/* Create an duplicate of the basic block BB and redirect edge E into it. */
@@ -880,9 +871,8 @@ cfg_layout_duplicate_bb (bb, e)
#endif
insn = duplicate_insn_chain (bb->head, bb->end);
- new_bb = create_basic_block (insn,
- insn ? get_last_insn () : NULL,
- EXIT_BLOCK_PTR->prev_bb);
+ new_bb = create_basic_block (n_basic_blocks, insn,
+ insn ? get_last_insn () : NULL);
alloc_aux_for_block (new_bb, sizeof (struct reorder_block_def));
if (RBI (bb)->header)