diff options
| author | 2026-02-24 14:18:07 +0100 | |
|---|---|---|
| committer | 2026-02-24 14:20:07 +0100 | |
| commit | 659430f48f8db6335676ed933f53e4c89d28106d (patch) | |
| tree | 7f82e6c006f425a83bcd375ae0c4b3b51fe49cb2 /ir/inliner.c | |
| parent | fa8c39d6dfdecc8285b09de86b70c28ebd06e152 (diff) | |
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.
Diffstat (limited to 'ir/inliner.c')
| -rw-r--r-- | ir/inliner.c | 3 |
1 files changed, 2 insertions, 1 deletions
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; |