[llvm] [RISCV] Allow spilling to unused Zcmp Stack (PR #125959)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 29 15:02:29 PDT 2025


topperc wrote:

https://godbolt.org/z/bhaq19vrb

With the patch we generate

```
        cm.push {ra, s0}, -16
        csrr    a0, vlenb
        sub     sp, sp, a0
        vsetivli        zero, 1, e32, m1, ta, ma
        vmv.s.x v8, zero
        mv      s0, sp
        li      a0, 1
        vs1r.v  v8, (s0)
        sw      a0, 4(sp)
        addi    a0, sp, 4
        mv      a1, sp
        call    foo
        vl1re32.v       v8, (s0)
        csrr    a0, vlenb
        add     sp, sp, a0
        cm.popret       {ra, s0}, 16
```

This has the vector allocated at sp, and the `int` local variable at sp+4. If the vector is more than 4 bytes, that's an overlap.

https://github.com/llvm/llvm-project/pull/125959


More information about the llvm-commits mailing list