File: definite_init_tuple.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 (91 lines) | stat: -rw-r--r-- 4,306 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
81
82
83
84
85
86
87
88
89
90
91
// RUN: %target-sil-opt -enable-sil-verify-all %s -definite-init -raw-sil-inst-lowering -verify

import Builtin
import Swift
import SwiftShims

struct S<T> {
  var x: (T, T)
}

sil [ossa] @$s19definite_init_tuple1SV1xx_xtvpfi : $@convention(thin) <T> () -> (@out T, @out T)

sil [ossa] @$s19definite_init_tuple1SVACyxGycfC : $@convention(method) <T> (@thin S<T>.Type) -> @out S<T> {
bb0(%0 : $*S<T>, %1 : $@thin S<T>.Type):
  %2 = alloc_box $<τ_0_0> { var S<τ_0_0> } <T>, var, name "self"
  %3 = mark_uninitialized [rootself] %2 : $<τ_0_0> { var S<τ_0_0> } <T>
  %4 = project_box %3 : $<τ_0_0> { var S<τ_0_0> } <T>, 0
  %5 = struct_element_addr %4 : $*S<T>, #S.x
  %6 = function_ref @$s19definite_init_tuple1SV1xx_xtvpfi : $@convention(thin) <τ_0_0> () -> (@out τ_0_0, @out τ_0_0)
  %7 = tuple_element_addr %5 : $*(T, T), 0
  %8 = tuple_element_addr %5 : $*(T, T), 1
  %9 = apply %6<T>(%7, %8) : $@convention(thin) <τ_0_0> () -> (@out τ_0_0, @out τ_0_0)
  copy_addr %4 to [init] %0 : $*S<T>
  destroy_value %3 : $<τ_0_0> { var S<τ_0_0> } <T>
  %12 = tuple ()
  return %12 : $()
}

struct MyText<V> {
  let label: String
  // expected-note @-1 {{'self.label' not initialized}}
  let value: V
  // expected-note @-1 {{'self.value.0' not initialized}}
  // expected-note @-2 {{'self.value.1' not initialized}} 
}

sil [ossa] @tuple_addr_constructor_1 : $@convention(method) (@owned String, Int, @thin MyText<(Int, Int)>.Type) -> @owned MyText<(Int, Int)> {
bb0(%0 : @owned $String, %1 : $Int, %2 : $@thin MyText<(Int, Int)>.Type):
  %3 = alloc_stack $MyText<(Int, Int)>, var, name "self"
  %4 = mark_uninitialized [rootself] %3 : $*MyText<(Int, Int)>
  %7 = copy_value %0 : $String
  %8 = begin_access [modify] [static] %4 : $*MyText<(Int, Int)>
  %9 = struct_element_addr %8 : $*MyText<(Int, Int)>, #MyText.label
  assign %7 to %9 : $*String
  end_access %8 : $*MyText<(Int, Int)>
  %12 = begin_access [modify] [static] %4 : $*MyText<(Int, Int)>
  %13 = struct_element_addr %12 : $*MyText<(Int, Int)>, #MyText.value
  tuple_addr_constructor [assign] %13 : $*(Int, Int) with (%1 : $Int, %1 : $Int)
  end_access %12 : $*MyText<(Int, Int)>
  %16 = load [copy] %4 : $*MyText<(Int, Int)>
  destroy_value %0 : $String
  destroy_addr %4 : $*MyText<(Int, Int)>
  dealloc_stack %3 : $*MyText<(Int, Int)>
  return %16 : $MyText<(Int, Int)>
}

sil [ossa] @tuple_addr_constructor_2 : $@convention(method) (@owned String, Int, @thin MyText<(Int, Int)>.Type) -> @owned MyText<(Int, Int)> {
bb0(%0 : @owned $String, %1 : $Int, %2 : $@thin MyText<(Int, Int)>.Type):
  %3 = alloc_stack $MyText<(Int, Int)>, var, name "self"
  %4 = mark_uninitialized [rootself] %3 : $*MyText<(Int, Int)>
  %7 = copy_value %0 : $String
  %8 = begin_access [modify] [static] %4 : $*MyText<(Int, Int)>
  %9 = struct_element_addr %8 : $*MyText<(Int, Int)>, #MyText.label
  destroy_value %7 : $String
  end_access %8 : $*MyText<(Int, Int)>
  %12 = begin_access [modify] [static] %4 : $*MyText<(Int, Int)>
  %13 = struct_element_addr %12 : $*MyText<(Int, Int)>, #MyText.value
  tuple_addr_constructor [assign] %13 : $*(Int, Int) with (%1 : $Int, %1 : $Int)
  end_access %12 : $*MyText<(Int, Int)>
  %16 = load [copy] %4 : $*MyText<(Int, Int)> // expected-error {{return from initializer without initializing all stored properties}}
  destroy_value %0 : $String
  destroy_addr %4 : $*MyText<(Int, Int)>
  dealloc_stack %3 : $*MyText<(Int, Int)>
  return %16 : $MyText<(Int, Int)>
}

sil [ossa] @tuple_addr_constructor_3 : $@convention(method) (@owned String, Int, @thin MyText<(Int, Int)>.Type) -> @owned MyText<(Int, Int)> {
bb0(%0 : @owned $String, %1 : $Int, %2 : $@thin MyText<(Int, Int)>.Type):
  %3 = alloc_stack $MyText<(Int, Int)>, var, name "self"
  %4 = mark_uninitialized [rootself] %3 : $*MyText<(Int, Int)>
  %7 = copy_value %0 : $String
  %8 = begin_access [modify] [static] %4 : $*MyText<(Int, Int)>
  %9 = struct_element_addr %8 : $*MyText<(Int, Int)>, #MyText.label
  assign %7 to %9 : $*String
  end_access %8 : $*MyText<(Int, Int)>
  %16 = load [copy] %4 : $*MyText<(Int, Int)> // expected-error {{return from initializer without initializing all stored properties}}
  destroy_value %0 : $String
  destroy_addr %4 : $*MyText<(Int, Int)>
  dealloc_stack %3 : $*MyText<(Int, Int)>
  return %16 : $MyText<(Int, Int)>
}