diff --git a/src/ir.cpp b/src/ir.cpp index 2de2b2669..e00dc42ee 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -1713,6 +1713,7 @@ irValue *ir_add_local(irProcedure *proc, Entity *e, Ast *expr, bool zero_initial if (zero_initialized) { ir_emit_zero_init(proc, instr, expr); } + set_procedure_abi_types(heap_allocator(), e->type); // if (proc->module->generate_debug_info && expr != nullptr && proc->entity != nullptr) { // if (proc->module->generate_debug_info && proc->entity != nullptr) { diff --git a/src/ir_print.cpp b/src/ir_print.cpp index f3840fce8..2baf1c2a0 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -354,7 +354,22 @@ void ir_print_proc_type_without_pointer(irFileBuffer *f, irModule *m, Type *t) { if (i+1 == param_count && t->Proc.c_vararg) { ir_write_string(f, str_lit("...")); } else { - ir_print_type(f, m, t->Proc.abi_compat_params[i]); + Type *et = t->Proc.abi_compat_params[i]; + if (is_type_tuple(et)) { + for_array(j, et->Tuple.variables) { + if (j > 0) ir_write_str_lit(f, ", "); + + ir_print_type(f, m, et->Tuple.variables[j]->type); + if (e->flags&EntityFlag_NoAlias) { + ir_write_str_lit(f, " noalias"); + } + ir_write_byte(f, ' '); + param_index++; + } + continue; + } else { + ir_print_type(f, m, et); + } } param_index++; @@ -2111,30 +2126,50 @@ void ir_print_instr(irFileBuffer *f, irModule *m, irValue *value) { TypeTuple *params = &proc_type->Proc.params->Tuple; if (proc_type->Proc.c_vararg) { isize i = 0; + isize arg_index = 0; for (; i < params->variables.count-1; i++) { Entity *e = params->variables[i]; GB_ASSERT(e != nullptr); - if (e->kind != Entity_Variable) continue; + if (e->kind != Entity_Variable) { + arg_index++; + continue; + } if (param_index > 0) ir_write_str_lit(f, ", "); Type *t = proc_type->Proc.abi_compat_params[i]; - ir_print_type(f, m, t); - if (e->flags&EntityFlag_NoAlias) { - ir_write_str_lit(f, " noalias"); + if (is_type_tuple(t)) { + for_array(j, t->Tuple.variables) { + if (j > 0) ir_write_str_lit(f, ", "); + + irValue *arg = call->args[arg_index++]; + + ir_print_type(f, m, t->Tuple.variables[j]->type); + if (e->flags&EntityFlag_NoAlias) { + ir_write_str_lit(f, " noalias"); + } + ir_write_byte(f, ' '); + ir_print_value(f, m, arg, t); + param_index++; + } + } else { + ir_print_type(f, m, t); + if (e->flags&EntityFlag_NoAlias) { + ir_write_str_lit(f, " noalias"); + } + if (e->flags&EntityFlag_ImplicitReference) { + ir_write_str_lit(f, " nonnull dereferenceable"); + } + ir_write_byte(f, ' '); + irValue *arg = call->args[arg_index++]; + ir_print_value(f, m, arg, t); + param_index++; } - if (e->flags&EntityFlag_ImplicitReference) { - ir_write_str_lit(f, " nonnull dereferenceable"); - } - ir_write_byte(f, ' '); - irValue *arg = call->args[i]; - ir_print_value(f, m, arg, t); - param_index++; } - for (; i < call->args.count; i++) { + while (arg_index < call->args.count) { if (param_index > 0) ir_write_str_lit(f, ", "); - irValue *arg = call->args[i]; + irValue *arg = call->args[arg_index]; Type *t = ir_type(arg); ir_print_type(f, m, t); ir_write_byte(f, ' '); diff --git a/src/types.cpp b/src/types.cpp index b4d42d67a..cf8e603ba 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -3394,7 +3394,7 @@ gbString write_type_to_string(gbString str, Type *type) { case Type_SimdVector: if (type->SimdVector.is_x86_mmx) { - return "intrinsics.x86_mmx"; + return gb_string_appendc(str, "intrinsics.x86_mmx"); } else { str = gb_string_append_fmt(str, "#simd[%d]", cast(int)type->SimdVector.count); str = write_type_to_string(str, type->SimdVector.elem);