[pypy-svn] r48115 - in pypy/dist/pypy/translator/backendopt: . test
arigo at codespeak.net
arigo at codespeak.net
Sat Oct 27 19:20:23 CEST 2007
Author: arigo
Date: Sat Oct 27 19:20:22 2007
New Revision: 48115
Modified:
pypy/dist/pypy/translator/backendopt/constfold.py
pypy/dist/pypy/translator/backendopt/test/test_constfold.py
Log:
Reintroduce 47798 in a more conservative version.
The flags in lloperation are not really consistent.
Added a test for what I'm trying to achieve with this.
Modified: pypy/dist/pypy/translator/backendopt/constfold.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/constfold.py (original)
+++ pypy/dist/pypy/translator/backendopt/constfold.py Sat Oct 27 19:20:22 2007
@@ -31,7 +31,8 @@
except AttributeError:
sideeffects = True
else:
- if len(args) == len(vargs):
+ sideeffects = op.sideeffects
+ if not sideeffects and len(args) == len(vargs):
RESTYPE = spaceop.result.concretetype
try:
result = op(RESTYPE, *args)
@@ -49,7 +50,6 @@
constants[spaceop.result] = Constant(result, RESTYPE)
folded_count += 1
continue
- sideeffects = op.sideeffects
# failed to fold an operation, exit early if requested
if exit_early:
return folded_count
Modified: pypy/dist/pypy/translator/backendopt/test/test_constfold.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_constfold.py (original)
+++ pypy/dist/pypy/translator/backendopt/test/test_constfold.py Sat Oct 27 19:20:22 2007
@@ -3,6 +3,7 @@
from pypy.translator.translator import TranslationContext, graphof
from pypy.rpython.llinterp import LLInterpreter
from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rlib import objectmodel
from pypy.translator.backendopt.constfold import constant_fold_graph
from pypy import conftest
@@ -234,3 +235,13 @@
assert summary(graph) == {'getarrayitem': 1}
check_graph(graph, [], 1234, t)
+
+
+def test_dont_constfold_debug_print():
+ def fn():
+ llop.debug_print(lltype.Void, "hello world")
+
+ graph, t = get_graph(fn, [])
+ assert summary(graph) == {'debug_print': 1}
+ constant_fold_graph(graph)
+ assert summary(graph) == {'debug_print': 1}
More information about the Pypy-commit
mailing list