From fb7b05420e71e2a7dd3d12e7456d93b9041bc159 Mon Sep 17 00:00:00 2001
From: Stephen Weeks <tene@allalone.org>
Date: Wed, 1 Oct 2008 22:22:31 -0600
Subject: [PATCH] [imcc]
 * Possibly fix an infinite loop in compute_dominance_frontiers.

---
 compilers/imcc/cfg.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/compilers/imcc/cfg.c b/compilers/imcc/cfg.c
index 03f2cbf..f628c77 100644
--- a/compilers/imcc/cfg.c
+++ b/compilers/imcc/cfg.c
@@ -1136,8 +1136,12 @@ compute_dominance_frontiers(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
 
                 /* while runner != idoms[b] */
                 while (runner >= 0 && runner != unit->idoms[b]) {
-                    /* add b to runner's dominance frontier set */
-                    set_add(unit->dominance_frontiers[runner], b);
+                    if (set_contains(unit->dominance_frontiers[runner], b))
+                        /* we've already gone down this path once before */
+                        runner = 0;
+                    else
+                        /* add b to runner's dominance frontier set */
+                        set_add(unit->dominance_frontiers[runner], b);
 
                     /* runner = idoms[runner] */
                     if (runner == 0)
-- 
1.5.5.1

