Skip to content

Commit 4d2e5d5

Browse files
author
zadeck
committed
2005-12-17 Danny Berlin <[email protected]>
Kenneth Zadeck <[email protected]> * basic-block.h: Changed basic block numbering so that the entry block is 0 and the exit block is 1. Changed insn iterators so that they are tolerant of blocks with no insns. * regrename.c (copyprop_hardreg_forward): Changed basic block numbering so that the entry block is 0 and the exit block is 1. * sched-ebb.c (sehedule_ebbs): Ditto. * tracer.c (branch_ratio_cutoff): Ditto. * cfgloopmanip.c (fix_loop_structure): Ditto. * cfghooks.c (verify_flow_info): Ditto. * cfg.c (compact_blocks): Ditto. * reorg.c (dbr_schedule): Ditto. * flow.c (calculate_global_regs_live, libcall_dead_p): Ditto. * dominance.c (calc_dfs_tree_nonrec, calc_dfs_tree, calculate_dominance_info): Ditto. * cfganal.c (create_edge_list, print_edge_list, flow_depth_first_order_compute, flow_dfs_compute_reverse_init, flow_dfs_compute_reverse_add_bb, flow_dfs_compute_reverse_execute, dfs_enumerate_from): Ditto. * global.c (global_alloc, set_up_bb_rts_numbers): Ditto. * ifcvt.c (find_if_case_2): Ditto. * cfgbuild.c (control_flow_insn_p, count_basic_blocks, find_basic_blocks): Ditto. * predict.c (predict_loops, tree_bb_level_predictions, predict_paths_leading_to, propagate_freq): Ditto. * lcm.c (compute_antinout_edge, compute_laterin, compute_available): Ditto. * function.c (thread_prologue_and_epilogue_insns): Ditto. * gcse.c (gcse_main, bypass_jumps): Ditto. * profile.c (compute_branch_probabilities, compute_value_histograms, branch_prob): Ditto. * tree-flow-inline.h (bsi_start, bsi_after_labels, bsi_last): Ditto. * tree-ssa-phiopt.c (tree_ssa_phiopt, blocks_in_phiopt_order): Ditto. * bt-load.c (compute_defs_uses_and_gen, compute_kill, compute_out, link_btr_uses, migrate_btr_defs): Ditto. * tree-dfa.c (collect_dfa_stats): Ditto. * cfgcleanup.c (try_forward_edges, try_optimize_cfg): Ditto. * cfglayout.c (fixup_reorder_chain): Ditto. * bb-reorder.c (reorder_basic_blocks, duplicate_computed_gotos, partition_hot_cold_basic_blocks): Ditto. * var-tracking.c (vt_find_locations): Ditto. * cfgloop.c (flow_loops_cfg_dump, flow_loops_find, get_loop_body): Ditto. * sched-rgn.c (compute_trg_info, init_regions, schedule_insns): Ditto. * tree-cfg.c (init_empty_tree_cfg, build_tree_cfg, make_edges label_to_block_fn, print_loop_ir, tree_flow_call_edges_add): Ditto. * tree-ssa-reassoc.c (init_reassoc): Ditto. * cfgrtl.c (entry_of_function, rtl_verify_flow_info, rtl_flow_call_edges_add, rtl_flow_call_edges_add): Ditto. * df.c (df_analyze_1, hybrid_search, iterative_dataflow): Ditto and removed unused reverse orders. * df.h (): Ditto. * combine.c: Fix document typo. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108713 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent f7553d0 commit 4d2e5d5

36 files changed

+236
-202
lines changed

gcc/ChangeLog

