aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-06-22 16:57:21 +0100
committergingerBill <bill@gingerbill.org>2020-06-22 16:57:21 +0100
commit2b27300387030c635acee783a2e573960ae3f748 (patch)
treed718a117e76c77482f6e75d415fc5b3bfd3ca198 /src/ir.cpp
parent0db1ebb4e5bf36a7c44b9119bcf3055a58fd6103 (diff)
Fix LLVM code gen bug
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index d6b6f49cd..923837293 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -976,9 +976,14 @@ irValue *ir_value_param(irProcedure *parent, Entity *e, Type *abi_type, i32 inde
if (e != nullptr && abi_type != e->type) {
if (is_type_pointer(abi_type)) {
GB_ASSERT(e->kind == Entity_Variable);
- v->Param.kind = irParamPass_Pointer;
- if (e->flags&EntityFlag_Value) {
- v->Param.kind = irParamPass_ConstRef;
+ Type *av = type_deref(abi_type);
+ if (are_types_identical(abi_type, e->type)) {
+ v->Param.kind = irParamPass_Pointer;
+ if (e->flags&EntityFlag_Value) {
+ v->Param.kind = irParamPass_ConstRef;
+ }
+ } else {
+ v->Param.kind = irParamPass_BitCast;
}
} else if (is_type_integer(abi_type)) {
v->Param.kind = irParamPass_Integer;
@@ -3241,10 +3246,15 @@ irValue *ir_emit_call(irProcedure *p, irValue *value, Array<irValue *> const &ar
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, ir_address_from_load_or_generate_local(p, args[i]));
- } else if (!is_type_pointer(arg_type)) {
- array_add(&processed_args, ir_copy_value_to_ptr(p, args[i], original_type, 16));
+ Type *av = type_deref(new_type);
+ if (are_types_identical(av, original_type)) {
+ if (e->flags&EntityFlag_ImplicitReference) {
+ array_add(&processed_args, ir_address_from_load_or_generate_local(p, args[i]));
+ } else if (!is_type_pointer(arg_type)) {
+ array_add(&processed_args, ir_copy_value_to_ptr(p, args[i], original_type, 16));
+ }
+ } else {
+ array_add(&processed_args, ir_emit_transmute(p, args[i], new_type));
}
} else if (is_type_integer(new_type) || is_type_float(new_type)) {
array_add(&processed_args, ir_emit_transmute(p, args[i], new_type));