File: closure-lifetime-fixup-debuginfo.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-- 2,773 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 -enable-sil-verify-all -closure-lifetime-fixup -emit-verbose-sil %s | %FileCheck %s

import Builtin
import Swift
import SwiftShims


sil_scope 1 { loc "closure-lifetime-fixup-debuginfo.sil":12:34 parent @destroy_and_dealloc_of_capture_are_cleanups : $@convention(method) <Self where Self : Indexable> (@in Self) -> () }
sil_scope 2 { loc "closure-lifetime-fixup-debuginfo.sil":12:34 parent 1 }

protocol Indexable {
associatedtype Index
}

// Verify that the destroy_addr and dealloc_stack that are created for captured
// closure arguments are marked as cleanups.
// CHECK-LABEL: sil [ossa] @destroy_and_dealloc_of_capture_are_cleanups : {{.*}} {
// CHECK:         [[CAPTURED_ADDR:%[^,]+]] = alloc_stack $Self
// CHECK:         try_apply {{.*}}, normal [[SUCCESS:bb[0-9]+]]
// CHECK:       [[SUCCESS]]
// CHECK:         destroy_addr [[CAPTURED_ADDR]]{{.*}}:cleanup:
//                                                     ^^^^^^^
// CHECK:         dealloc_stack [[CAPTURED_ADDR]]{{.*}}:cleanup:
//                                                      ^^^^^^^
// CHECK-LABEL: } // end sil function 'destroy_and_dealloc_of_capture_are_cleanups'
sil [ossa] @destroy_and_dealloc_of_capture_are_cleanups : $@convention(method) <Self where Self : Indexable> (@in Self) -> () {
bb0(%self : $*Self):
  %copy = alloc_stack $Self, scope 1
  copy_addr %self to [init] %copy : $*Self, scope 2
  %closure = partial_apply [callee_guaranteed] undef<Self>(%copy) : $@convention(thin) <Tee where Tee : Indexable> (@in_guaranteed Tee) -> (@out Tee.Index, @error any Error), scope 2
  %converted = convert_function %closure : $@callee_guaranteed () -> (@out Self.Index, @error any Error) to $@callee_guaranteed @substituted <Tee> () -> (@out Tee, @error any Error) for <Self.Index>, scope 2
  %noescape = convert_escape_to_noescape [not_guaranteed] %converted : $@callee_guaranteed @substituted <Tee> () -> (@out Tee, @error any Error) for <Self.Index> to $@noescape @callee_guaranteed @substituted <Tee> () -> (@out Tee, @error any Error) for <Self.Index>, scope 2
  try_apply undef<Self.Index>(%noescape) : $@convention(thin) <Tee> (@noescape @callee_guaranteed @substituted <Tee> () -> (@out Tee, @error any Error) for <Tee>) -> (@error any Error), normal bb1, error bb2, scope 2
bb1(%result : $()):
  destroy_value %noescape : $@noescape @callee_guaranteed @substituted <Tee> () -> (@out Tee, @error any Error) for <Self.Index>, scope 2
  destroy_value %converted : $@callee_guaranteed @substituted <Tee> () -> (@out Tee, @error any Error) for <Self.Index>, scope 2
  destroy_addr %self : $*Self, scope 2
  %retval = tuple (), scope 2
  dealloc_stack %copy : $*Self, scope 2
  return %retval : $(), scope 2

bb2(%83 : @owned $any Error):
  unreachable , scope 2
}