aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/X86/swifttail-async-win64.ll
blob: 82efeadd2b28ebe670bb4fe37e91e92d64cfac41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
; RUN: llc -mtriple x86_64-unknown-windows-msvc %s -o - | FileCheck %s

declare swifttailcc void @callee()

define swifttailcc void @swift_tail() {
  call void asm "","~{r14}"()
  tail call swifttailcc void @callee()
  ret void
}

; CHECK-LABEL: swift_tail:
; CHECK-NOT: popq %r14

define void @has_swift_async(ptr swiftasync %contet) {
  call void asm "","~{r14}"()
  ret void
}

; CHECK-LABEL: has_swift_async:
; CHECK: popq    %r14

; It's impossible to get a tail call from a function without a swiftasync
; parameter to one with unless the CC is swifttailcc. So it doesn't matter
; whether r14 is callee-saved in this case.
define void @calls_swift_async() {
  call void asm "","~{r14}"()
  tail call void @has_swift_async(ptr swiftasync null)
  ret void
}

; CHECK-LABEL: calls_swift_async:
; CHECK-NOT: jmpq has_swift_async

define swifttailcc void @no_preserve_swiftself() {
  call void asm "","~{r13}"()
  ret void
}

; CHECK-LABEL: no_preserve_swiftself:
; CHECK-NOT: popq %r13

declare swifttailcc ptr @swift_self(ptr swiftasync %context, ptr swiftself %self)

define swiftcc ptr @call_swift_self(ptr swiftself %self, ptr %context) {
  ; call void asm "","~{r13}"()
  ; We get a push r13 but why not with the call below?
  %res = call swifttailcc ptr @swift_self(ptr swiftasync %context, ptr swiftself %self)
  ret ptr %res
}

; CHECK-LABEL: call_swift_self:
; CHECK: pushq %r13