File: simple_partial_apply.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (57 lines) | stat: -rw-r--r-- 3,516 bytes parent folder | download
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
53
54
55
56
57
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-cpu

sil_stage canonical

import Swift

class C {}

sil_vtable C {}

struct SingleRefcounted {
    var c: C
}

// CHECK-LABEL: define {{.*}} @escape_partial_apply_swift_class
// CHECK-arm64e:  call i64 @llvm.ptrauth.resign
// CHECK:      [[FPTR:%.*]] = insertvalue { ptr, ptr } undef, ptr {{.*}}, 0
// CHECK-NEXT: [[FCTX:%.*]] = insertvalue { ptr, ptr } [[FPTR]], ptr {{.*}}, 1
// CHECK-NEXT: ret { ptr, ptr } [[FCTX]]
sil @escape_partial_apply_swift_class : $@convention(thin) (@convention(method) (Int, @guaranteed C) -> Int, @guaranteed C) -> @callee_guaranteed (Int) -> Int {
entry(%body : $@convention(method) (Int, @guaranteed C) -> Int, %context : $C):
  %closure = partial_apply [callee_guaranteed] %body(%context) : $@convention(method) (Int, @guaranteed C) -> Int
  return %closure : $@callee_guaranteed (Int) -> Int
}

// Can't reuse the method because it does not have swiftself.

// CHECK-LABEL: define {{.*}} @escape_partial_apply_swift_single_refcount_struct
// CHECK: [[CTXT:%.*]] = call {{.*}} @swift_allocObject
// CHECK: [[FCTX:%.*]] = insertvalue { ptr, ptr } { ptr @"$sTA{{.*}}", ptr undef }, ptr [[CTXT]], 1
// CHECK-NEXT: ret { ptr, ptr } [[FCTX]]
sil @escape_partial_apply_swift_single_refcount_struct : $@convention(thin) (@convention(method) (Int, @guaranteed SingleRefcounted) -> Int, @guaranteed SingleRefcounted) -> @callee_guaranteed (Int) -> Int {
entry(%body : $@convention(method) (Int, @guaranteed SingleRefcounted) -> Int, %context : $SingleRefcounted):
  %closure = partial_apply [callee_guaranteed] %body(%context) : $@convention(method) (Int, @guaranteed SingleRefcounted) -> Int
  return %closure : $@callee_guaranteed (Int) -> Int
}

// CHECK-LABEL: define {{.*}} @noescape_partial_apply_swift_indirect
// CHECK:       call {{.*}}void %2(ptr {{.*}}, ptr %1, ptr {{.*}}%3)
sil @noescape_partial_apply_swift_indirect : $@convention(thin) (@convention(method) (Int, @in_guaranteed C) -> Int, @in_guaranteed C, @guaranteed @callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()) -> () {
entry(%body : $@convention(method) (Int, @in_guaranteed C) -> Int, %context : $*C, %cont : $@callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()):
  %closure = partial_apply [callee_guaranteed] [on_stack] %body(%context) : $@convention(method) (Int, @in_guaranteed C) -> Int
  %x = apply %cont(%closure) : $@callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()
  dealloc_stack %closure : $@noescape @callee_guaranteed (Int) -> Int
  return undef : $()
}

// Can't reuse the method because it does not have swiftself.
// CHECK-LABEL: define {{.*}} @noescape_partial_apply_swift_direct_word
// CHECK: call swiftcc void {{.*}}(ptr @"$sTA{{.*}}", ptr {{.*}}, ptr swiftself {{.*}})
sil @noescape_partial_apply_swift_direct_word : $@convention(thin) (@convention(method) (Int, Int) -> Int, Int, @guaranteed @callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()) -> () {
entry(%body : $@convention(method) (Int, Int) -> Int, %context : $Int, %cont : $@callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()):
  %closure = partial_apply [callee_guaranteed] [on_stack] %body(%context) : $@convention(method) (Int, Int) -> Int
  %x = apply %cont(%closure) : $@callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()
  dealloc_stack %closure : $@noescape @callee_guaranteed (Int) -> Int
  return undef : $()
}