2009/8/18 Pekka Enberg <penb...@cs.helsinki.fi>: > Lets use radix_tree_lookup() and get rid of the nasty loop in > bb_last_insn(). For some reason, this seems to fix the infinite loop > triggered by empty basic blocks. > > Cc: Arthur HUILLET <arthur.huil...@free.fr> > Cc: Tomek Grabiec <tgrab...@gmail.com> > Signed-off-by: Pekka Enberg <penb...@cs.helsinki.fi> > --- > jit/basic-block.c | 16 +--------------- > jit/spill-reload.c | 2 +- > 2 files changed, 2 insertions(+), 16 deletions(-) > > diff --git a/jit/basic-block.c b/jit/basic-block.c > index 6de5c3f..dbf3675 100644 > --- a/jit/basic-block.c > +++ b/jit/basic-block.c > @@ -176,21 +176,7 @@ struct insn *bb_first_insn(struct basic_block *bb) > > struct insn *bb_last_insn(struct basic_block *bb) > { > - struct insn *this = list_entry(bb->insn_list.prev, struct insn, > insn_list_node); > - > - /* > - * We want to return the last "real" instruction of the basic block. > Taking the > - * last of the insn_list will not work in case a live interval has > been spilled > - * right after the final jump of the basic block. > - * This is a side effect of the linear scan algorithm. > - * > - * As a result, we browse instructions starting from the last, in > order to find the one > - * that has a LIR position matching the position for the end of the > block. > - */ > - while (this->lir_pos != bb->end_insn - 1) { > - this = list_entry(this->insn_list_node.prev, struct insn, > insn_list_node); > - } > - return this; > + return list_entry(bb->insn_list.prev, struct insn, insn_list_node); > } > > static int __bb_add_neighbor(void *new, void **array, unsigned long *nb) > diff --git a/jit/spill-reload.c b/jit/spill-reload.c > index 5ced80e..515db8a 100644 > --- a/jit/spill-reload.c > +++ b/jit/spill-reload.c > @@ -183,7 +183,7 @@ static void insert_mov_insns(struct compilation_unit *cu, > struct insn *spill_at_insn; > int i; > > - spill_at_insn = bb_last_insn(from_bb); > + spill_at_insn = radix_tree_lookup(cu->lir_insn_map, > from_bb->end_insn - 1); > > /* Spill all intervals that have to be resolved */ > for (i = 0; i < nr_mapped; i++) { > -- > 1.5.6.3 > >
Like I said on IRC, this will not work for empty basic blocks, because spill_at_insn will belong to the preceding basic block. This causes that instructions will be added to different (preceding) basic block and might not be executed on some execution paths. -- Tomek Grabiec ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel