From ec15336174d0c4b1dd511f12ced4559d8c17ae55 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Tue, 1 Aug 2023 22:17:55 +0200 Subject: [PATCH] Fix stack allocation with false recursion with function pointers --- oscar64/GlobalAnalyzer.cpp | 4 +++- oscar64/NativeCodeGenerator.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/oscar64/GlobalAnalyzer.cpp b/oscar64/GlobalAnalyzer.cpp index 4df17c1..d9113fe 100644 --- a/oscar64/GlobalAnalyzer.cpp +++ b/oscar64/GlobalAnalyzer.cpp @@ -297,14 +297,16 @@ void GlobalAnalyzer::CheckFastcall(Declaration* procDec, bool head) for (int i = 0; i < mVariableFunctions.Size(); i++) { Declaration* vf = mVariableFunctions[i]; - CheckFastcall(vf, false); if (vf->mBase->IsSame(cf)) { + CheckFastcall(vf, false); + int n = vf->mBase->mFastCallBase + vf->mBase->mFastCallSize; if (n > nbase) nbase = n; } + } // procDec->mFlags |= DTF_DYNSTACK; } diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 13641af..9ad5473 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -3503,7 +3503,7 @@ bool NativeCodeInstruction::ValueForwarding(NativeRegisterDataSet& data, AsmInsT } changed = true; } - else if (data.mRegs[mAddress].mMode == NRDM_ZERO_PAGE) + else if (data.mRegs[mAddress].mMode == NRDM_ZERO_PAGE && (mAddress < BC_REG_FPARAMS || mAddress >= BC_REG_FPARAMS_END)) { data.mRegs[CPU_REG_A] = data.mRegs[mAddress]; mAddress = data.mRegs[CPU_REG_A].mValue; @@ -41410,7 +41410,7 @@ void NativeCodeProcedure::Optimize(void) t++; - } while (changed); + } while (changed && t < 20); #endif BuildDataFlowSets();