Author: leo
Date: Sat Oct 29 10:02:11 2005
New Revision: 9630

Modified:
   trunk/imcc/reg_alloc.c
   trunk/imcc/t/reg/alloc.t
Log:
fix register alligator bug, spotted by pmichaud - thanks

Modified: trunk/imcc/reg_alloc.c
==============================================================================
--- trunk/imcc/reg_alloc.c      (original)
+++ trunk/imcc/reg_alloc.c      Sat Oct 29 10:02:11 2005
@@ -738,10 +738,13 @@ interferes(Interp *interpreter, IMC_Unit
         if (l1->first_ins->index > l0->last_ins->index)
             continue;
 
-#if 1
+#if 0
         /* If they only overlap one instruction and one is used RHS only
          * and the other LHS, then that's ok
          * same if both are LHS
+         *
+         * XXX While the idea is ok, the following tests are wrong
+         * see imcc/t/reg/alloc_2
          */
         if (l0->first_ins->index == l1->last_ins->index &&
                 instruction_writes(l0->first_ins, r0) &&

Modified: trunk/imcc/t/reg/alloc.t
==============================================================================
--- trunk/imcc/t/reg/alloc.t    (original)
+++ trunk/imcc/t/reg/alloc.t    Sat Oct 29 10:02:11 2005
@@ -3,7 +3,7 @@
 # $Id$
 
 use strict;
-use Parrot::Test tests => 1;
+use Parrot::Test tests => 2;
 
 pir_output_is(<<'CODE', <<'OUT', "alligator");
 # if the side-effect of newsub/continuation isn't
@@ -32,3 +32,31 @@ CODE
 Hi
 Hi
 OUT
+
+pir_output_is(<<'CODE', <<'OUT', "alligator 2 - r9629");
+.sub xyz
+    .local pmc args
+    args = new .ResizablePMCArray
+    push args, "abc"
+    push args, "def"
+    push args, "POPME"
+
+    $S0 = args[-1]
+    if $S0 != "POPME" goto start
+    $P0 = pop args
+  start:
+    $I1 = elements args
+    $I0 = 0
+  loop:
+    if $I0 >= $I1 goto end
+    $S0 = args[$I0]
+    print $S0
+    print "\n"
+    inc $I0
+    goto loop
+  end:
+.end
+CODE
+abc
+def
+OUT

Reply via email to