|
@@ -2270,12 +2270,17 @@ lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name, Type *type
|
|
|
lbValue lb_value_param(lbProcedure *p, Entity *e, Type *abi_type, i32 index, lbParamPasskind *kind_) {
|
|
|
lbParamPasskind kind = lbParamPass_Value;
|
|
|
|
|
|
- if (e != nullptr && abi_type != e->type) {
|
|
|
+ if (e != nullptr && !are_types_identical(abi_type, e->type)) {
|
|
|
if (is_type_pointer(abi_type)) {
|
|
|
GB_ASSERT(e->kind == Entity_Variable);
|
|
|
- kind = lbParamPass_Pointer;
|
|
|
- if (e->flags&EntityFlag_Value) {
|
|
|
- kind = lbParamPass_ConstRef;
|
|
|
+ Type *av = type_deref(abi_type);
|
|
|
+ if (are_types_identical(av, e->type)) {
|
|
|
+ kind = lbParamPass_Pointer;
|
|
|
+ if (e->flags&EntityFlag_Value) {
|
|
|
+ kind = lbParamPass_ConstRef;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ kind = lbParamPass_BitCast;
|
|
|
}
|
|
|
} else if (is_type_integer(abi_type)) {
|
|
|
kind = lbParamPass_Integer;
|
|
@@ -2364,6 +2369,7 @@ lbValue lb_add_param(lbProcedure *p, Entity *e, Ast *expr, Type *abi_type, i32 i
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
GB_PANIC("Unreachable");
|
|
|
return {};
|
|
|
}
|
|
@@ -7035,10 +7041,15 @@ lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> const &args,
|
|
|
array_add(&processed_args, args[i]);
|
|
|
} else if (!are_types_identical(original_type, new_type)) {
|
|
|
if (is_type_pointer(new_type) && !is_type_pointer(original_type)) {
|
|
|
- if (e->flags&EntityFlag_ImplicitReference) {
|
|
|
- array_add(&processed_args, lb_address_from_load_or_generate_local(p, args[i]));
|
|
|
- } else if (!is_type_pointer(arg_type)) {
|
|
|
- array_add(&processed_args, lb_copy_value_to_ptr(p, args[i], original_type, 16));
|
|
|
+ Type *av = type_deref(new_type);
|
|
|
+ if (are_types_identical(av, arg_type)) {
|
|
|
+ if (e->flags&EntityFlag_ImplicitReference) {
|
|
|
+ array_add(&processed_args, lb_address_from_load_or_generate_local(p, args[i]));
|
|
|
+ } else if (!is_type_pointer(arg_type)) {
|
|
|
+ array_add(&processed_args, lb_copy_value_to_ptr(p, args[i], original_type, 16));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ array_add(&processed_args, lb_emit_transmute(p, args[i], new_type));
|
|
|
}
|
|
|
} else if (new_type == t_llvm_bool) {
|
|
|
array_add(&processed_args, lb_emit_conv(p, args[i], new_type));
|