aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir/regalloc.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-02-28 20:38:55 +0100
committerlemon <lsof@mailbox.org>2026-02-28 20:38:55 +0100
commitf06da11d8524a9eb7fe984171d4462cef8eac2e6 (patch)
tree0050bede4ec0e9939e4a5f98be089a539d5810d2 /ir/regalloc.c
parent3d1efdcc77de5ce8f3279bd22b0a510a699229ea (diff)
ir: make address ref hash table resizable
Would hit the limit on very large functions (thanks csmith).
Diffstat (limited to 'ir/regalloc.c')
-rw-r--r--ir/regalloc.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/ir/regalloc.c b/ir/regalloc.c
index aa18e10..cdbd7af 100644
--- a/ir/regalloc.c
+++ b/ir/regalloc.c
@@ -62,8 +62,8 @@ liveuse(struct bitset *defined, struct instr *ins, union ref *r, struct block *b
{
int var;
if (r->t == RADDR) {
- liveuse(defined, ins, &addrht[r->i].base, blk);
- liveuse(defined, ins, &addrht[r->i].index, blk);
+ liveuse(defined, ins, &addrtab.p[r->i].base, blk);
+ liveuse(defined, ins, &addrtab.p[r->i].index, blk);
return;
} else if (r->t != RTMP) return;
var = r->i;
@@ -736,8 +736,8 @@ buildintervals(struct rega *ra)
usereg(ra, r.i, blk, pos);
} else if (r.t == RADDR) {
reghint = -1;
- queue[nqueue++] = addrht[r.i].base;
- queue[nqueue++] = addrht[r.i].index;
+ queue[nqueue++] = addrtab.p[r.i].base;
+ queue[nqueue++] = addrtab.p[r.i].index;
}
}
}
@@ -970,10 +970,17 @@ linearscan(struct rega *ra)
avail &= ~excl;
if (!avail) {
+ /* XXX heuristically pick a better interval to spill */
/* spill current */
current->alloc = allocstk(ra);
DBG("%%%d got stk%d\n", this, current->alloc.a);
/* move current to active */
+ /* XXX spilled intervals are being put in active so their stack
+ * slots can be freed when expiring old intervals but it turns the
+ * linear scan algorithmic complexity closer to O(n^2), so is a
+ * performance downgrade. in the referenced paper, they are moved
+ * to handled. this should be fixed by doing stack slot allocation
+ * separately */
current->next = *active;
*active = current;
continue;
@@ -1071,7 +1078,7 @@ devirt(struct rega *ra, struct block *blk)
for (int i = 0; i < 2; ++i) {
union ref *r = &i[&ins->l];
if (r->t == RADDR) {
- struct addr *a = &addrht[r->i];
+ struct addr *a = &addrtab.p[r->i];
++naddr;
newaddr = *a;
argref[nargref++] = &newaddr.base;