File: definite_init_closures.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 (80 lines) | stat: -rw-r--r-- 3,234 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// RUN: %target-sil-opt -enable-sil-verify-all %s -definite-init

// Test that implicit closures don't count as use of the whole self and only
// actual uses inside the closures are taken into account.

// Check that no errors are generated. No FileCheck needed.

sil_stage raw

import Builtin
import Swift
import SwiftShims

struct SimpleStruct {
  @_hasStorage let x: Bool
  @_hasStorage let y: Bool
  init()
}

class SimpleClass {
  @_hasStorage final let x: Bool
  @_hasStorage final let y: Bool
  init()
}

sil [ossa] @$s4test1SVACycfC : $@convention(method) (Bool) -> SimpleStruct {
bb0(%0 : $Bool):
  %1 = alloc_stack $SimpleStruct, var, name "self"
  %2 = mark_uninitialized [rootself] %1 : $*SimpleStruct
  %7 = begin_access [modify] [static] %2 : $*SimpleStruct
  %8 = struct_element_addr %7 : $*SimpleStruct, #SimpleStruct.x
  assign %0 to %8 : $*Bool
  end_access %7 : $*SimpleStruct
  %16 = function_ref @implicit_closure_struct : $@convention(thin) (@inout_aliasable SimpleStruct) -> (Bool, @error any Error)
  %17 = partial_apply [callee_guaranteed] %16(%2) : $@convention(thin) (@inout_aliasable SimpleStruct) -> (Bool, @error any Error)
  destroy_value %17 : $@callee_guaranteed () -> (Bool, @error any Error)
  %23 = begin_access [modify] [static] %2 : $*SimpleStruct
  %24 = struct_element_addr %23 : $*SimpleStruct, #SimpleStruct.y
  assign %0 to %24 : $*Bool
  end_access %23 : $*SimpleStruct
  %27 = load [trivial] %2 : $*SimpleStruct
  dealloc_stack %1 : $*SimpleStruct
  return %27 : $SimpleStruct
}

sil private [transparent] [ossa] @implicit_closure_struct : $@convention(thin) (@inout_aliasable SimpleStruct) -> (Bool, @error any Error) {
bb0(%0 : $*SimpleStruct):
  debug_value %0 : $*SimpleStruct, var, name "self", argno 2, expr op_deref
  %3 = begin_access [read] [static] %0 : $*SimpleStruct
  %4 = struct_element_addr %3 : $*SimpleStruct, #SimpleStruct.x
  %5 = load [trivial] %4 : $*Bool
  end_access %3 : $*SimpleStruct
  return %5 : $Bool
}

sil [ossa] @$s4test11SimpleClassC1bACSb_tcfc : $@convention(method) (Bool, @owned SimpleClass) -> @owned SimpleClass {
bb0(%0 : $Bool, %1 : @owned $SimpleClass):
  %4 = mark_uninitialized [rootself] %1 : $SimpleClass
  %5 = begin_borrow %4 : $SimpleClass
  %6 = ref_element_addr %5 : $SimpleClass, #SimpleClass.x
  assign %0 to %6 : $*Bool
  end_borrow %5 : $SimpleClass
  %9 = begin_borrow %4 : $SimpleClass
  %11 = function_ref @implicit_closure_class : $@convention(thin) (@guaranteed SimpleClass) -> (Bool, @error any Error)
  %12 = copy_value %4 : $SimpleClass
  %13 = partial_apply [callee_guaranteed] %11(%12) : $@convention(thin) (@guaranteed SimpleClass) -> (Bool, @error any Error)
  destroy_value %13 : $@callee_guaranteed () -> (Bool, @error any Error)
  %19 = ref_element_addr %9 : $SimpleClass, #SimpleClass.y
  assign %0 to %19 : $*Bool
  end_borrow %9 : $SimpleClass
  return %4 : $SimpleClass
}

sil private [transparent] [ossa] @implicit_closure_class : $@convention(thin) (@guaranteed SimpleClass) -> (Bool, @error any Error) {
bb0(%0 : @guaranteed $SimpleClass):
  debug_value %0 : $SimpleClass, let, name "self", argno 2
  %3 = ref_element_addr %0 : $SimpleClass, #SimpleClass.x
  %4 = load [trivial] %3 : $*Bool
  return %4 : $Bool
}