diff python/mem2reg.py @ 261:444b9df2ed99

try to split up code generation
author Windel Bouwman
date Fri, 09 Aug 2013 09:05:13 +0200
parents 74c6a20302d5
children 534b94b40aa8
line wrap: on
line diff
--- a/python/mem2reg.py	Tue Aug 06 18:29:53 2013 +0200
+++ b/python/mem2reg.py	Fri Aug 09 09:05:13 2013 +0200
@@ -5,7 +5,7 @@
 def isAllocPromotable(allocinst):
     # Check if alloc value is only used by load and store operations.
     assert type(allocinst) is Alloc
-    return all(type(use) in [Load,Store] for use in allocinst.value.used_by)
+    return all(type(use) in [Load, Store] for use in allocinst.value.used_by)
 
 class Mem2RegPromotor(FunctionPass):
     def promoteSingleBlock(self, ai):
@@ -24,9 +24,7 @@
             for store in stores:
                 if store.Position < load.Position:
                     break
-            for use_ins in load.value.used_by:
-                use_ins.replaceValue(load.value, store.value)
-            assert not load.value.Used
+            load.value.replaceby(store.value)
             logging.debug('replaced {} with {}'.format(load, store.value))
             bb.removeInstruction(load)