Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better fix for throw argument thing (I think) #473

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions backends/asm/optimize_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -5605,7 +5601,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;
}
Expand Down
1 change: 1 addition & 0 deletions backends/asm/outasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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