From 85fed148fd68c5e621353dfcf07351f66b290ce3 Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 15 Jun 2023 12:46:28 +0200 Subject: less memset --- ir.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'ir.c') diff --git a/ir.c b/ir.c index c2abe12..7ccb926 100644 --- a/ir.c +++ b/ir.c @@ -11,6 +11,9 @@ struct calltab calltab; struct phitab phitab; struct dattab dattab; struct addr addrht[1 << 12]; +static int naddrht; +struct xcon conht[1 << 12]; +static int nconht; void irinit(struct function *fn) @@ -24,7 +27,10 @@ irinit(struct function *fn) vinit(&calltab, callsbuf, arraylength(callsbuf)); vinit(&phitab, phisbuf, arraylength(phisbuf)); vinit(&dattab, datsbuf, arraylength(datsbuf)); - memset(addrht, 0, sizeof addrht); + if (naddrht >= arraylength(addrht)/2) + memset(addrht, naddrht = 0, sizeof addrht); + if (nconht >= arraylength(conht)/2) + memset(addrht, nconht = 0, sizeof addrht); if (!type2cls[TYINT]) { for (int i = TYBOOL; i <= TYUVLONG; ++i) { int siz = targ_primsizes[i]; @@ -52,6 +58,7 @@ addaddr(const struct addr *addr) i &= arraylength(addrht) - 1; if (!addrht[i].base.t && !addrht[i].index.t) { addrht[i] = *addr; + ++naddrht; return i; } else if (!memcmp(&addrht[i], addr, sizeof *addr)) { return i; @@ -60,8 +67,6 @@ addaddr(const struct addr *addr) } } -struct xcon conht[1 << 12]; - static int addcon(const struct xcon *con) { @@ -72,6 +77,7 @@ addcon(const struct xcon *con) i &= arraylength(conht) - 1; if (!conht[i].issym && !conht[i].cls) { conht[i] = *con; + ++nconht; return i; } else if (!memcmp(&conht[i], con, sizeof *con)) { return i; -- cgit v1.2.3