diff options
| author | 2023-06-15 12:46:28 +0200 | |
|---|---|---|
| committer | 2023-06-15 12:46:28 +0200 | |
| commit | 85fed148fd68c5e621353dfcf07351f66b290ce3 (patch) | |
| tree | 2f43a3554c0a90fab703ddae4e377b4e3cb2beed /ir.c | |
| parent | da8246e054a8bed6d918cb74dfe476976d1c99af (diff) | |
less memset
Diffstat (limited to 'ir.c')
| -rw-r--r-- | ir.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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; |