From d88b052d2d9aa8fa012be314bd29d7ae311fc941 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 25 Nov 2022 23:57:55 +0000 Subject: Naïve optimization of named _split_ multiple return valued when `defer` is never used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a naïve optimization but it helps a lot in the general case where callee temporary stack variables are not allocated to represent the named return values by using that specific memory. In the future, try to check if a specific named return value is ever used a `defer` within a procedure or not, or is ever passed to a nested procedure call (e.g. possibly escapes). --- src/check_decl.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index bb56749af..0e41dbbb5 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -1544,8 +1544,12 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty // NOTE(bill): Don't err here } + GB_ASSERT(decl->defer_use_checked == false); + check_stmt_list(ctx, bs->stmts, Stmt_CheckScopeDecls); + decl->defer_use_checked = true; + for_array(i, bs->stmts) { Ast *stmt = bs->stmts[i]; if (stmt->kind == Ast_ValueDecl) { @@ -1580,6 +1584,7 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty } } } + } check_close_scope(ctx); -- cgit v1.2.3