From 38bb0333287577fa0e429c42fd9c0fd566a3c53f Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Mon, 30 Dec 2024 18:06:26 +0100 Subject: [PATCH] Fix global variable changes bypassing assembly blocks --- include/c64/sprites.c | 6 ++++++ include/c64/sprites.h | 2 ++ oscar64/InterCode.cpp | 9 +++++---- oscar64/NativeCodeGenerator.cpp | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/c64/sprites.c b/include/c64/sprites.c index 59da402..e2e7011 100644 --- a/include/c64/sprites.c +++ b/include/c64/sprites.c @@ -171,6 +171,12 @@ void vspr_init(char * screen) } } +void vspr_shutdown(void) +{ + for(int i=0; imCompilerOptions & COPT_OPTIMIZE_BASIC)) { // Check forwarding globals @@ -18438,7 +18439,7 @@ void InterCodeBasicBlock::SingleBlockLoopOptimisation(const NumberSet& aliasedPa InterInstruction* ins = mInstructions[i]; // A global load - if (ins->mCode == IC_LOAD && ins->mSrc[0].mTemp < 0 && (ins->mSrc[0].mMemory == IM_GLOBAL || ins->mSrc[0].mMemory == IM_FPARAM)) + if (ins->mCode == IC_LOAD && !ins->mVolatile && ins->mSrc[0].mTemp < 0 && (ins->mSrc[0].mMemory == IM_GLOBAL || ins->mSrc[0].mMemory == IM_FPARAM)) { // Find the last store that overlaps the load int j = mInstructions.Size() - 1; @@ -18450,7 +18451,7 @@ void InterCodeBasicBlock::SingleBlockLoopOptimisation(const NumberSet& aliasedPa InterInstruction* sins = mInstructions[j]; // Does a full store - if (SameMem(ins->mSrc[0], sins->mSrc[1]) && !AliasingMem(this, ins, 0, mInstructions.Size())) + if (SameMem(ins->mSrc[0], sins->mSrc[1]) && !AliasingMem(this, ins, 0, mInstructions.Size()) && !DestroyingMem(this, ins, 0, j)) { if (sins->mSrc[0].mTemp >= 0) { @@ -23012,7 +23013,7 @@ void InterCodeProcedure::Close(void) { GrowingTypeArray tstack(IT_NONE); - CheckFunc = !strcmp(mIdent->mString, "main"); + CheckFunc = !strcmp(mIdent->mString, "drawAllRows"); CheckCase = false; mEntryBlock = mBlocks[0]; diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index e0fc0ad..7a73a7f 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -669,7 +669,7 @@ bool NativeCodeInstruction::IsUsedResultInstructions(NumberSet& requiredTemps) if (mFlags & NCIF_VOLATILE) { - if (mMode != ASMIM_IMPLIED && mMode != ASMIM_ZERO_PAGE) + if (mMode != ASMIM_IMPLIED && mMode != ASMIM_ZERO_PAGE && !(mMode == ASMIM_ABSOLUTE && mLinkerObject && (mLinkerObject->mFlags & LOBJF_ZEROPAGE))) used = true; }