+57
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
1+
2005-12-17 Danny Berlin <[email protected]>
2+
Kenneth Zadeck <[email protected]>
3+
4+
* basic-block.h: Changed basic block numbering so that the entry
5+
block is 0 and the exit block is 1. Changed insn iterators so
6+
that they are tolerant of blocks with no insns.
7+
* regrename.c (copyprop_hardreg_forward): Changed basic block
8+
numbering so that the entry block is 0 and the exit block is 1.
9+
* sched-ebb.c (sehedule_ebbs): Ditto.
10+
* tracer.c (branch_ratio_cutoff): Ditto.
11+
* cfgloopmanip.c (fix_loop_structure): Ditto.
12+
* cfghooks.c (verify_flow_info): Ditto.
13+
* cfg.c (compact_blocks): Ditto.
14+
* reorg.c (dbr_schedule): Ditto.
15+
* flow.c (calculate_global_regs_live, libcall_dead_p): Ditto.
16+
* dominance.c (calc_dfs_tree_nonrec, calc_dfs_tree,
17+
calculate_dominance_info): Ditto.
18+
* cfganal.c (create_edge_list, print_edge_list,
19+
flow_depth_first_order_compute, flow_dfs_compute_reverse_init,
20+
flow_dfs_compute_reverse_add_bb, flow_dfs_compute_reverse_execute,
21+
dfs_enumerate_from): Ditto.
22+
* global.c (global_alloc, set_up_bb_rts_numbers): Ditto.
23+
* ifcvt.c (find_if_case_2): Ditto.
24+
* cfgbuild.c (control_flow_insn_p, count_basic_blocks,
25+
find_basic_blocks): Ditto.
26+
* predict.c (predict_loops, tree_bb_level_predictions,
27+
predict_paths_leading_to, propagate_freq): Ditto.
28+
* lcm.c (compute_antinout_edge, compute_laterin,
29+
compute_available): Ditto.
30+
* function.c (thread_prologue_and_epilogue_insns): Ditto.
31+
* gcse.c (gcse_main, bypass_jumps): Ditto.
32+
* profile.c (compute_branch_probabilities,
33+
compute_value_histograms, branch_prob): Ditto.
34+
* tree-flow-inline.h (bsi_start, bsi_after_labels,
35+
bsi_last): Ditto.
36+
* tree-ssa-phiopt.c (tree_ssa_phiopt,
37+
blocks_in_phiopt_order): Ditto.
38+
* bt-load.c (compute_defs_uses_and_gen, compute_kill,
39+
compute_out, link_btr_uses, migrate_btr_defs): Ditto.
40+
* tree-dfa.c (collect_dfa_stats): Ditto.
41+
* cfgcleanup.c (try_forward_edges, try_optimize_cfg): Ditto.
42+
* cfglayout.c (fixup_reorder_chain): Ditto.
43+
* bb-reorder.c (reorder_basic_blocks, duplicate_computed_gotos,
44+
partition_hot_cold_basic_blocks): Ditto.
45+
* var-tracking.c (vt_find_locations): Ditto.
46+
* cfgloop.c (flow_loops_cfg_dump, flow_loops_find, get_loop_body): Ditto.
47+
* sched-rgn.c (compute_trg_info, init_regions, schedule_insns): Ditto.
48+
* tree-cfg.c (init_empty_tree_cfg, build_tree_cfg, make_edges
49+
label_to_block_fn, print_loop_ir, tree_flow_call_edges_add): Ditto.
50+
* tree-ssa-reassoc.c (init_reassoc): Ditto.
51+
* cfgrtl.c (entry_of_function, rtl_verify_flow_info,
52+
rtl_flow_call_edges_add, rtl_flow_call_edges_add): Ditto.
53+
* df.c (df_analyze_1, hybrid_search, iterative_dataflow): Ditto
54+
and removed unused reverse orders.
55+
* df.h (): Ditto.
56+
* combine.c: Fix document typo.
57+
158
2005-12-17 Jan Hubicka <[email protected]>
259

360
* tree-flow-inline.h (set_default_def, default_def): Kill.

gcc/basic-block.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,12 @@ extern bool rediscover_loops_after_threading;
430430
/* For iterating over insns in basic block. */
431431
#define FOR_BB_INSNS(BB, INSN) \
432432
for ((INSN) = BB_HEAD (BB); \
433-
(INSN) != NEXT_INSN (BB_END (BB)); \
433+
(INSN) && (INSN) != NEXT_INSN (BB_END (BB)); \
434434
(INSN) = NEXT_INSN (INSN))
435435

436436
#define FOR_BB_INSNS_REVERSE(BB, INSN) \
437437
for ((INSN) = BB_END (BB); \
438-
(INSN) != PREV_INSN (BB_HEAD (BB)); \
438+
(INSN) && (INSN) != PREV_INSN (BB_HEAD (BB)); \
439439
(INSN) = PREV_INSN (INSN))
440440

441441
/* Cycles through _all_ basic blocks, even the fake ones (entry and
@@ -467,11 +467,12 @@ extern bitmap_obstack reg_obstack;
467467
#define BB_END(B) (B)->il.rtl->end_
468468

469469
/* Special block numbers [markers] for entry and exit. */
470-
#define ENTRY_BLOCK (-1)
471-
#define EXIT_BLOCK (-2)
470+
#define ENTRY_BLOCK (0)
471+
#define EXIT_BLOCK (1)
472+
473+
/* The two blocks that are always in the cfg. */
474+
#define NUM_FIXED_BLOCKS (2)
472475

