From c1e510b1fb12eba816d8731d069b3dfffea430eb Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 6 Sep 2006 12:01:18 +0000 Subject: [PATCH] - commented out be_ra_chordal_verify, an algorithm with a really bad asymptotic runtime. be_verify_register_allocation should find the same errors anyway... - fixes for block schedule creation --- ir/be/bechordal_main.c | 12 +++++---- ir/be/beirgmod.c | 2 ++ ir/be/besched.c | 60 +++++++++++++++++++++++++++++++----------- ir/be/beverify.c | 7 ++++- 4 files changed, 59 insertions(+), 22 deletions(-) diff --git a/ir/be/bechordal_main.c b/ir/be/bechordal_main.c index 6b376b05a..fd8d87479 100644 --- a/ir/be/bechordal_main.c +++ b/ir/be/bechordal_main.c @@ -722,8 +722,9 @@ static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi) } BE_TIMER_PUSH(ra_timer.t_verify); - if (options.vrfy_option != BE_CH_VRFY_OFF) - be_ra_chordal_check(&chordal_env); + if (options.vrfy_option != BE_CH_VRFY_OFF) { + //be_ra_chordal_check(&chordal_env); + } BE_TIMER_POP(ra_timer.t_verify); @@ -735,8 +736,9 @@ static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi) BE_TIMER_PUSH(ra_timer.t_verify); - if (options.vrfy_option != BE_CH_VRFY_OFF) - be_ra_chordal_check(&chordal_env); + if (options.vrfy_option != BE_CH_VRFY_OFF) { + //be_ra_chordal_check(&chordal_env); + } BE_TIMER_POP(ra_timer.t_verify); BE_TIMER_PUSH(ra_timer.t_ssa); @@ -751,7 +753,7 @@ static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi) BE_TIMER_PUSH(ra_timer.t_verify); if (options.vrfy_option != BE_CH_VRFY_OFF) { be_ssa_destruction_check(&chordal_env); - be_ra_chordal_check(&chordal_env); + //be_ra_chordal_check(&chordal_env); } BE_TIMER_POP(ra_timer.t_verify); diff --git a/ir/be/beirgmod.c b/ir/be/beirgmod.c index 9992afa9b..a3611397d 100644 --- a/ir/be/beirgmod.c +++ b/ir/be/beirgmod.c @@ -636,6 +636,8 @@ static void remove_empty_block(ir_node *block, void *data) { set_irn_n(block, pos, node); } + ir_printf("Removing %+F\n", block); + set_Block_cfgpred(block, 0, new_Bad()); sched_remove(jump); diff --git a/ir/be/besched.c b/ir/be/besched.c index 25aeb17c9..be565debc 100644 --- a/ir/be/besched.c +++ b/ir/be/besched.c @@ -211,27 +211,54 @@ typedef struct { unsigned n_blks; /**< number of blocks in the list */ } anchor; -/** - * Ext-Block walker: create a block schedule - */ -static void create_block_list(ir_extblk *blk, void *env) { - anchor *list = env; - int i, n; +static void add_block(anchor *list, ir_node *block) { + if(list->start == NULL) { + list->start = block; + list->end = block; + } else { + set_irn_link(list->end, block); + list->end = block; + } - for (i = 0, n = get_extbb_n_blocks(blk); i < n; ++i) { - ir_node *block = get_extbb_block(blk, i); + list->n_blks++; +} - set_irn_link(block, NULL); - if (list->start) - set_irn_link(list->end, block); - else - list->start = block; +static void create_block_list(ir_node *leader_block, anchor *list) { + int i; + ir_node *block = NULL; + const ir_edge_t *edge; - list->end = block; - ++list->n_blks; + ir_extblk *extbb = get_Block_extbb(leader_block); + if(extbb_visited(extbb)) + return; + mark_extbb_visited(extbb); + + for(i = 0; i < get_extbb_n_blocks(extbb); ++i) { + block = get_extbb_block(extbb, i); + add_block(list, block); + } + + assert(block != NULL); + + // pick successor extbbs + foreach_block_succ(block, edge) { + ir_node *succ = get_edge_src_irn(edge); + + create_block_list(succ, list); + } + + for(i = 0; i < get_extbb_n_blocks(extbb) - 1; ++i) { + block = get_extbb_block(extbb, i); + foreach_block_succ(block, edge) { + ir_node *succ = get_edge_src_irn(edge); + + create_block_list(succ, list); + } } } +void compute_extbb_execfreqs(ir_graph *irg, exec_freq_t *execfreqs); + /* * Calculates a block schedule. The schedule is stored as a linked * list starting at the start_block of the irg. @@ -249,7 +276,8 @@ ir_node **sched_create_block_schedule(ir_graph *irg, exec_freq_t *execfreqs) list.start = NULL; list.end = NULL; list.n_blks = 0; - irg_extblock_walk_graph(irg, NULL, create_block_list, &list); + inc_irg_block_visited(irg); + create_block_list(get_irg_start_block(irg), &list); /** create an array, so we can go forward and backward */ blk_list = NEW_ARR_D(ir_node *, irg->obst,list.n_blks); diff --git a/ir/be/beverify.c b/ir/be/beverify.c index 3d5bd20b7..a2195b164 100644 --- a/ir/be/beverify.c +++ b/ir/be/beverify.c @@ -600,7 +600,7 @@ static void check_register_allocation(be_verify_register_allocation_env_t *env, const arch_register_class_t *regclass, pset *nodes) { const arch_env_t *arch_env = env->arch_env; ir_node *node; - const arch_register_t *reg; + const arch_register_t *reg = NULL; int fail = 0; bitset_t *registers = bitset_alloca(arch_register_class_n_regs(regclass)); @@ -616,6 +616,11 @@ static void check_register_allocation(be_verify_register_allocation_env_t *env, env->problem_found = 1; continue; } + if(!arch_reg_is_allocatable(arch_env, node, -1, reg)) { + ir_fprintf(stderr, "Verify warning: Register %s assigned to %+F not allowed (register constraint) in block %+F(%s)\n", + reg->name, node, get_nodes_block(node), get_irg_dump_name(env->irg)); + env->problem_found = 1; + } if(bitset_is_set(registers, reg->index)) { pset_break(nodes); fail = 1; -- 2.20.1