From 659430f48f8db6335676ed933f53e4c89d28106d Mon Sep 17 00:00:00 2001 From: lemon Date: Tue, 24 Feb 2026 14:18:07 +0100 Subject: inline: fix undefined value returns Previously if an inlined function has a return statement with no value (control flow reaching the closing brace of the function), would use an invalid null reference in the inlined body. Turn it into undef. --- ir/inliner.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ir') diff --git a/ir/inliner.c b/ir/inliner.c index 2ce817b..80e6081 100644 --- a/ir/inliner.c +++ b/ir/inliner.c @@ -104,6 +104,7 @@ maybeinlinee(struct function *fn) static union ref mapref(short *instrmap, struct savedfunc *sv, union ref r) { + assert(r.bits); if (r.t == RTMP) return r.i = instrmap[r.i], r; if (r.t == RXCON) return newxcon(&sv->contab[r.i]); assert(r.t != RADDR); @@ -219,7 +220,7 @@ inlcall(struct function *fn, struct block *blk, int curi, struct savedfunc *sv) if (b->jmp.t == Jret) { new->jmp.t = Jb; new->s1 = exit; - retvals[iret++] = mapref(instrmap, sv, b->jmp.arg[0]); + retvals[iret++] = b->jmp.arg[0].bits ? mapref(instrmap, sv, b->jmp.arg[0]) : UNDREF; addpred(exit, new); } else { new->jmp.t = b->jmp.t; -- cgit v1.2.3