All registers that were defined in the basic block were subtracted from the
use set. This is right if the order is "define, use", but it's wrong if the
order is "use, define". Fix this by checking if the register has already
been used/defined.

Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com>
---
 jit/liveness.c               |   18 +++++++++---------
 test/jit/spill-reload-test.c |   12 ++++++------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/jit/liveness.c b/jit/liveness.c
index 84b413a..90f2a0c 100644
--- a/jit/liveness.c
+++ b/jit/liveness.c
@@ -147,18 +147,18 @@ static void __analyze_use_def(struct basic_block *bb, 
struct insn *insn)
        struct var_info *var;
 
        for_each_variable(var, bb->b_parent->var_infos) {
+               if (insn_uses(insn, var)) {
+                       /*
+                        * It's in the use set if and only if it has not
+                        * _already_ been defined by insn basic block.
+                        */
+                       if (!test_bit(bb->def_set->bits, var->vreg))
+                               set_bit(bb->use_set->bits, var->vreg);
+               }
+
                if (insn_defs(insn, var))
                        set_bit(bb->def_set->bits, var->vreg);
-
-               if (insn_uses(insn, var))
-                       set_bit(bb->use_set->bits, var->vreg);
        }
-
-       /*
-        * It's in the use set if and only if it has not been defined
-        * by insn basic block.
-        */
-       bitset_sub(bb->def_set, bb->use_set);
 }
 
 static void analyze_use_def(struct compilation_unit *cu)
diff --git a/test/jit/spill-reload-test.c b/test/jit/spill-reload-test.c
index bf0abba..2b654ee 100644
--- a/test/jit/spill-reload-test.c
+++ b/test/jit/spill-reload-test.c
@@ -122,16 +122,16 @@ void 
test_reload_insn_is_inserted_at_the_beginning_of_the_interval_if_necessary(
        insert_spill_reload_insns(cu);
 
        /*
-        * First instruction stays the same. 
-        */
+        * A reload instruction is inserted at the beginning.
+        */ 
        insn = list_first_entry(&bb->insn_list, struct insn, insn_list_node);
-       assert_ptr_equals(insn_array[0], insn);
+       assert_ld_insn(INSN_LD_LOCAL, r2->interval->reg, 
r1->interval->spill_slot, insn);
 
        /*
-        * A reload instruction is inserted before the interval end.
-        */ 
+        * Second instruction stays the same. 
+        */
        insn = list_next_entry(&insn->insn_list_node, struct insn, 
insn_list_node);
-       assert_ld_insn(INSN_LD_LOCAL, r2->interval->reg, 
r1->interval->spill_slot, insn);
+       assert_ptr_equals(insn_array[0], insn);
 
        /*
         * Last instruction stays the same. 
-- 
1.6.0.6


------------------------------------------------------------------------------
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

Reply via email to