473-
/* Special block number not valid for any block. */
474-
#define INVALID_BLOCK (-3)
475476

476477
#define BLOCK_NUM(INSN) (BLOCK_FOR_INSN (INSN)->index + 0)
477478
#define set_block_for_insn(INSN, BB) (BLOCK_FOR_INSN (INSN) = BB)

gcc/bb-reorder.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ reorder_basic_blocks (unsigned int flags)
18941894
int i;
18951895
struct trace *traces;
18961896

1897-
if (n_basic_blocks <= 1)
1897+
if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1)
18981898
return;
18991899

19001900
if (targetm.cannot_modify_jumps_p ())
@@ -1986,7 +1986,7 @@ duplicate_computed_gotos (void)
19861986
bitmap candidates;
19871987
int max_size;
19881988

1989-
if (n_basic_blocks <= 1)
1989+
if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1)
19901990
return;
19911991

19921992
if (targetm.cannot_modify_jumps_p ())
@@ -2169,16 +2169,16 @@ partition_hot_cold_basic_blocks (void)
21692169
int n_crossing_edges;
21702170
int max_edges = 2 * last_basic_block;
21712171

2172-
if (n_basic_blocks <= 1)
2172+
if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1)
21732173
return;
21742174

21752175
crossing_edges = xcalloc (max_edges, sizeof (edge));
21762176

21772177
cfg_layout_initialize (0);
21782178

21792179
FOR_EACH_BB (cur_bb)
2180-
if (cur_bb->index >= 0
2181-
&& cur_bb->next_bb->index >= 0)
2180+
if (cur_bb->index >= NUM_FIXED_BLOCKS
2181+
&& cur_bb->next_bb->index >= NUM_FIXED_BLOCKS)
21822182
cur_bb->aux = cur_bb->next_bb;
21832183

