Fix stack setting after error return. Some fixes to examples.

This commit is contained in:
Christoffer Lerno
2022-07-02 10:08:45 +02:00
committed by Christoffer Lerno
parent b1d83e2ccd
commit bb28f6e61c
12 changed files with 140 additions and 110 deletions

View File

@@ -4909,6 +4909,9 @@ void llvm_emit_call_expr(GenContext *c, BEValue *result_value, Expr *expr)
{
BEValue no_err;
// Emit the current stack into the thread local or things will get messed up.
if (c->debug.last_ptr) llvm_store(c, c->debug.last_ptr, c->debug.stack_slot, type_alloca_alignment(type_voidptr));
// 17a. If we used the error var as the indirect recipient, then that will hold the error.
// otherwise it's whatever value in be_value.
BEValue error_holder = *result_value;
@@ -4941,9 +4944,6 @@ void llvm_emit_call_expr(GenContext *c, BEValue *result_value, Expr *expr)
// 17f. Emit the "after" block.
llvm_emit_block(c, after_block);
// Emit the current stack into the thread local or things will get messed up.
if (c->debug.last_ptr) llvm_store(c, c->debug.last_ptr, c->debug.stack_slot, type_alloca_alignment(type_voidptr));
// 17g. If void, be_value contents should be skipped.
if (!prototype->ret_by_ref)
{