Author: Manuel Jacob <m...@manueljacob.de> Branch: llvm-translation-backend Changeset: r81510:56cf0a68905a Date: 2015-12-31 16:55 +0100 http://bitbucket.org/pypy/pypy/changeset/56cf0a68905a/
Log: Implement inhibit_tail_call marker. This raises the required LLVM version to 3.8 (as of now unreleased). diff --git a/rpython/translator/llvm/genllvm.py b/rpython/translator/llvm/genllvm.py --- a/rpython/translator/llvm/genllvm.py +++ b/rpython/translator/llvm/genllvm.py @@ -1216,10 +1216,17 @@ tmp.append('{arg.TV}'.format(arg=arg)) args = ', '.join(tmp) + tailmarker = '' + try: + if fn.value._obj.graph.inhibit_tail_call: + tailmarker = 'notail ' + except AttributeError: + pass + if result.type is LLVMVoid: - fmt = 'call void {fn.V}({args})' + fmt = '{tailmarker}call void {fn.V}({args})' else: - fmt = '{result.V} = call {result.T} {fn.V}({args})' + fmt = '{result.V} = {tailmarker}call {result.T} {fn.V}({args})' self.w(fmt.format(**locals())) op_indirect_call = op_direct_call diff --git a/rpython/translator/llvm/test/test_genllvm.py b/rpython/translator/llvm/test/test_genllvm.py --- a/rpython/translator/llvm/test/test_genllvm.py +++ b/rpython/translator/llvm/test/test_genllvm.py @@ -655,6 +655,16 @@ assert not fc(r_longfloat(0.0)) assert fc(r_longfloat(1.0)) + def test_recursive_notail(self): + def f(n): + if n <= 0: + return 42 + return f(n+1) + def entry_point(): + return f(1) + fc = self.getcompiled(entry_point, []) + fc(expected_exception_name='StackOverflow') + class TestLowLevelTypeLLVM(_LLVMMixin, test_lltyped.TestLowLevelType): def getcompiled(self, func, argtypes): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit