aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-11-24 12:50:41 +0100
committerlemon <lsof@mailbox.org>2025-11-24 12:51:38 +0100
commit9dab543399fd67085225e165d1e48deab7731180 (patch)
treee8b374be81f541c00743116e94ab33f904150cd8
parent8ca8776f3ad526745d85adac942f0e2b6951c5c8 (diff)
c: create dummy unreachable block after trap
Reverts 9abe27f6712. This simplies expr codegen, otherwise would manually have to check `fn->curblk != NULL` repeatedly. Later passes will easily delete those unreachable blocks
-rw-r--r--c/builtin.c1
-rw-r--r--c/c.c6
2 files changed, 2 insertions, 5 deletions
diff --git a/c/builtin.c b/c/builtin.c
index 29a3191..9a8a12b 100644
--- a/c/builtin.c
+++ b/c/builtin.c
@@ -83,6 +83,7 @@ static union ref
trap_comp(struct function *fn, struct expr *ex, bool discard)
{
puttrap(fn);
+ useblk(fn, newblk(fn)); /* unreachable block, but simplifies expr codegen */
return NOREF;
}
diff --git a/c/c.c b/c/c.c
index 6d1996a..14f988e 100644
--- a/c/c.c
+++ b/c/c.c
@@ -3128,16 +3128,12 @@ compilecall(struct function *fn, const struct expr *ex)
assert(ins.cls || ex->ty.t == TYVOID);
}
ins.l = exprvalue(fn, &sub[0]);
- for (int i = 0; i < ex->narg && fn->curblk; ++i) {
+ for (int i = 0; i < ex->narg; ++i) {
struct expr *arg = &sub[i+1];
union type ty = i < td->nmemb ? td->param[i] : argpromote(arg->ty);
union ref r = cvt(fn, ty, typedecay(arg->ty), exprvalue(fn, arg));
vpush(&insns, mkarginstr(mkirtype(ty), r));
}
- if (!fn->curblk) {
- vfree(&insns);
- return NOREF;
- }
for (int i = 0; i < insns.n; ++i)
addinstr(fn, insns.p[i]);
vfree(&insns);