llvm-project/llvm/test/CodeGen/X86/frame-pointer-reserved.ll
Brandt Bucher 30836781e8
[X86] Don't use rbp when it's reserved (#146638)
This fixes the x86 backend to properly reserve `rbp` when the
`frame-pointer=reserved` option is used. Currently, this option is
ignored.

Disassembly of the new test case before:

```s
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %ebp
callq bar@PLT
movl %ebp, %edi
movl %ebx, %esi
callq bar@PLT
addq $8, %rsp
popq %rbx
popq %rbp
retq
```

...and after (`r14` is used as scratch space in place of `rbp`):

```s
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %r14d
callq bar@PLT
movl %r14d, %edi
movl %ebx, %esi
callq bar@PLT
addq $8, %rsp
popq %rbx
popq %r14
retq
```

Fixes #117178.
2025-07-07 10:02:47 +01:00

26 lines
774 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
declare void @bar(i32, i32)
define void @foo(i32 %0, i32 %1) nounwind "frame-pointer"="reserved" {
; CHECK-LABEL: foo:
; CHECK: # %bb.0:
; CHECK-NEXT: pushq %r14
; CHECK-NEXT: pushq %rbx
; CHECK-NEXT: pushq %rax
; CHECK-NEXT: movl %esi, %ebx
; CHECK-NEXT: movl %edi, %r14d
; CHECK-NEXT: callq bar@PLT
; CHECK-NEXT: movl %r14d, %edi
; CHECK-NEXT: movl %ebx, %esi
; CHECK-NEXT: callq bar@PLT
; CHECK-NEXT: addq $8, %rsp
; CHECK-NEXT: popq %rbx
; CHECK-NEXT: popq %r14
; CHECK-NEXT: retq
call void @bar(i32 %0, i32 %1)
call void @bar(i32 %0, i32 %1)
ret void
}