From 42ce457bba06bd3607fc04700a919b6c395f22c3 Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 14 Mar 2026 17:27:37 +0100 Subject: c: static eval refactoring Explicit node for static symbol (addresses). Should not break with edge cases like the previous ad-hoc approach. And some other bugfixes --- ir/ir.c | 8 +++++--- ir/ir.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'ir') diff --git a/ir/ir.c b/ir/ir.c index bb75d4b..626311e 100644 --- a/ir/ir.c +++ b/ir/ir.c @@ -159,10 +159,12 @@ mksymref(internstr s, enum symflags symflags) } union ref -mkdatref(internstr name, union type ctype, uint siz, uint align, const void *bytes, uint n, bool deref) +mkdatref(internstr name, union type ctype, uint siz, uint align, + const void *bytes, uint n, bool deref, bool funclocal) { - struct irdat dat = { .ctype = ctype, .align = align, .siz = siz, .name = name }; - dat.section = objout.code && align >= 4 && align <= targ_primsizes[TYPTR] && siz <= 16 ? Stext : Srodata; + struct irdat dat = { .ctype = ctype, .align = align, .siz = siz, .name = name, .section = Srodata }; + if (funclocal && objout.code && align >= 4 && align <= targ_primsizes[TYPTR] && siz <= 16) + dat.section = Stext; assert(n <= siz && siz && align); if (!name) { diff --git a/ir/ir.h b/ir/ir.h index 39fa116..a4da8ad 100644 --- a/ir/ir.h +++ b/ir/ir.h @@ -265,7 +265,8 @@ union ref mkfltcon(enum irclass, double); #define intconval(r) ((r).t == RICON ? (r).i : contab.p[(r).i].i) #define fltconval(r) ((r).t == RICON ? (r).i : contab.p[(r).i].f) union ref mksymref(internstr, enum symflags); -union ref mkdatref(internstr name, union type ctype, uint siz, uint align, const void *, uint n, bool deref); +union ref mkdatref(internstr sym, union type ctype, uint siz, uint align, + const void *, uint n, bool deref, bool funclocal); internstr xcon2sym(int ref); struct instr mkalloca(uint siz, uint align); union ref mkcallarg(union irtype ret, uint narg, int vararg); -- cgit v1.2.3