21842184
find_rarely_executed_basic_blocks_and_crossing_edges (crossing_edges,

gcc/bt-load.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ compute_defs_uses_and_gen (fibheap_t all_btr_defs, btr_def *def_array,
461461
defs_uses_info info;
462462

463463
sbitmap_vector_zero (bb_gen, n_basic_blocks);
464-
for (i = 0; i < n_basic_blocks; i++)
464+
for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
465465
{
466466
basic_block bb = BASIC_BLOCK (i);
467467
int reg;
@@ -622,7 +622,7 @@ compute_kill (sbitmap *bb_kill, sbitmap *btr_defset,
622622
/* For each basic block, form the set BB_KILL - the set
623623
of definitions that the block kills. */
624624
sbitmap_vector_zero (bb_kill, n_basic_blocks);
625-
for (i = 0; i < n_basic_blocks; i++)
625+
for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
626626
{
627627
for (regno = first_btr; regno <= last_btr; regno++)
628628
if (TEST_HARD_REG_BIT (all_btrs, regno)
@@ -645,14 +645,14 @@ compute_out (sbitmap *bb_out, sbitmap *bb_gen, sbitmap *bb_kill, int max_uid)
645645
int changed;
646646
sbitmap bb_in = sbitmap_alloc (max_uid);
647647

648-
for (i = 0; i < n_basic_blocks; i++)
648+
for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
649649
sbitmap_copy (bb_out[i], bb_gen[i]);
650650

651651
changed = 1;
652652
while (changed)
653653
{
654654
changed = 0;
655-
for (i = 0; i < n_basic_blocks; i++)
655+
for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
656656
{
657657
sbitmap_union_of_preds (bb_in, bb_out, i);
658658
changed |= sbitmap_union_of_diff_cg (bb_out[i], bb_gen[i],
@@ -671,7 +671,7 @@ link_btr_uses (btr_def *def_array, btr_user *use_array, sbitmap *bb_out,
671671

672672
/* Link uses to the uses lists of all of their reaching defs.
673673
Count up the number of reaching defs of each use. */
674-
for (i = 0; i < n_basic_blocks; i++)
674+
for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
675675
{
676676
basic_block bb = BASIC_BLOCK (i);
677677
rtx insn;
@@ -1397,7 +1397,7 @@ migrate_btr_defs (enum reg_class btr_class, int allow_callee_save)
13971397
{
13981398
int i;
13991399

1400-
for (i = 0; i < n_basic_blocks; i++)
1400+
for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
14011401
{
14021402
basic_block bb = BASIC_BLOCK (i);
14031403
fprintf(dump_file,

gcc/cfg.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,11 @@ compact_blocks (void)
163163
int i;
164164
basic_block bb;
165165

166-
i = 0;
167-
FOR_EACH_BB (bb)
166+
BASIC_BLOCK (ENTRY_BLOCK) = ENTRY_BLOCK_PTR;
167+
BASIC_BLOCK (EXIT_BLOCK) = EXIT_BLOCK_PTR;
168+
169+
i = NUM_FIXED_BLOCKS;
170+
FOR_EACH_BB (bb)
168171
{
169172
BASIC_BLOCK (i) = bb;
170173
bb->index = i;

gcc/cfganal.c

+15-16
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ create_edge_list (void)
345345
basic_block bb;
346346
edge_iterator ei;
347347

348-
block_count = n_basic_blocks + 2; /* Include the entry and exit blocks. */
348+
block_count = n_basic_blocks; /* Include the entry and exit blocks. */
349349

350350
num_edges = 0;
351351

@@ -391,7 +391,7 @@ print_edge_list (FILE *f, struct edge_list *elist)
391391
int x;
392392

393393
fprintf (f, "Compressed edge list, %d BBs + entry & exit, and %d edges\n",
394-
elist->num_blocks - 2, elist->num_edges);
394+
elist->num_blocks, elist->num_edges);
395395

396396
for (x = 0; x < elist->num_edges; x++)
397397
{
@@ -721,7 +721,7 @@ flow_depth_first_order_compute (int *dfs_order, int *rc_order)
721721
edge_iterator *stack;
722722
int sp;
723723
int dfsnum = 0;
724-
int rcnum = n_basic_blocks - 1;
724+
int rcnum = n_basic_blocks - 1 - NUM_FIXED_BLOCKS;
725725
sbitmap visited;
726726

727727
/* Allocate stack for back-tracking up CFG. */
@@ -786,8 +786,9 @@ flow_depth_first_order_compute (int *dfs_order, int *rc_order)
786786
free (stack);
787787
sbitmap_free (visited);
788788

789-
/* The number of nodes visited should be the number of blocks. */
790-
gcc_assert (dfsnum == n_basic_blocks);
789+
/* The number of nodes visited should be the number of blocks minus
790+
the entry and exit blocks which are not visited here. */
791+
gcc_assert (dfsnum == n_basic_blocks - NUM_FIXED_BLOCKS);
791792

792793
return dfsnum;
793794
}
@@ -826,12 +827,11 @@ static void
826827
flow_dfs_compute_reverse_init (depth_first_search_ds data)
827828
{
828829
/* Allocate stack for back-tracking up CFG. */
829-
data->stack = xmalloc ((n_basic_blocks - (INVALID_BLOCK + 1))
830-
* sizeof (basic_block));
830+
data->stack = xmalloc (n_basic_blocks * sizeof (basic_block));
831831
data->sp = 0;
832832

833833
/* Allocate bitmap to track nodes that have been visited. */
834-
data->visited_blocks = sbitmap_alloc (last_basic_block - (INVALID_BLOCK + 1));
834+
data->visited_blocks = sbitmap_alloc (last_basic_block);
835835

836836
/* None of the nodes in the CFG have been visited yet. */
837837
sbitmap_zero (data->visited_blocks);
@@ -847,7 +847,7 @@ static void
847847
flow_dfs_compute_reverse_add_bb (depth_first_search_ds data, basic_block bb)
848848
{
849849
data->stack[data->sp++] = bb;
850-
SET_BIT (data->visited_blocks, bb->index - (INVALID_BLOCK + 1));
850+
SET_BIT (data->visited_blocks, bb->index);
851851
}
852852

853853
/* Continue the depth-first search through the reverse graph starting with the
@@ -869,14 +869,13 @@ flow_dfs_compute_reverse_execute (depth_first_search_ds data,
869869

870870
/* Perform depth-first search on adjacent vertices. */
871871
FOR_EACH_EDGE (e, ei, bb->preds)
872-
if (!TEST_BIT (data->visited_blocks,
873-
e->src->index - (INVALID_BLOCK + 1)))
872+
if (!TEST_BIT (data->visited_blocks, e->src->index))
874873
flow_dfs_compute_reverse_add_bb (data, e->src);
875874
}
876875

877876
/* Determine if there are unvisited basic blocks. */
878877
FOR_BB_BETWEEN (bb, last_unvisited, NULL, prev_bb)
879-
if (!TEST_BIT (data->visited_blocks, bb->index - (INVALID_BLOCK + 1)))
878+
if (!TEST_BIT (data->visited_blocks, bb->index))
880879
return bb;
881880

882881
return NULL;
@@ -912,12 +911,12 @@ dfs_enumerate_from (basic_block bb, int reverse,
912911
static sbitmap visited;
913912
static unsigned v_size;
914913

915-
#define MARK_VISITED(BB) (SET_BIT (visited, (BB)->index + 2))
916-
#define UNMARK_VISITED(BB) (RESET_BIT (visited, (BB)->index + 2))
917-
#define VISITED_P(BB) (TEST_BIT (visited, (BB)->index + 2))
914+
#define MARK_VISITED(BB) (SET_BIT (visited, (BB)->index))
915+
#define UNMARK_VISITED(BB) (RESET_BIT (visited, (BB)->index))
916+
#define VISITED_P(BB) (TEST_BIT (visited, (BB)->index))
918917

919918
/* Resize the VISITED sbitmap if necessary. */
920-
size = last_basic_block + 2;
919+
size = last_basic_block;
921920
if (size < 10)
922921
size = 10;
923922

gcc/cfgbuild.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ control_flow_insn_p (rtx insn)
138138
static int
139139
count_basic_blocks (rtx f)
140140
{
141-
int count = 0;
141+
int count = NUM_FIXED_BLOCKS;
142142
bool saw_insn = false;
143143
rtx insn;
144144

@@ -164,10 +164,10 @@ count_basic_blocks (rtx f)
164164

165165
/* The rest of the compiler works a bit smoother when we don't have to
166166
check for the edge case of do-nothing functions with no basic blocks. */
167-
if (count == 0)
167+
if (count == NUM_FIXED_BLOCKS)
168168
{
169169
emit_insn (gen_rtx_USE (VOIDmode, const0_rtx));
170-
count = 1;
170+
count = NUM_FIXED_BLOCKS + 1;
171171
}
172172

173173
return count;
@@ -529,10 +529,11 @@ find_basic_blocks (rtx f)
529529
}
530530

531531
n_basic_blocks = count_basic_blocks (f);
532-
last_basic_block = 0;
532+
last_basic_block = NUM_FIXED_BLOCKS;
533533
ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR;
534534
EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR;
535535

536+
536537
/* Size the basic block table. The actual structures will be allocated
537538
by find_basic_blocks_1, since we want to keep the structure pointers
538539
stable across calls to find_basic_blocks. */
@@ -542,6 +543,8 @@ find_basic_blocks (rtx f)
542543
actually lay them out. */
543544

544545
VARRAY_BB_INIT (basic_block_info, n_basic_blocks, "basic_block_info");
546+
BASIC_BLOCK (ENTRY_BLOCK) = ENTRY_BLOCK_PTR;
547+
BASIC_BLOCK (EXIT_BLOCK) = EXIT_BLOCK_PTR;
545548

546549
find_basic_blocks_1 (f);
547550

gcc/cfgcleanup.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ try_forward_edges (int mode, basic_block b)
441441
}
442442

443443
target = first = e->dest;
444-
counter = 0;
444+
counter = NUM_FIXED_BLOCKS;
445445

446446
/* If we are partitioning hot/cold basic_blocks, we don't want to mess
447447
up jumps that cross between hot/cold sections.
@@ -503,7 +503,7 @@ try_forward_edges (int mode, basic_block b)
503503
if (t->dest == b)
504504
break;
505505

506-
gcc_assert (nthreaded_edges < n_basic_blocks);
506+
gcc_assert (nthreaded_edges < n_basic_blocks - NUM_FIXED_BLOCKS);
507507
threaded_edges[nthreaded_edges++] = t;
508508

509509
new_target = t->dest;
@@ -1676,7 +1676,7 @@ try_optimize_cfg (int mode)
16761676
/* Note that forwarder_block_p true ensures that
16771677
there is a successor for this block. */
16781678
&& (single_succ_edge (b)->flags & EDGE_FALLTHRU)
1679-
&& n_basic_blocks > 1)
1679+
&& n_basic_blocks > NUM_FIXED_BLOCKS + 1)
16801680
{
16811681
if (dump_file)
16821682
fprintf (dump_file,

0 commit comments

Comments
 (0)