瀏覽代碼

Fix a bug in SSA construction

jonathanvdc 8 年之前
父節點
當前提交
82967407c6
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      kernel/modelverse_jit/cfg_ssa_construction.py

+ 5 - 2
kernel/modelverse_jit/cfg_ssa_construction.py

@@ -45,7 +45,7 @@ def get_ineligible_local_ids(entry_point):
 def construct_ssa_form(entry_point):
     """Converts local variables into SSA form in the graph defined by the given entry point."""
     # Build some helper data structures.
-    all_blocks = cfg_ir.get_all_blocks(entry_point)
+    all_blocks = list(cfg_ir.get_all_blocks(entry_point))
     ineligible_locals = get_ineligible_local_ids(entry_point)
     predecessor_map = cfg_ir.get_all_predecessor_blocks(entry_point)
 
@@ -134,6 +134,9 @@ class SSAConstructionState(object):
         if trivial_phi_val is None:
             return phi_def
         else:
+            for pred in self.predecessor_map[phi_def.block]:
+                del self.extra_phi_operands[pred][phi_def]
+
             phi_def.block.remove_parameter(phi_def)
             phi_def.redefine(trivial_phi_val)
             phi_def.block.prepend_definition(phi_def)
@@ -216,7 +219,7 @@ class SSAConstructionState(object):
             # Find all pairs phis which are defined in the branch target block.
             applicable_pairs = [
                 (phi_def, operand_def)
-                for phi_def, operand_def in self.extra_phi_operands[block]
+                for phi_def, operand_def in self.extra_phi_operands[block].items()
                 if phi_def.block == branch.block]
 
             if len(applicable_pairs) == 0: