Sfoglia il codice sorgente

Protected {alloc|free}-root-node from dead code elimination

jonathanvdc 8 anni fa
parent
commit
a01ac84e97
1 ha cambiato i file con 9 aggiunte e 3 eliminazioni
  1. 9 3
      kernel/modelverse_jit/cfg_ir.py

+ 9 - 3
kernel/modelverse_jit/cfg_ir.py

@@ -48,6 +48,8 @@ class BasicBlock(object):
     def create_definition(self, value=None):
         """Creates a definition, but does not assign it to this block yet."""
         if isinstance(value, Definition):
+            value.block = self
+            value.renumber(self.definition_counter.next_value())
             return value
         else:
             assert isinstance(value, Value) or value is None
@@ -83,13 +85,13 @@ class Definition(object):
         self.definition_index = definition_index
         self.value = value
         if value is not None:
-            assert isinstance(value, Value)
+            assert isinstance(value, Value) or isinstance(value, Definition)
 
     def redefine(self, new_value):
         """Tweaks this definition to take on the given new value."""
         self.value = new_value
         if new_value is not None:
-            assert isinstance(new_value, Value)
+            assert isinstance(new_value, Value) or isinstance(new_value, Definition)
 
     def renumber(self, new_definition_index):
         """Updates this definition's index in the block that defines it."""
@@ -366,7 +368,11 @@ class DeallocateRootNode(Value):
 
     def get_dependencies(self):
         """Gets all definitions and instructions on which this instruction depends."""
-        return []
+        return [self.root_node]
+
+    def has_side_effects(self):
+        """Tells if this instruction has side-effects."""
+        return True
 
     def __str__(self):
         return 'free-root-node %s' % self.root_node.ref_str()