Author: David Schneider <[email protected]>
Branch: arm-backed-float
Changeset: r44520:85393a5c17dc
Date: 2011-05-26 16:56 +0200
http://bitbucket.org/pypy/pypy/changeset/85393a5c17dc/
Log: make sure to spill the variables before reordering them to perform
the call
diff --git a/pypy/jit/backend/arm/opassembler.py
b/pypy/jit/backend/arm/opassembler.py
--- a/pypy/jit/backend/arm/opassembler.py
+++ b/pypy/jit/backend/arm/opassembler.py
@@ -359,12 +359,12 @@
num += 1
count += 1
+ # spill variables that need to be saved around calls
+ regalloc.before_call(save_all_regs=2)
+
# remap values stored in core registers
remap_frame_layout(self, non_float_locs, non_float_regs, r.ip)
- # spill variables that need to be saved around calls
- regalloc.before_call(save_all_regs=2)
-
for loc, reg in float_locs:
self.mov_loc_loc(loc, reg)
diff --git a/pypy/jit/backend/arm/test/test_calling_convention.py
b/pypy/jit/backend/arm/test/test_calling_convention.py
--- a/pypy/jit/backend/arm/test/test_calling_convention.py
+++ b/pypy/jit/backend/arm/test/test_calling_convention.py
@@ -1,1 +1,35 @@
-from pypy.jit.backend.test.calling_convention_test import TestCallingConv
+from pypy.rpython.annlowlevel import llhelper
+from pypy.jit.metainterp.history import LoopToken
+from pypy.jit.backend.test.calling_convention_test import TestCallingConv,
parse
+from pypy.rpython.lltypesystem import lltype
+
+# ../../test/calling_convention_test.py
+class TestARMCallingConvention(TestCallingConv):
+ def test_call_argument_spilling(self):
+ # bug when we have a value in r0, that is overwritten by an argument
+ # and needed after the call, so that the register gets spilled after it
+ # was overwritten with the argument to the call
+ def func(a):
+ return a + 16
+
+ I = lltype.Signed
+ FUNC = self.FuncType([I], I)
+ FPTR = self.Ptr(FUNC)
+ func_ptr = llhelper(FPTR, func)
+ calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
+ funcbox = self.get_funcbox(self.cpu, func_ptr)
+
+ args = ', '.join(['i%d' % i for i in range(11)])
+ ops = """
+ [%s]
+ i99 = call(ConstClass(func_ptr), 22, descr=calldescr)
+ finish(%s, i99)""" % (args, args)
+ loop = parse(ops, namespace=locals())
+ looptoken = LoopToken()
+ self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
+ for x in range(11):
+ self.cpu.set_future_value_int(x, x)
+ self.cpu.execute_token(looptoken)
+ for x in range(11):
+ assert self.cpu.get_latest_value_int(x) == x
+ assert self.cpu.get_latest_value_int(11) == 38
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit