From f877e5b8c2e313238792fa72eef19926ebc4f1d9 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Wed, 28 Feb 2024 21:26:25 +0100 Subject: [PATCH] Fix assert in linux sample build --- oscar64/GlobalAnalyzer.cpp | 20 ++++++++++++-------- oscar64/NativeCodeGenerator.cpp | 5 ++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/oscar64/GlobalAnalyzer.cpp b/oscar64/GlobalAnalyzer.cpp index 803acd7..d276998 100644 --- a/oscar64/GlobalAnalyzer.cpp +++ b/oscar64/GlobalAnalyzer.cpp @@ -162,14 +162,15 @@ void GlobalAnalyzer::AutoInline(void) { Declaration* f = mTopoFunctions[i]; - if (!(f->mFlags & DTF_INLINE) && + if (f->mType == DT_CONST_FUNCTION && + !(f->mFlags & DTF_INLINE) && !(f->mFlags & DTF_EXPORT) && !(f->mFlags & DTF_PREVENT_INLINE) && !(f->mBase->mFlags & DTF_VARIADIC) && !(f->mFlags & DTF_FUNC_VARIABLE) && !((f->mFlags & DTF_FUNC_ASSEMBLER) && !(f->mFlags & DTF_REQUEST_INLINE)) && !(f->mFlags & DTF_INTRINSIC) && - !(f->mFlags & DTF_FUNC_RECURSIVE) && f->mLocalSize < 100) + !(f->mFlags & DTF_FUNC_RECURSIVE)) { int nparams = 0; Declaration* dec = f->mBase->mParams; @@ -186,18 +187,21 @@ void GlobalAnalyzer::AutoInline(void) bool doinline = false; if ((f->mCompilerOptions & COPT_OPTIMIZE_INLINE) && (f->mFlags & DTF_REQUEST_INLINE)) doinline = true; - if ((f->mCompilerOptions & COPT_OPTIMIZE_AUTO_INLINE) && ((cost - 20) * (f->mCallers.Size() - 1) <= 20)) + if (f->mLocalSize < 100) { - if (f->mCallers.Size() == 1 && f->mComplexity > 100) + if ((f->mCompilerOptions & COPT_OPTIMIZE_AUTO_INLINE) && ((cost - 20) * (f->mCallers.Size() - 1) <= 20)) { - if (f->mCallers[0]->mCalled.Size() == 1) + if (f->mCallers.Size() == 1 && f->mComplexity > 100) + { + if (f->mCallers[0]->mCalled.Size() == 1) + doinline = true; + } + else doinline = true; } - else + if ((f->mCompilerOptions & COPT_OPTIMIZE_AUTO_INLINE_ALL) && (cost * (f->mCallers.Size() - 1) <= 10000)) doinline = true; } - if ((f->mCompilerOptions & COPT_OPTIMIZE_AUTO_INLINE_ALL) && (cost * (f->mCallers.Size() - 1) <= 10000)) - doinline = true; if (doinline) { diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index e0e1b69..b3fc90e 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -423,7 +423,10 @@ NativeCodeInstruction::NativeCodeInstruction(const InterInstruction* ins, AsmIns NativeCodeInstruction::NativeCodeInstruction(const InterInstruction* ins, AsmInsType type, const NativeCodeInstruction& addr) : mIns(ins), mType(type), mMode(addr.mMode), mAddress(addr.mAddress), mLinkerObject(addr.mLinkerObject), mFlags(addr.mFlags), mParam(addr.mParam), mLive(LIVE_ALL) { - assert(mIns->mLocation.mFileName); + if (mIns) + { + assert(mIns->mLocation.mFileName); + } }