summaryrefslogtreecommitdiff
path: root/gcc/cfgbuild.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/cfgbuild.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/cfgbuild.c')
-rw-r--r--gcc/cfgbuild.c126
1 files changed, 64 insertions, 62 deletions
diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index d531877597e..5ce9d40f3b0 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -50,8 +50,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
static int count_basic_blocks PARAMS ((rtx));
static void find_basic_blocks_1 PARAMS ((rtx));
static rtx find_label_refs PARAMS ((rtx, rtx));
-static void make_edges PARAMS ((rtx, basic_block,
- basic_block, int));
+static void make_edges PARAMS ((rtx, int, int, int));
static void make_label_edge PARAMS ((sbitmap *, basic_block,
rtx, int));
static void make_eh_edge PARAMS ((sbitmap *, basic_block, rtx));
@@ -281,10 +280,9 @@ make_eh_edge (edge_cache, src, insn)
static void
make_edges (label_value_list, min, max, update_p)
rtx label_value_list;
- basic_block min, max;
- int update_p;
+ int min, max, update_p;
{
- basic_block bb;
+ int i;
sbitmap *edge_cache = NULL;
/* Assume no computed jump; revise as we create edges. */
@@ -295,26 +293,28 @@ make_edges (label_value_list, min, max, update_p)
amount of time searching the edge lists for duplicates. */
if (forced_labels || label_value_list)
{
- edge_cache = sbitmap_vector_alloc (last_basic_block, last_basic_block);
- sbitmap_vector_zero (edge_cache, last_basic_block);
+ edge_cache = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
+ sbitmap_vector_zero (edge_cache, n_basic_blocks);
if (update_p)
- FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
+ for (i = min; i <= max; ++i)
{
edge e;
- for (e = bb->succ; e ; e = e->succ_next)
+ for (e = BASIC_BLOCK (i)->succ; e ; e = e->succ_next)
if (e->dest != EXIT_BLOCK_PTR)
- SET_BIT (edge_cache[bb->sindex], e->dest->sindex);
+ SET_BIT (edge_cache[i], e->dest->index);
}
}
- if (min == ENTRY_BLOCK_PTR->next_bb)
- cached_make_edge (edge_cache, ENTRY_BLOCK_PTR, min,
+ /* By nature of the way these get numbered, block 0 is always the entry. */
+ if (min == 0)
+ cached_make_edge (edge_cache, ENTRY_BLOCK_PTR, BASIC_BLOCK (0),
EDGE_FALLTHRU);
- FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
+ for (i = min; i <= max; ++i)
{
+ basic_block bb = BASIC_BLOCK (i);
rtx insn, x;
enum rtx_code code;
int force_fallthru = 0;
@@ -443,16 +443,15 @@ make_edges (label_value_list, min, max, update_p)
/* Find out if we can drop through to the next block. */
insn = next_nonnote_insn (insn);
-
- if (!insn || (bb->next_bb == EXIT_BLOCK_PTR && force_fallthru))
+ if (!insn || (i + 1 == n_basic_blocks && force_fallthru))
cached_make_edge (edge_cache, bb, EXIT_BLOCK_PTR, EDGE_FALLTHRU);
- else if (bb->next_bb != EXIT_BLOCK_PTR)
+ else if (i + 1 < n_basic_blocks)
{
- rtx tmp = bb->next_bb->head;
+ rtx tmp = BLOCK_HEAD (i + 1);
if (GET_CODE (tmp) == NOTE)
tmp = next_nonnote_insn (tmp);
if (force_fallthru || insn == tmp)
- cached_make_edge (edge_cache, bb, bb->next_bb,
+ cached_make_edge (edge_cache, bb, BASIC_BLOCK (i + 1),
EDGE_FALLTHRU);
}
}
@@ -471,12 +470,12 @@ find_basic_blocks_1 (f)
rtx f;
{
rtx insn, next;
+ int i = 0;
rtx bb_note = NULL_RTX;
rtx lvl = NULL_RTX;
rtx trll = NULL_RTX;
rtx head = NULL_RTX;
rtx end = NULL_RTX;
- basic_block prev = ENTRY_BLOCK_PTR;
/* We process the instructions in a slightly different way than we did
previously. This is so that we see a NOTE_BASIC_BLOCK after we have
@@ -493,7 +492,7 @@ find_basic_blocks_1 (f)
if ((GET_CODE (insn) == CODE_LABEL || GET_CODE (insn) == BARRIER)
&& head)
{
- prev = create_basic_block_structure (last_basic_block++, head, end, bb_note, prev);
+ create_basic_block_structure (i++, head, end, bb_note);
head = end = NULL_RTX;
bb_note = NULL_RTX;
}
@@ -507,7 +506,7 @@ find_basic_blocks_1 (f)
if (head && control_flow_insn_p (insn))
{
- prev = create_basic_block_structure (last_basic_block++, head, end, bb_note, prev);
+ create_basic_block_structure (i++, head, end, bb_note);
head = end = NULL_RTX;
bb_note = NULL_RTX;
}
@@ -589,11 +588,11 @@ find_basic_blocks_1 (f)
}
if (head != NULL_RTX)
- create_basic_block_structure (last_basic_block++, head, end, bb_note, prev);
+ create_basic_block_structure (i++, head, end, bb_note);
else if (bb_note)
delete_insn (bb_note);
- if (last_basic_block != num_basic_blocks)
+ if (i != n_basic_blocks)
abort ();
label_value_list = lvl;
@@ -613,7 +612,6 @@ find_basic_blocks (f, nregs, file)
FILE *file ATTRIBUTE_UNUSED;
{
int max_uid;
- basic_block bb;
timevar_push (TV_CFG);
basic_block_for_insn = 0;
@@ -621,21 +619,20 @@ find_basic_blocks (f, nregs, file)
/* Flush out existing data. */
if (basic_block_info != NULL)
{
+ int i;
+
clear_edges ();
/* Clear bb->aux on all extant basic blocks. We'll use this as a
tag for reuse during create_basic_block, just in case some pass
copies around basic block notes improperly. */
- FOR_ALL_BB (bb)
- bb->aux = NULL;
+ for (i = 0; i < n_basic_blocks; ++i)
+ BASIC_BLOCK (i)->aux = NULL;
VARRAY_FREE (basic_block_info);
}
- num_basic_blocks = count_basic_blocks (f);
- last_basic_block = 0;
- ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR;
- EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR;
+ n_basic_blocks = count_basic_blocks (f);
/* Size the basic block table. The actual structures will be allocated
by find_basic_blocks_1, since we want to keep the structure pointers
@@ -645,7 +642,7 @@ find_basic_blocks (f, nregs, file)
instructions at all until close to the end of compilation when we
actually lay them out. */
- VARRAY_BB_INIT (basic_block_info, num_basic_blocks, "basic_block_info");
+ VARRAY_BB_INIT (basic_block_info, n_basic_blocks, "basic_block_info");
find_basic_blocks_1 (f);
@@ -664,7 +661,7 @@ find_basic_blocks (f, nregs, file)
compute_bb_for_insn (max_uid);
/* Discover the edges of our cfg. */
- make_edges (label_value_list, ENTRY_BLOCK_PTR->next_bb, EXIT_BLOCK_PTR->prev_bb, 0);
+ make_edges (label_value_list, 0, n_basic_blocks - 1, 0);
/* Do very simple cleanup now, for the benefit of code that runs between
here and cleanup_cfg, e.g. thread_prologue_and_epilogue_insns. */
@@ -793,24 +790,25 @@ void
find_many_sub_basic_blocks (blocks)
sbitmap blocks;
{
- basic_block bb, min, max;
+ int i;
+ int min, max;
- FOR_ALL_BB (bb)
- SET_STATE (bb,
- TEST_BIT (blocks, bb->sindex) ? BLOCK_TO_SPLIT : BLOCK_ORIGINAL);
+ for (i = 0; i < n_basic_blocks; i++)
+ SET_STATE (BASIC_BLOCK (i),
+ TEST_BIT (blocks, i) ? BLOCK_TO_SPLIT : BLOCK_ORIGINAL);
- FOR_ALL_BB (bb)
- if (STATE (bb) == BLOCK_TO_SPLIT)
- find_bb_boundaries (bb);
+ for (i = 0; i < n_basic_blocks; i++)
+ if (STATE (BASIC_BLOCK (i)) == BLOCK_TO_SPLIT)
+ find_bb_boundaries (BASIC_BLOCK (i));
- FOR_ALL_BB (bb)
- if (STATE (bb) != BLOCK_ORIGINAL)
+ for (i = 0; i < n_basic_blocks; i++)
+ if (STATE (BASIC_BLOCK (i)) != BLOCK_ORIGINAL)
break;
- min = max = bb;
- for (; bb != EXIT_BLOCK_PTR; bb = bb->next_bb)
- if (STATE (bb) != BLOCK_ORIGINAL)
- max = bb;
+ min = max = i;
+ for (; i < n_basic_blocks; i++)
+ if (STATE (BASIC_BLOCK (i)) != BLOCK_ORIGINAL)
+ max = i;
/* Now re-scan and wire in all edges. This expect simple (conditional)
jumps at the end of each new basic blocks. */
@@ -818,28 +816,29 @@ find_many_sub_basic_blocks (blocks)
/* Update branch probabilities. Expect only (un)conditional jumps
to be created with only the forward edges. */
- FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
+ for (i = min; i <= max; i++)
{
edge e;
+ basic_block b = BASIC_BLOCK (i);
- if (STATE (bb) == BLOCK_ORIGINAL)
+ if (STATE (b) == BLOCK_ORIGINAL)
continue;
- if (STATE (bb) == BLOCK_NEW)
+ if (STATE (b) == BLOCK_NEW)
{
- bb->count = 0;
- bb->frequency = 0;
- for (e = bb->pred; e; e=e->pred_next)
+ b->count = 0;
+ b->frequency = 0;
+ for (e = b->pred; e; e=e->pred_next)
{
- bb->count += e->count;
- bb->frequency += EDGE_FREQUENCY (e);
+ b->count += e->count;
+ b->frequency += EDGE_FREQUENCY (e);
}
}
- compute_outgoing_frequencies (bb);
+ compute_outgoing_frequencies (b);
}
- FOR_ALL_BB (bb)
- SET_STATE (bb, 0);
+ for (i = 0; i < n_basic_blocks; i++)
+ SET_STATE (BASIC_BLOCK (i), 0);
}
/* Like above but for single basic block only. */
@@ -848,12 +847,14 @@ void
find_sub_basic_blocks (bb)
basic_block bb;
{
- basic_block min, max, b;
- basic_block next = bb->next_bb;
+ int i;
+ int min, max;
+ basic_block next = (bb->index == n_basic_blocks - 1
+ ? NULL : BASIC_BLOCK (bb->index + 1));
- min = bb;
+ min = bb->index;
find_bb_boundaries (bb);
- max = next->prev_bb;
+ max = (next ? next->index : n_basic_blocks) - 1;
/* Now re-scan and wire in all edges. This expect simple (conditional)
jumps at the end of each new basic blocks. */
@@ -861,11 +862,12 @@ find_sub_basic_blocks (bb)
/* Update branch probabilities. Expect only (un)conditional jumps
to be created with only the forward edges. */
- FOR_BB_BETWEEN (b, min, max->next_bb, next_bb)
+ for (i = min; i <= max; i++)
{
edge e;
+ basic_block b = BASIC_BLOCK (i);
- if (b != min)
+ if (i != min)
{
b->count = 0;
b->frequency = 0;