[pypy-svn] r15914 - in pypy/dist/pypy/translator/llvm2: . module test
ericvrp at codespeak.net
ericvrp at codespeak.net
Wed Aug 10 16:04:04 CEST 2005
Author: ericvrp
Date: Wed Aug 10 16:04:03 2005
New Revision: 15914
Modified:
pypy/dist/pypy/translator/llvm2/module/ll_time.py
pypy/dist/pypy/translator/llvm2/module/support.py
pypy/dist/pypy/translator/llvm2/opwriter.py
pypy/dist/pypy/translator/llvm2/test/test_exception.py
pypy/dist/pypy/translator/llvm2/test/test_typed.py
Log:
* moved neg/abs overflow tests to test_exception
* fixed overflow test in support.py
* neg/abs with overflow probably fail because of an llvm bug
(added bug 617 to llvm bug database)
* fixed test that used to require --nomagic
* fixed bug in opwriter whereby to many exception raising operations were reported
Modified: pypy/dist/pypy/translator/llvm2/module/ll_time.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/ll_time.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/ll_time.py Wed Aug 10 16:04:03 2005
@@ -44,7 +44,6 @@
%tmp.13 = cast int %tmp.12 to double ; <double> [#uses=1]
ret double %tmp.13
}
-
""")
extfunctions["%ll_time_clock"] = ((), """
@@ -82,5 +81,4 @@
return: ; preds = %entry
ret void
}
-
""")
Modified: pypy/dist/pypy/translator/llvm2/module/support.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/support.py (original)
+++ pypy/dist/pypy/translator/llvm2/module/support.py Wed Aug 10 16:04:03 2005
@@ -72,7 +72,6 @@
store %%structtype.object* %%exception_value, %%structtype.object** %%last_exception_value
ret void
}
-
""" % locals())
@@ -98,18 +97,17 @@
""" % locals())
-ovf_test = """
- ;overflow test
- %%cond2 = setge int %%x2, 0
- br bool %%cond2, label %%return_block, label %%block2
+int_ovf_test = """
+ ;integer overflow test
+ %cond2 = setge int %x, 0
+ br bool %cond2, label %return_block, label %block2
block2:
- %%tmp = sub int 0, %%x2
- %%cond3 = setne int %%x2, %%tmp
- br bool %%cond3, label %%return_block, label %%ovf
+ %xneg = sub int 0, %x
+ %cond3 = setne int %x, %xneg
+ br bool %cond3, label %return_block, label %ovf
ovf:
- call fastcc void %%__prepare_OverflowError()
+ call fastcc void %__prepare_OverflowError()
unwind
-
"""
#unary with OverflowError only
@@ -118,11 +116,10 @@
fastcc int %%int_neg_ovf(int %%x) {
block1:
%%x2 = sub int 0, %%x
- %(ovf_test)s
+ %(int_ovf_test)s
return_block:
ret int %%x2
}
-
""" % locals())
extfunctions["%int_abs_ovf"] = (("%__prepare_OverflowError",), """
@@ -132,12 +129,11 @@
br bool %%cond1, label %%return_block, label %%block1
block1:
%%x2 = sub int 0, %%x
- %(ovf_test)s
+ %(int_ovf_test)s
return_block:
%%result = phi int [%%x, %%block0], [%%x2, %%block1], [%%x2, %%block2]
ret int %%result
}
-
""" % locals())
Modified: pypy/dist/pypy/translator/llvm2/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/opwriter.py (original)
+++ pypy/dist/pypy/translator/llvm2/opwriter.py Wed Aug 10 16:04:03 2005
@@ -274,10 +274,12 @@
opname = op.opname.split(':',1)[1]
op_args = ['%' + opname] + op_args
functionref = op_args[0]
- ExternalFuncNode.used_external_functions[functionref] = True
- msg = "exception raising operation %s not found" %(op.opname,)
- self.codewriter.comment('XXX: Error: ' + msg)
- #assert functionref in extfunctions, msg
+ if functionref in extfunctions:
+ ExternalFuncNode.used_external_functions[functionref] = True
+ else:
+ msg = "exception raising operation %s not found" %(op.opname,)
+ self.codewriter.comment('XXX: Error: ' + msg)
+ #assert functionref in extfunctions, msg
assert len(op_args) >= 1
assert len(self.block.exits) >= 2 #at least one label and one exception label
Modified: pypy/dist/pypy/translator/llvm2/test/test_exception.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_exception.py (original)
+++ pypy/dist/pypy/translator/llvm2/test/test_exception.py Wed Aug 10 16:04:03 2005
@@ -2,7 +2,7 @@
from pypy.translator.llvm2.genllvm import compile_function
from pypy.translator.test.snippet import try_raise_choose
-from pypy.rpython.rarithmetic import r_uint
+from pypy.rpython.rarithmetic import r_uint, ovfcheck, ovfcheck_lshift
import sys
@@ -139,10 +139,10 @@
assert f(i) == zerodivrem_uint(i)
def test_neg_int_ovf():
- py.test.skip("When does int_neg_ovf get generated")
+ py.test.skip("test failing probably because llvm things x != -x is always true")
def neg_int_ovf(n):
try:
- r=-n
+ r=ovfcheck(-n)
except OverflowError:
return 123
return r
@@ -151,14 +151,14 @@
assert f(i) == neg_int_ovf(i)
def test_abs_int_ovf():
- py.test.skip("When does int_abs_ovf get generated")
+ py.test.skip("test failing probably because llvm things x != -x is always true")
def abs_int_ovf(n):
try:
- r=abs(n)
+ r=ovfcheck(abs(n))
except OverflowError:
return 123
return r
- f = compile_function(abs_int_ovf, [int], True)
+ f = compile_function(abs_int_ovf, [int])
for i in (-sys.maxint-1, -sys.maxint, 0, sys.maxint-1, sys.maxint):
assert f(i) == abs_int_ovf(i)
@@ -263,7 +263,6 @@
assert f(i) == i
def test_raise_outside_testfn():
- py.test.skip("Test needs --nomagic!")
def raiser(n):
if n < 0:
raise ValueError("hello")
@@ -281,8 +280,23 @@
except Exception:
return 2
return 0
-
- f = compile_function(testfn, [int])
- assert f(1) == testfn(1)
- assert f(-1) == testfn(-1)
+ saved = no_magic()
+ try:
+ f = compile_function(testfn, [int])
+ assert f(1) == testfn(1)
+ assert f(-1) == testfn(-1)
+ finally:
+ restore_magic(saved)
+
+def no_magic():
+ import __builtin__
+ try:
+ py.magic.revert(__builtin__, 'AssertionError')
+ return True
+ except ValueError:
+ return False
+
+def restore_magic(saved):
+ if saved:
+ py.magic.invoke(assertion=True)
Modified: pypy/dist/pypy/translator/llvm2/test/test_typed.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_typed.py (original)
+++ pypy/dist/pypy/translator/llvm2/test/test_typed.py Wed Aug 10 16:04:03 2005
@@ -302,14 +302,6 @@
fn = compile_function(snippet.lshift_func, [int])
raises(ValueError, fn, -1)
-def test_int_unary_ovf():
- py.test.skip("int_neg_ovf operation missing (raises)")
- fn = compile_function(snippet.unary_func, [int])
- for i in range(-3,3):
- assert fn(i) == (-(i), abs(i-1))
- raises (OverflowError, fn, -sys.maxint-1)
- raises (OverflowError, fn, -sys.maxint)
-
def test_uint_arith():
py.test.skip("uint_floordiv_zer operation missing (raises)")
def fn(i):
More information about the Pypy-commit
mailing list