mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Improve handling of passing constants to implicit immutable const ref parameters
This commit is contained in:
@@ -1045,10 +1045,26 @@ gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> c
|
|||||||
} else if (is_odin_cc) {
|
} else if (is_odin_cc) {
|
||||||
// NOTE(bill): Odin parameters are immutable so the original value can be passed if possible
|
// NOTE(bill): Odin parameters are immutable so the original value can be passed if possible
|
||||||
// i.e. `T const &` in C++
|
// i.e. `T const &` in C++
|
||||||
|
if (LLVMIsConstant(x.value)) {
|
||||||
|
// NOTE(bill): if the value is already constant, then just it as a global variable
|
||||||
|
// and pass it by pointer
|
||||||
|
lbAddr addr = lb_add_global_generated(p->module, original_type, x);
|
||||||
|
lb_make_global_private_const(addr);
|
||||||
|
ptr = addr.addr;
|
||||||
|
} else {
|
||||||
ptr = lb_address_from_load_or_generate_local(p, x);
|
ptr = lb_address_from_load_or_generate_local(p, x);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (LLVMIsConstant(x.value)) {
|
||||||
|
// NOTE(bill): if the value is already constant, then just it as a global variable
|
||||||
|
// and pass it by pointer
|
||||||
|
lbAddr addr = lb_add_global_generated(p->module, original_type, x);
|
||||||
|
lb_make_global_private_const(addr);
|
||||||
|
ptr = addr.addr;
|
||||||
} else {
|
} else {
|
||||||
ptr = lb_copy_value_to_ptr(p, x, original_type, 16);
|
ptr = lb_copy_value_to_ptr(p, x, original_type, 16);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
array_add(&processed_args, ptr);
|
array_add(&processed_args, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user