File: swifttail-async-win64.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (52 lines) | stat: -rw-r--r-- 1,389 bytes parent folder | download | duplicates (6)
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(i8* 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(i8* 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 i8* @swift_self(i8* swiftasync %context, i8* swiftself %self)

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

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