[pypy-svn] r48352 - in pypy/dist/pypy/translator/backendopt: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Nov 7 11:30:00 CET 2007


Author: cfbolz
Date: Wed Nov  7 11:29:59 2007
New Revision: 48352

Modified:
   pypy/dist/pypy/translator/backendopt/coalloc.py
   pypy/dist/pypy/translator/backendopt/test/test_coalloc.py
Log:
test + fix: try to use the setvar when it is available in more cases.


Modified: pypy/dist/pypy/translator/backendopt/coalloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/coalloc.py	(original)
+++ pypy/dist/pypy/translator/backendopt/coalloc.py	Wed Nov  7 11:29:59 2007
@@ -363,7 +363,7 @@
         return None
     result = 0
     for block in graph.iterblocks():
-        seen_setvar = False
+        seen_setvar = setop.args[0] in block.inputargs
         for op in block.operations:
             if block is setblock and op.result is setop.args[0]:
                 seen_setvar = True

Modified: pypy/dist/pypy/translator/backendopt/test/test_coalloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_coalloc.py	(original)
+++ pypy/dist/pypy/translator/backendopt/test/test_coalloc.py	Wed Nov  7 11:29:59 2007
@@ -266,6 +266,28 @@
         return 1
     t = check_malloc_to_coalloc(f, [], [], 1, must_remove=1)
 
+def test_coalloc_in_setblock_args():
+    class A(object):
+        pass
+    def g():
+        return A()
+    globala = A()
+    def f(x):
+        if x:
+            a = g()
+        else:
+            a = globala
+        a1 = A()
+        a.a = a1
+        return 1
+    t = check_malloc_to_coalloc(f, [int], [1], 1, must_remove=1)
+    fgraph = t.graphs[0]
+    # make sure that the coallocator is not globala but the variable a
+    block = fgraph.startblock.exits[0].target
+    op = block.operations[0]
+    assert op.opname == "coalloc"
+    assert op.args[1] is block.inputargs[0]
+
 
 def test_nocoalloc_finalizer():
     class A(object):



More information about the Pypy-commit mailing list