From 204924927a6c7d1507323b464de10e0a09dd2163 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 7 Jun 2023 00:35:11 +0100 Subject: [PATCH] Ignore non-variable parameters --- src/llvm_abi.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 071f34627..877560d91 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -1335,14 +1335,17 @@ namespace lbAbiWasm { auto args = array_make(lb_function_type_args_allocator(), arg_count); GB_ASSERT(original_type->kind == Type_Proc); - GB_ASSERT(cast(isize)arg_count == original_type->Proc.param_count); + GB_ASSERT(cast(isize)arg_count <= original_type->Proc.param_count); auto const ¶ms = original_type->Proc.params->Tuple.variables; - for (unsigned i = 0; i < arg_count; i++) { + for (unsigned i = 0, j = 0; i < arg_count; i++, j++) { + while (params[j]->kind != Entity_Variable) { + j++; + } + Type *ptype = params[j]->type; LLVMTypeRef t = arg_types[i]; LLVMTypeKind kind = LLVMGetTypeKind(t); if (kind == LLVMStructTypeKind || kind == LLVMArrayTypeKind) { - Type *ptype = params[i]->type; if (is_type_slice(ptype) || is_type_string(ptype)) { args[i] = pseudo_slice(c, t, calling_convention); } else {