diff options
| author | gingerBill <bill@gingerbill.org> | 2019-03-14 23:41:48 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-03-14 23:41:48 +0000 |
| commit | 712744ef367045f21c017137ad1856dca8814e7b (patch) | |
| tree | ab650c176100a99f3c7b3b8533f140d3c5b41521 /src/ir.cpp | |
| parent | dbcd49acfc853d136935605222e5c824b621dbd9 (diff) | |
Fix `ir_copy_value_to_ptr` usage in `ir_emit_call` #350
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 0d5e3fc36..0d9a165cf 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -2875,12 +2875,12 @@ irValue *ir_copy_value_to_ptr(irProcedure *proc, irValue *val, Type *new_type, i if (alignment < type_alignment) { alignment = type_alignment; } + GB_ASSERT_MSG(are_types_identical(new_type, ir_type(val)), "%s %s", type_to_string(new_type), type_to_string(ir_type(val))); + irValue *ptr = ir_add_local_generated(proc, new_type, false); ptr->Instr.Local.alignment = alignment; ir_emit_store(proc, ptr, val); - if (val) val->uses += 1; - return ptr; } @@ -2972,12 +2972,18 @@ irValue *ir_emit_call(irProcedure *p, irValue *value, Array<irValue *> args, Pro Type *original_type = e->type; Type *new_type = pt->Proc.abi_compat_params[i]; - if (original_type != new_type) { + if (!are_types_identical(original_type, new_type)) { + Type *arg_type = ir_type(args[i]); + if (is_type_pointer(new_type)) { if (e->flags&EntityFlag_Value) { args[i] = ir_address_from_load_or_generate_local(p, args[i]); } else { - args[i] = ir_copy_value_to_ptr(p, args[i], original_type, 16); + if (is_type_pointer(arg_type)) { + args[i] = ir_copy_value_to_ptr(p, ir_emit_load(p, args[i]), original_type, 16); + } else { + args[i] = ir_copy_value_to_ptr(p, args[i], original_type, 16); + } } } else if (is_type_integer(new_type)) { args[i] = ir_emit_transmute(p, args[i], new_type); |