[llvm] Spill/restore FP/BP around instructions in which they are clobbered (PR #81048)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 05:12:41 PST 2024


aengelke wrote:

This apparently doesn't catch all cases. Example: ghccc uses rbp as argument register, but rbp is used after the function call despite being clobbered before.

```
; RUN: llc -mtriple=x86_64-pc-linux -stackrealign -verify-machineinstrs < %s

declare ghccc i32 @external(i32)

define i32 @foo(i32 %0, i32 %1) {
    %x = call ghccc i32 @external(i32 %0, i32 %1)
    ret i32 %x
}
```
Output (w/o directives for brevity):
```
foo:                                    # @foo
# %bb.0:
        pushq   %rbp
        movq    %rsp, %rbp
        pushq   %r15
        pushq   %r14
        pushq   %r13
        pushq   %r12
        pushq   %rbx
        andq    $-16, %rsp
        subq    $16, %rsp
                                        # kill: def $edi killed $edi def $rdi
        movl    %esi, %ebp
        movq    %rdi, %r13
        callq   external at PLT
        leaq    -40(%rbp), %rsp
        popq    %rbx
        popq    %r12
        popq    %r13
        popq    %r14
        popq    %r15
        popq    %rbp
        retq
```

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


More information about the llvm-commits mailing list