File: capture_promotion_resilient.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 (59 lines) | stat: -rw-r--r-- 3,115 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
// RUN: %target-sil-opt -enable-library-evolution -enable-sil-verify-all %s -capture-promotion | %FileCheck %s

sil_stage raw

import Swift

public struct ResilientStruct {
  var x : Int64
}

sil [ossa] @closure0 : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> () {
bb0(%0 : @guaranteed $<τ_0_0> { var τ_0_0 } <ResilientStruct>):
  %1 = project_box %0 : $<τ_0_0> { var τ_0_0 } <ResilientStruct>, 0
  %2 = tuple ()
  return %2 : $()
}

// Primarily don't crash.

// CHECK-LABEL: sil [ossa] @$s8closure0Tf2i_n : $@convention(thin) (ResilientStruct) -> () {
// CHECK: bb0(%0 : $ResilientStruct):
// CHECK:   return {{.*}} : $()
// CHECK: }

// CHECK: sil [ossa] @test_capture_promotion : $@convention(thin) (@in_guaranteed ResilientStruct) -> @owned @callee_guaranteed () -> () {
// CHECK: bb0([[ARG:%.*]] : $*ResilientStruct):
// CHECK:   [[BOX:%.*]] = alloc_box $<τ_0_0> { var τ_0_0 } <ResilientStruct>
// CHECK:   [[F1:%.*]] = project_box [[BOX]]
// CHECK:   [[F2:%.*]] = project_box [[BOX]]
// CHECK:   copy_addr [[ARG]] to [init] [[F2]] : $*ResilientStruct
// CHECK:   [[F:%.*]] = function_ref @$s8closure0Tf2i_n : $@convention(thin) (ResilientStruct) -> () // user: %8
// CHECK:   [[R:%.*]] = load [trivial] [[F1]] : $*ResilientStruct
// CHECK:   [[C:%.*]] = partial_apply [callee_guaranteed] [[F]]([[R]])
// CHECK:   return [[C]] : $@callee_guaranteed () -> ()
// CHECK: }
sil [ossa] @test_capture_promotion : $@convention(thin) (@in_guaranteed ResilientStruct) -> @owned @callee_guaranteed () -> () {
bb0(%0 : $*ResilientStruct):
  %1 = alloc_box $<τ_0_0> { var τ_0_0 } <ResilientStruct>
  %2 = project_box %1 : $<τ_0_0> { var τ_0_0 } <ResilientStruct>, 0
  copy_addr %0 to [init] %2 : $*ResilientStruct
  %4 = function_ref @closure0 : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
  %5 = partial_apply [callee_guaranteed] %4(%1) : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
  return %5 : $@callee_guaranteed () -> ()
}

// CHECK-LABEL: sil [serialized] [ossa] @test_capture_promotion_2 :
// CHECK:  [[F:%.*]] = function_ref @closure0 : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
// CHECK:  [[C:%.*]] = partial_apply [callee_guaranteed] [[F]]({{.*}}) : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
// CHECK:  return [[C]]
// CHECK: } // end sil function 'test_capture_promotion_2'
sil [serialized] [ossa] @test_capture_promotion_2 : $@convention(thin) (@in_guaranteed ResilientStruct) -> @owned @callee_guaranteed () -> () {
bb0(%0 : $*ResilientStruct):
  %1 = alloc_box $<τ_0_0> { var τ_0_0 } <ResilientStruct>
  %2 = project_box %1 : $<τ_0_0> { var τ_0_0 } <ResilientStruct>, 0
  copy_addr %0 to [init] %2 : $*ResilientStruct
  %4 = function_ref @closure0 : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
  %5 = partial_apply [callee_guaranteed] %4(%1) : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <ResilientStruct>) -> ()
  return %5 : $@callee_guaranteed () -> ()
}