[pypy-svn] r36730 - in pypy/dist/pypy/jit/codegen/llgraph: . test

mwh at codespeak.net mwh at codespeak.net
Sun Jan 14 13:24:45 CET 2007


Author: mwh
Date: Sun Jan 14 13:24:42 2007
New Revision: 36730

Modified:
   pypy/dist/pypy/jit/codegen/llgraph/llimpl.py
   pypy/dist/pypy/jit/codegen/llgraph/test/test_rgenop.py
Log:
make sure that the llgraph backend will explode when you write a test that does
not call builder.end() (to stop Eric having to bug me or Armin about it when
this breaks the llvm generator)


Modified: pypy/dist/pypy/jit/codegen/llgraph/llimpl.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llgraph/llimpl.py	(original)
+++ pypy/dist/pypy/jit/codegen/llgraph/llimpl.py	Sun Jan 14 13:24:42 2007
@@ -43,6 +43,14 @@
         v.concretetype = lltype.erasedType(ARG)
         erasedinputargs.append(v)
     startblock = flowmodel.Block(inputargs)
+    # insert an exploding operation here which is removed by
+    # builder.end() to ensure that builder.end() is actually called.
+    startblock.operations.append(
+        flowmodel.SpaceOperation("debug_assert",
+                                 [flowmodel.Constant(False, lltype.Bool),
+                                  flowmodel.Constant("you didn't call builder.end()?",
+                                                     lltype.Void)],
+                                 varoftype(lltype.Void)))
     return_var = flowmodel.Variable()
     return_var.concretetype = FUNCTYPE.RESULT
     graph = flowmodel.FunctionGraph(name, startblock, return_var)
@@ -204,8 +212,9 @@
     return isinstance(c, flowmodel.Constant)
 
 # XXX
-# temporary interface; it's unclera if genop itself should change to ease dinstinguishing
-# Void special args from the rest. Or there should be variation for the ops involving them
+# temporary interface; it's unclear if genop itself should change to
+# ease dinstinguishing Void special args from the rest. Or there
+# should be variation for the ops involving them
 
 def placeholder(dummy):
     c = flowmodel.Constant(dummy)
@@ -418,6 +427,8 @@
             done[block] = True
 
 def _buildgraph(graph):
+    assert graph.startblock.operations[0].opname == 'debug_assert'
+    del graph.startblock.operations[0]
     # rgenop makes graphs that use the same variable in several blocks,
     fixduplicatevars(graph)                             # fix this now
     flowmodel.checkgraph(graph)

Modified: pypy/dist/pypy/jit/codegen/llgraph/test/test_rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llgraph/test/test_rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/llgraph/test/test_rgenop.py	Sun Jan 14 13:24:42 2007
@@ -55,3 +55,14 @@
     ptr = gv_f.revealconst(lltype.Ptr(F1))
     res = testgengraph(ptr._obj.graph, [21])
     assert res == 42
+
+def test_not_calling_end_explodes():
+    F1 = lltype.FuncType([lltype.Signed], lltype.Signed)
+    rgenop = RGenOp()
+    sigtoken = rgenop.sigToken(F1)
+    builder, gv_adder, [gv_x] = rgenop.newgraph(sigtoken, "adder")
+    gv_result = builder.genop2("int_add", gv_x, rgenop.genconst(5))
+    builder.finish_and_return(sigtoken, gv_result)
+    #builder.end() <--- the point
+    ptr = gv_adder.revealconst(lltype.Ptr(F1))
+    py.test.raises(AssertionError, "testgengraph(ptr._obj.graph, [1])")



More information about the Pypy-commit mailing list