When interval ends just before the next basic block, then prev_insn() will be called on that next basic block's first instruction and will return invalid instruction. We should not use prev_insn here because it does not work across basic block boundaries.
Simmilar applies for next_insn() and get_reload_after_insn(). Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- jit/spill-reload.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jit/spill-reload.c b/jit/spill-reload.c index 3dfb0b3..7624bd6 100644 --- a/jit/spill-reload.c +++ b/jit/spill-reload.c @@ -49,11 +49,10 @@ struct live_interval_mapping { static struct insn * get_reload_before_insn(struct compilation_unit *cu, struct live_interval *interval) { + unsigned long start; struct insn *ret; - unsigned long start = interval_start(interval); - - ret = radix_tree_lookup(cu->lir_insn_map, start); + start = interval_start(interval); if (start & 1) { /* @@ -64,10 +63,12 @@ get_reload_before_insn(struct compilation_unit *cu, struct live_interval *interv * odd position and has no use at this position, we * should reload after that instruction. */ - if (first_use_pos(interval) == interval_start(interval)) + if (first_use_pos(interval) == start) error("interval begins with a def-use and is marked for reload"); - ret = next_insn(ret); + ret = radix_tree_lookup(cu->lir_insn_map, start + 1); + } else { + ret = radix_tree_lookup(cu->lir_insn_map, start); } assert(ret != NULL); @@ -90,8 +91,7 @@ get_spill_after_insn(struct compilation_unit *cu, struct live_interval *interval if (last_pos & 1) { ret = radix_tree_lookup(cu->lir_insn_map, last_pos - 1); } else { - ret = radix_tree_lookup(cu->lir_insn_map, last_pos); - ret = prev_insn(ret); + ret = radix_tree_lookup(cu->lir_insn_map, last_pos - 2); } assert(ret != NULL); -- 1.6.0.4 ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel