mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 04:38:16 +00:00
Fix #2054 Differing behaviours with defer statements for single vs multiple return values caused by naïve ABI optimization
This commit is contained in:
@@ -577,20 +577,13 @@ void lb_begin_procedure_body(lbProcedure *p) {
|
|||||||
if (e->token.string != "") {
|
if (e->token.string != "") {
|
||||||
GB_ASSERT(!is_blank_ident(e->token));
|
GB_ASSERT(!is_blank_ident(e->token));
|
||||||
|
|
||||||
lbAddr res = {};
|
// NOTE(bill): Don't even bother trying to optimize this with the return ptr value
|
||||||
if (return_ptr_value.value != nullptr) {
|
// This will violate the defer rules if you do:
|
||||||
lbValue ptr = return_ptr_value;
|
// foo :: proc() -> (x, y: T) {
|
||||||
if (results->variables.count != 1) {
|
// defer x = ... // defer is executed after the `defer`
|
||||||
ptr = lb_emit_struct_ep(p, ptr, cast(i32)i);
|
// return // the values returned should be zeroed
|
||||||
}
|
// }
|
||||||
|
lbAddr res = lb_add_local(p, e->type, e);
|
||||||
res = lb_addr(ptr);
|
|
||||||
lb_add_entity(p->module, e, ptr);
|
|
||||||
lb_add_debug_local_variable(p, ptr.value, e->type, e->token);
|
|
||||||
} else {
|
|
||||||
res = lb_add_local(p, e->type, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e->Variable.param_value.kind != ParameterValue_Invalid) {
|
if (e->Variable.param_value.kind != ParameterValue_Invalid) {
|
||||||
lbValue c = lb_handle_param_value(p, e->type, e->Variable.param_value, e->token.pos);
|
lbValue c = lb_handle_param_value(p, e->type, e->Variable.param_value, e->token.pos);
|
||||||
lb_addr_store(p, res, c);
|
lb_addr_store(p, res, c);
|
||||||
|
|||||||
Reference in New Issue
Block a user