diff options
| author | 2025-11-02 19:26:20 +0100 | |
|---|---|---|
| committer | 2025-11-02 19:26:20 +0100 | |
| commit | 088c3c1ce51de82ef317592bae766ad20f82208d (patch) | |
| tree | e94f30be7158f6b5cd97224883db584a7340d56b | |
| parent | fab6314ffcb547cbbf45ce16e390eba00e5bfa31 (diff) | |
regalloc: misc
| -rw-r--r-- | ir/regalloc.c | 6 | ||||
| -rw-r--r-- | test/test4.c | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/ir/regalloc.c b/ir/regalloc.c index 03d9413..fae1a61 100644 --- a/ir/regalloc.c +++ b/ir/regalloc.c @@ -982,18 +982,18 @@ devirt(struct rega *ra, struct block *blk) int tr; if (r->t == RTMP) { alloc = (it = &ra->intervals.temps[r->i]) && it->nrange ? &it->alloc : NULL; - if (alloc->t == ASTACK && ins->op == Omove) { + if (alloc && alloc->t == ASTACK && ins->op == Omove) { /* move [reg], [stk] -> [reg] = load [stk] */ assert(r == &ins->r && ins->l.t == RREG); ins->reg = ins->l.i+1; ins->op = cls2load[ins->cls]; ins->r = NOREF; addstkslotref(temp, alloc->a*8); - } else if (alloc->t == ASTACK && ins->op == Ocopy && r == &ins->l && ins->reg) { + } else if (alloc && alloc->t == ASTACK && ins->op == Ocopy && r == &ins->l && ins->reg) { /* [reg] = copy [stk] -> [reg] = load [stk] */ ins->op = cls2load[ins->cls]; addstkslotref(temp, alloc->a*8); - } else if (alloc->t == ASTACK) { + } else if (alloc && alloc->t == ASTACK) { /* ref was spilled, gen load to scratch register and use it */ struct instr ld = {.cls = insrescls(instrtab[r->i])}; int reg = kisint(ld.cls) ? mctarg->gprscratch : mctarg->fprscratch; diff --git a/test/test4.c b/test/test4.c index c1c9429..694d798 100644 --- a/test/test4.c +++ b/test/test4.c @@ -21,6 +21,17 @@ int bitf(struct foo *q) { return q->x + q->y - q->k + q->a; } +struct s1 { + short x : 3, y : 12; +}; +struct s2 { + struct s1 a; +}; + +struct s2 bitfcopy2(struct s2 x) { + return (struct s2){x.a}; +} + int main(int p) { extern int printf(const char *, ...); |