[pypy-svn] r25837 - pypy/dist/pypy/translator/backendopt
cfbolz at codespeak.net
cfbolz at codespeak.net
Sat Apr 15 01:10:30 CEST 2006
Author: cfbolz
Date: Sat Apr 15 01:10:27 2006
New Revision: 25837
Modified:
pypy/dist/pypy/translator/backendopt/propagate.py
Log:
don't crash if the operation is not in the table of all operations
Modified: pypy/dist/pypy/translator/backendopt/propagate.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/propagate.py (original)
+++ pypy/dist/pypy/translator/backendopt/propagate.py Sat Apr 15 01:10:27 2006
@@ -134,7 +134,10 @@
return super(CountingLLFrame, self).eval_operation(operation)
def op_can_be_folded(op):
- return not lloperation.LL_OPERATIONS[op.opname].canfold
+ try:
+ return not lloperation.LL_OPERATIONS[op.opname].canfold
+ except KeyError:
+ return True
def constant_folding(graph, translator):
"""do constant folding if the arguments of an operations are constants"""
@@ -145,7 +148,7 @@
for i, op in enumerate(block.operations):
if sum([isinstance(arg, Variable) for arg in op.args]):
continue
- if lloperation.LL_OPERATIONS[op.opname].canfold:
+ if op.opname in lloperation.LL_OPERATIONS and lloperation.LL_OPERATIONS[op.opname].canfold:
if op.opname in ("getsubstruct", "getarraysubstruct"):
if not var_needsgc(op.result):
continue
@@ -201,7 +204,8 @@
return
usedvars = {}
for op in block.operations:
- if not lloperation.LL_OPERATIONS[op.opname].canfold:
+ if (op.opname not in lloperation.LL_OPERATIONS or
+ not lloperation.LL_OPERATIONS[op.opname].canfold):
return
for arg in op.args:
if (isinstance(arg, Variable) and arg in block.inputargs):
@@ -239,6 +243,8 @@
else:
assert 0, "this should not occur"
unchanged = link.target == nextblock and link.args == newargs
+ if not unchanged:
+ print "doing partial folding in graph", graph.name
link.target = nextblock
link.args = newargs
checkgraph(graph)
@@ -361,6 +367,7 @@
translator) or changed
changed = partial_folding(graph, translator) or changed
changed = remove_all_getfields(graph, translator) or changed
+ checkgraph(graph)
return changed
do_atmost(10, prop)
More information about the Pypy-commit
mailing list