[llvm] [RISCV][MRI] Account for fixed registers when determining callee saved regs (PR #115756)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 11 13:47:42 PST 2024


michaelmaitland wrote:

It looks like we are still allocating a slack slot.
```
register long a asm("x8");

int foo(int b, int c) {
  asm volatile ("" ::: "x9");
  a = 321;
  return 0;
}
```
GCC:
```
        addi    sp,sp,-16
        sd      s1,8(sp)
        li      s0,321
        ld      s1,8(sp)
        li      a0,0
        addi    sp,sp,16
        jr      ra
```
LLVM + this patch:
```
          addi    sp, sp, -16
        sd      s0, 8(sp)                       # 8-byte Folded Spill
        sd      s1, 0(sp)                       # 8-byte Folded Spill
        li      s0, 321
        li      a0, 0
        ld      s0, 8(sp)                       # 8-byte Folded Reload
        ld      s1, 0(sp)                       # 8-byte Folded Reload
        addi    sp, sp, 16
        ret
```

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


More information about the llvm-commits mailing list