File: lifetime_dependence.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 (44 lines) | stat: -rw-r--r-- 1,476 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
// RUN: %target-sil-opt %s \
// RUN:   -o /dev/null \
// RUN:   -sil-verify-all \
// RUN:   -module-name Swift \
// RUN:   -enable-experimental-feature NonescapableTypes

// REQUIRES: asserts
// REQUIRES: swift_in_compiler

// Test the SIL representation for lifetime depenence.

sil_stage raw

class C {}

@_marker public protocol Escapable { }

struct Nonescapable: ~Escapable {}

sil @c_dependence : $@convention(thin) (@guaranteed C) -> _scope(0) @owned Nonescapable

// Test that SILType.isEscpable does not crash on a generic box when NoncopyableGenerics is enabled.
sil shared [serialized] [ossa] @testLocalFunc : $@convention(thin) <T, U> (@guaranteed <τ_0_0> { var τ_0_0 } <U>) -> () {
bb0(%1 : @closureCapture @guaranteed $<τ_0_0> { var τ_0_0 } <U>):
  %33 = tuple ()
  return %33 : $()
}

// Test that ownership verification handles a mark_dependence with a stored use.
sil [ossa] @test_mark_dependence_store : $@convention(thin) (@owned C) -> () {
bb0(%0 : @owned $C):
  %stk = alloc_stack [var_decl] $Nonescapable
  %f = function_ref @c_dependence : $@convention(thin) (@guaranteed C) -> _scope(0) @owned Nonescapable
  %c = apply %f(%0) : $@convention(thin) (@guaranteed C) -> _scope(0) @owned Nonescapable

  %md = mark_dependence [nonescaping] %c : $Nonescapable on %0 : $C
  store %md to [init] %stk : $*Nonescapable

  destroy_addr %stk : $*Nonescapable
  dealloc_stack %stk : $*Nonescapable
  destroy_value %0 : $C
  %28 = tuple ()
  return %28 : $()
}