harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 7e165462b67706c380de17d194ee09a928f4f635
parent 0edcd481417b331394a92b4214f4bb20274c934b
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue, 29 Dec 2020 13:39:30 -0500

gen: fix if branches which terminate

qbe doesn't like to see any more instructions after jmp in a block.

Diffstat:
Msrc/gen.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gen.c b/src/gen.c @@ -610,12 +610,16 @@ gen_expr_if(struct gen_context *ctx, push(&ctx->current->body, &tlabel); gen_expression(ctx, expr->_if.true_branch, out); - pushi(ctx->current, NULL, Q_JMP, &end, NULL); + if (!expr->_if.true_branch->terminates) { + pushi(ctx->current, NULL, Q_JMP, &end, NULL); + } push(&ctx->current->body, &flabel); if (expr->_if.false_branch) { gen_expression(ctx, expr->_if.false_branch, out); - pushi(ctx->current, NULL, Q_JMP, &end, NULL); + if (!expr->_if.false_branch->terminates) { + pushi(ctx->current, NULL, Q_JMP, &end, NULL); + } } push(&ctx->current->body, &endl);