Fix bug where some phis weren't being inserted when a given variable definition
authorDavid Given <dg@cowlark.com>
Thu, 27 Oct 2016 19:40:25 +0000 (21:40 +0200)
committerDavid Given <dg@cowlark.com>
Thu, 27 Oct 2016 19:40:25 +0000 (21:40 +0200)
needed more than one phi (due to the dominance frontier containing more than
one basic block).

mach/proto/mcg/pass_ssa.c

index 260ad92..e0f835f 100644 (file)
@@ -185,12 +185,16 @@ static void ssa_convert(void)
     for (i=0; i<defining.count; i++)
     {
         struct basicblock* bb = defining.item[i];
-        struct basicblock* dominates = pmap_findleft(&dominancefrontiers, bb);
-        if (dominates)
+        tracef('S', "S: local %d in defined in block %s\n", current_local->offset, bb->name);
+        for (j=0; j<dominancefrontiers.count; j++)
         {
-            array_appendu(&needsphis, dominates);
-            array_appendu(&defining, dominates);
-            tracef('S', "S: local %d needs phi in block %s\n", current_local->offset, dominates->name);
+            if (dominancefrontiers.item[j].left == bb)
+            {
+                struct basicblock* dominates = dominancefrontiers.item[j].right;
+                array_appendu(&needsphis, dominates);
+                array_appendu(&defining, dominates);
+                tracef('S', "S: local %d needs phi in block %s\n", current_local->offset, dominates->name);
+            }
         }
     }