llvm-project/llvm/test/CodeGen/X86/ipra-transform.ll
weiguozhi c166a43c6e
New calling convention preserve_none (#76868)
The new experimental calling convention preserve_none is the opposite
side of existing preserve_all. It tries to preserve as few general
registers as possible. So all general registers are caller saved
registers. It can also uses more general registers to pass arguments.
This attribute doesn't impact floating-point registers. Floating-point
registers still follow the c calling convention.

Currently preserve_none is supported on X86-64 only. It changes the c
calling convention in following fields:
  
* RSP and RBP are the only preserved general registers, all other
general registers are caller saved registers.
* We can use [RDI, RSI, RDX, RCX, R8, R9, R11, R12, R13, R14, R15, RAX]
to pass arguments.

It can improve the performance of hot tailcall chain, because many
callee saved registers' save/restore instructions can be removed if the
tail functions are using preserve_none. In my experiment in protocol
buffer, the parsing functions are improved by 3% to 10%.
2024-02-05 13:28:43 -08:00

52 lines
1.1 KiB
LLVM

; RUN: llc < %s | FileCheck %s -check-prefix=NOIPRA
; RUN: llc -enable-ipra < %s | FileCheck %s
target triple = "x86_64-unknown-unknown"
define void @bar1() {
ret void
}
define preserve_allcc void @foo()#0 {
; Due to preserve_allcc foo() will save some registers at start of foo()
; prefix NOIPRA will verify that.
; NOIPRA-LABEL: foo:
; NOIPRA: pushq %r10
; NOIPRA-NEXT: pushq %r9
; NOIPRA-NEXT: pushq %r8
; NOIPRA: callq bar1
; When IPRA is present above registers will not be saved and that is verified
; by prefix CHECK.
; CHECK: foo:
; CHECK-NOT: pushq %r10
; CHECK-NOT: pushq %r9
; CHECK-NOT: pushq %r8
; CHECK: callq bar1
call void @bar1()
call void @bar2()
ret void
}
define void @bar2() {
ret void
}
define preserve_nonecc void @foo2()#0 {
; Due to preserve_nonecc foo2() will save above registers no matter IPRA is
; present or not.
; NOIPRA-LABEL: foo2:
; NOIPRA-NOT: pushq %r10
; NOIPRA-NOT: pushq %r9
; NOIPRA-NOT: pushq %r8
; NOIPRA: callq bar1
; CHECK: foo2:
; CHECK-NOT: pushq %r10
; CHECK-NOT: pushq %r9
; CHECK-NOT: pushq %r8
; CHECK: callq bar1
call void @bar1()
call void @bar2()
ret void
}
attributes #0 = {nounwind}