This patch fixes the branch reorganization failing for tail recursion.

Previously.
-----------
$ ./parrot -Oc ack.pir 3
Ack(3, 3) = 61

$ /parrot -Oc1 ack.pir 3
maximum recursion depth exceeded (According to Leo)
But on Linux I was getting a segfault.

After
------
$ ./parrot -Oc ./examples/shootout/ack.pir 3
Ack(3, 3) = 61
$ ./parrot -Oc1 ./examples/shootout/ack.pir 3
Ack(3, 3) = 61

Thanks,
Vishal

Index: CREDITS
===================================================================
--- CREDITS     (revision 13046)
+++ CREDITS     (working copy)
@@ -470,3 +470,7 @@
 N: Norman Nunley
 D: Shaving a Ponie
 E: [EMAIL PROTECTED]
+
+N: Vishal Soni
+E: [EMAIL PROTECTED]
+D: Bug fixes in IMCC
Index: compilers/imcc/optimizer.c
===================================================================
--- compilers/imcc/optimizer.c  (revision 13046)
+++ compilers/imcc/optimizer.c  (working copy)
@@ -932,7 +932,7 @@
                     }

                     /* this was screwing up multi-block loops... */
-                    if (end != ins) {
+                    if (end != ins && ins->next !=NULL ) {
                         ins->next->prev = end;
                         start->prev->next = end->next;
                         if (end->next)


--
Thanks,
Vishal
Index: CREDITS
===================================================================
--- CREDITS	(revision 13046)
+++ CREDITS	(working copy)
@@ -470,3 +470,7 @@
 N: Norman Nunley
 D: Shaving a Ponie
 E: [EMAIL PROTECTED]
+
+N: Vishal Soni
+E: [EMAIL PROTECTED]
+D: Bug fixes in IMCC
Index: compilers/imcc/optimizer.c
===================================================================
--- compilers/imcc/optimizer.c	(revision 13046)
+++ compilers/imcc/optimizer.c	(working copy)
@@ -932,7 +932,7 @@
                     }
 
                     /* this was screwing up multi-block loops... */
-                    if (end != ins) {
+                    if (end != ins && ins->next !=NULL ) {
                         ins->next->prev = end;
                         start->prev->next = end->next;
                         if (end->next)

Reply via email to