File: escape_effects_objc.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 (56 lines) | stat: -rw-r--r-- 2,556 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
// RUN: %target-sil-opt %s -compute-escape-effects | %FileCheck %s

// REQUIRES: swift_in_compiler
// REQUIRES: objc_interop
// REQUIRES: PTRSIZE=64

sil_stage canonical

import Builtin
import Swift
import SwiftShims

class Y {
  @_hasStorage var i: Int
}

// CHECK-LABEL: sil @array_adopt_storage
// CHECK-NEXT:  [%0: escape => %r.0.s0.s0.s0, escape c*.v** -> %r.**]
// CHECK-NEXT:  {{^[^[]}}
sil @array_adopt_storage : $@convention(thin) (@owned _ContiguousArrayStorage<Y>) -> (@owned Array<Y>, UnsafeMutablePointer<Y>) {
bb0(%0 : $_ContiguousArrayStorage<Y>):
  %3 = upcast %0 : $_ContiguousArrayStorage<Y> to $__ContiguousArrayStorageBase
  %12 = unchecked_ref_cast %0 : $_ContiguousArrayStorage<Y> to $Builtin.BridgeObject
  %13 = struct $_BridgeStorage<__ContiguousArrayStorageBase> (%12 : $Builtin.BridgeObject)
  %14 = struct $_ArrayBuffer<Y> (%13 : $_BridgeStorage<__ContiguousArrayStorageBase>)
  %15 = struct $Array<Y> (%14 : $_ArrayBuffer<Y>)
  %16 = ref_tail_addr %3 : $__ContiguousArrayStorageBase, $Y
  %17 = address_to_pointer %16 : $*Y to $Builtin.RawPointer
  %18 = struct $UnsafeMutablePointer<Y> (%17 : $Builtin.RawPointer)
  %19 = tuple (%15 : $Array<Y>, %18 : $UnsafeMutablePointer<Y>)
  return %19 : $(Array<Y>, UnsafeMutablePointer<Y>)
}

// CHECK-LABEL: sil @array_destructor
// CHECK-NEXT:  [%0: noescape, noescape c*.v**]
// CHECK-NEXT:  {{^[^[]}}
sil @array_destructor : $@convention(method) <Element> (@owned _ContiguousArrayStorage<Element>) -> () {
bb0(%0 : $_ContiguousArrayStorage<Element>):
  %1 = ref_tail_addr %0 : $_ContiguousArrayStorage<Element>, $Element
  %2 = address_to_pointer %1 : $*Element to $Builtin.RawPointer
  %3 = upcast %0 : $_ContiguousArrayStorage<Element> to $__ContiguousArrayStorageBase
  %4 = ref_element_addr %3 : $__ContiguousArrayStorageBase, #__ContiguousArrayStorageBase.countAndCapacity
  %5 = struct_element_addr %4 : $*_ArrayBody, #_ArrayBody._storage
  %6 = struct_element_addr %5 : $*_SwiftArrayBodyStorage, #_SwiftArrayBodyStorage.count
  %7 = struct_element_addr %6 : $*Int, #Int._value
  %8 = load %7 : $*Builtin.Int64
  %9 = builtin "assumeNonNegative_Int64"(%8 : $Builtin.Int64) : $Builtin.Int64
  %10 = metatype $@thick Element.Type
  %11 = builtin "truncOrBitCast_Int64_Word"(%9 : $Builtin.Int64) : $Builtin.Word
  %12 = builtin "destroyArray"<Element>(%10 : $@thick Element.Type, %2 : $Builtin.RawPointer, %11 : $Builtin.Word) : $()
  fix_lifetime %0 : $_ContiguousArrayStorage<Element>
  dealloc_ref %0 : $_ContiguousArrayStorage<Element>
  %15 = tuple ()
  return %15 : $()
}