[pypy-svn] r30305 - in pypy/dist/pypy/translator/llvm: . test

rxe at codespeak.net rxe at codespeak.net
Fri Jul 21 03:28:07 CEST 2006


Author: rxe
Date: Fri Jul 21 03:27:54 2006
New Revision: 30305

Modified:
   pypy/dist/pypy/translator/llvm/funcnode.py
   pypy/dist/pypy/translator/llvm/test/test_genllvm.py
Log:
Makeshift fix - seems we are not ssa anymore after transformations.  Hopefully
pypy-llvm will compile now.
  


Modified: pypy/dist/pypy/translator/llvm/funcnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/funcnode.py	(original)
+++ pypy/dist/pypy/translator/llvm/funcnode.py	Fri Jul 21 03:27:54 2006
@@ -4,7 +4,7 @@
 from pypy.translator.llvm.node import LLVMNode, ConstantLLVMNode
 from pypy.translator.llvm.opwriter import OpWriter
 from pypy.translator.llvm.log import log 
-from pypy.translator.unsimplify import remove_double_links
+from pypy.translator.unsimplify import remove_double_links, insert_empty_startblock
 log = log.funcnode
 
 class FuncTypeNode(LLVMNode):
@@ -67,8 +67,25 @@
     # main entry points from genllvm 
 
     def post_setup_transform(self):
-        remove_double_links(self.db.translator.annotator, self.graph)
+        graph = self.graph
+
+        remove_double_links(self.db.translator.annotator, graph)
+
+        # XXX below is a quick hack to compile pypy-llvm
+        broken_start_block = False
+        for block in graph.iterblocks():
+            for link in block.exits:
+                if link.target == graph.startblock:
+                    broken_start_block = True
+                    break
+
+        if broken_start_block:
+            insert_empty_startblock(None, graph)
         
+        for block in graph.iterblocks():
+            for link in block.exits:
+                assert link.target != graph.startblock
+
     def writedecl(self, codewriter): 
         codewriter.declare(self.getdecl())
 

Modified: pypy/dist/pypy/translator/llvm/test/test_genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/test_genllvm.py	Fri Jul 21 03:27:54 2006
@@ -418,3 +418,26 @@
     f = compile_function(testf, [int])
     assert f(1) == testf(1)
     assert f(2) == testf(2)
+
+def test_broken_after_transform():
+    class A:
+        pass
+    a = A()
+    a.count = 0
+    
+    def drop(n):
+        loops = 0
+        while n > 0:
+            n -= 1
+            a.count += 1
+
+    def rundrop(n):
+        drop(n)
+        return a.count
+
+    f = compile_function(rundrop, [int])
+    assert f(42) == 42
+    f = compile_function(rundrop, [int])
+    assert f(0) == 0
+    
+



More information about the Pypy-commit mailing list