From 2db88904535724e9ce1070aee59f11a21a721291 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Mon, 24 Mar 2025 08:56:03 +0100 Subject: [PATCH] Fix temp spilling in recursive functions --- include/opp/boundint.h | 7 +++++++ oscar64/InterCodeGenerator.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/opp/boundint.h b/include/opp/boundint.h index 4f9f5bd..1353b20 100644 --- a/include/opp/boundint.h +++ b/include/opp/boundint.h @@ -39,6 +39,13 @@ namespace opp { v = k; } + void operator-=(int k) + { + k = v - k; + __assume(k >= tmin && k <= tmax); + v = k; + } + operator int() const { int k = v; diff --git a/oscar64/InterCodeGenerator.cpp b/oscar64/InterCodeGenerator.cpp index 13b96f7..7b6f71e 100644 --- a/oscar64/InterCodeGenerator.cpp +++ b/oscar64/InterCodeGenerator.cpp @@ -5971,7 +5971,7 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod if (dec->mFlags & DTF_FUNC_INTRCALLED) proc->mInterruptCalled = true; - if (dec->mFlags & DTF_DYNSTACK) + if ((dec->mFlags & DTF_DYNSTACK) || (dec->mFlags & DTF_FUNC_RECURSIVE)) proc->mDynamicStack = true; if ((dec->mFlags & DTF_PREVENT_INLINE) || (dec->mBase->mFlags & DTF_VARIADIC))