From 188b9583bd1b0e0077edcd5fc0a0597917ef5969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ada=20Gottenstr=C3=A4ter?= Date: Fri, 21 Feb 2025 21:57:51 +0100 Subject: [PATCH 1/2] Better fix for throw argument thing (I think) --- backends/asm/optimize_ir.c | 4 ++-- backends/asm/outasm.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backends/asm/optimize_ir.c b/backends/asm/optimize_ir.c index a13b3c97e..b866d4b54 100644 --- a/backends/asm/optimize_ir.c +++ b/backends/asm/optimize_ir.c @@ -982,7 +982,7 @@ static bool FuncUsesArgEx(Operand *func, Operand *arg, bool actually) return !actually; } else if (func && func->val && peek_into_func) { Function *funcObj = (Function *)func->val; - if ((/*func->kind == IMM_COG_LABEL ||*/ func->kind == IMM_HUB_LABEL) && (actually || funcObj->is_leaf || FuncData(funcObj)->effectivelyLeaf) && !funcObj->has_throw) { + if ((/*func->kind == IMM_COG_LABEL ||*/ func->kind == IMM_HUB_LABEL) && (actually || funcObj->is_leaf || FuncData(funcObj)->effectivelyLeaf)) { if (arg->kind != REG_ARG) return true; // subreg or smth if (arg->val < funcObj->numparams) return true; // Arg used; if (!actually && arg->val < FuncData(funcObj)->maxInlineArg) return true; // Arg clobbered @@ -5605,7 +5605,7 @@ ExpandInlines(IRList *irl) ir = ir_next; } // If inlining (or previous dead-code optimization...) removed all external calls, mark as leaf. - if (non_inline_calls==0 && !curfunc->is_leaf && !FuncData(curfunc)->effectivelyLeaf && !curfunc->has_throw) { + if (non_inline_calls==0 && !curfunc->is_leaf && !FuncData(curfunc)->effectivelyLeaf) { FuncData(curfunc)->effectivelyLeaf = true; change = true; } diff --git a/backends/asm/outasm.c b/backends/asm/outasm.c index fbb756660..5e8c70651 100644 --- a/backends/asm/outasm.c +++ b/backends/asm/outasm.c @@ -5266,6 +5266,7 @@ static void CompileStatement(IRList *irl, IRList *cold_irl, AST *ast) EmitMove(irl, GetArgReg(1), op, ast); EmitMove(irl, GetArgReg(2), NewImmediate(ast->d.ival), ast); EmitOp1(irl, OPC_CALL, longjmpfunc); + updateMax(&FuncData(curfunc)->maxInlineArg,3); break; case AST_LABEL: EmitDebugComment(irl, ast); From fb5b8f9694f9c1a3a64504e9f8cca525e51f125f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ada=20Gottenstr=C3=A4ter?= Date: Fri, 21 Feb 2025 22:07:30 +0100 Subject: [PATCH 2/2] Move updateMax to header where it can actually be used --- backends/asm/optimize_ir.c | 4 ---- util/util.h | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backends/asm/optimize_ir.c b/backends/asm/optimize_ir.c index b866d4b54..3a0ec7caf 100644 --- a/backends/asm/optimize_ir.c +++ b/backends/asm/optimize_ir.c @@ -5550,10 +5550,6 @@ AnalyzeInlineEligibility(Function *f) return FuncData(f)->inliningFlags & ~prev_flags; } -static inline void updateMax(int *dst, int src) { - if (*dst < src) *dst = src; -} - static bool ShouldExpandPureFunction(IR *ir) { Function *f = (Function *)ir->aux; diff --git a/util/util.h b/util/util.h index 1715862f8..3b62eaa43 100644 --- a/util/util.h +++ b/util/util.h @@ -83,4 +83,9 @@ size_t to_utf8(char *s, wchar_t wcorig); // convert utf-8 sequence to wide character; n is max size of cptr size_t from_utf8(wchar_t *wcptr, const char *cptr, size_t n); + +static inline void updateMax(int *dst, int src) { + if (*dst < src) *dst = src; +} + #endif