mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
93803262f4
LLVM's targets need to know if stack pointer adjustments occur after the prologue. This is needed to correctly determine if the red-zone is appropriate to use or if a frame pointer is required. Normally, LLVM can figure this out very precisely by reasoning about the contents of the MachineFunction. There is an interesting corner case: inline assembly. The vast majority of inline assembly which will perform a push or pop is done so to pair up with pushf or popf as appropriate. Unfortunately, this inline assembly doesn't mark the stack pointer as clobbered because, well, it isn't. The stack pointer is decremented and then immediately incremented. Because of this, LLVM was changed in r256456 to conservatively assume that inline assembly contain a sequence of stack operations. This is unfortunate because the vast majority of inline assembly will not end up manipulating the stack pointer in any way at all. Instead, let's provide a more principled solution: an intrinsic. FWIW, other compilers (MSVC and GCC among them) also provide this functionality as an intrinsic. llvm-svn: 256685
24 lines
671 B
LLVM
24 lines
671 B
LLVM
; RUN: llc -mtriple=x86_64-pc-linux %s -o - -regalloc=fast -optimize-regalloc=0 | FileCheck %s
|
|
|
|
; We used to consider the early clobber in the second asm statement as
|
|
; defining %0 before it was read. This caused us to omit the
|
|
; movq -8(%rsp), %rdx
|
|
|
|
; CHECK: #APP
|
|
; CHECK-NEXT: #NO_APP
|
|
; CHECK-NEXT: movq %rcx, %rax
|
|
; CHECK-NEXT: movq %rax, -8(%rsp)
|
|
; CHECK-NEXT: movq -8(%rsp), %rdx
|
|
; CHECK-NEXT: #APP
|
|
; CHECK-NEXT: #NO_APP
|
|
; CHECK-NEXT: movq %rdx, %rax
|
|
; CHECK-NEXT: movq %rdx, -8(%rsp)
|
|
; CHECK-NEXT: ret
|
|
|
|
define i64 @foo() {
|
|
entry:
|
|
%0 = tail call i64 asm "", "={cx}"() nounwind
|
|
%1 = tail call i64 asm "", "=&r,0,r,~{rax}"(i64 %0, i64 %0) nounwind
|
|
ret i64 %1
|
|
}
|