File: lexical_destroy_folding_unit.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 (52 lines) | stat: -rw-r--r-- 2,021 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
// RUN: %target-sil-opt -test-runner %s -o /dev/null 2>&1 | %FileCheck %s

class C {}
sil [ossa] @callee_owned : $@convention(thin) (@owned C) -> ()

// Fold apply when guaranteed lexical value used in one but not two branches
// and the lexical scope ends before the use on the non-lexical branch.
//
// CHECK-LABEL: sil [ossa] @nofold_two_parallel_owned_uses_one_lexical___scope_ends_before_use : {{.*}} {
// CHECK:       {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
// CHECK:         [[COPY:%[^,]+]] = copy_value [[INSTANCE]]
// CHECK:         [[MOVE:%[^,]+]] = move_value [lexical] [[INSTANCE]]
// CHECK:         [[CALLEE_OWNED:%[^,]+]] = function_ref @callee_owned
// CHECK:         cond_br undef, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
// CHECK:       [[LEFT]]:
// CHECK:         apply [[CALLEE_OWNED]]([[MOVE]])
// CHECK:         destroy_value [[COPY]]
// CHECK:         br [[EXIT:bb[0-9]+]]
// CHECK:       [[RIGHT]]:
// CHECK:         destroy_value [[MOVE]]
// CHECK:         apply [[CALLEE_OWNED]]([[COPY]])
// CHECK:         br [[EXIT]]
// CHECK:       [[EXIT]]:
// CHECK-LABEL: } // end sil function 'nofold_two_parallel_owned_uses_one_lexical___scope_ends_before_use'
sil [ossa] @nofold_two_parallel_owned_uses_one_lexical___scope_ends_before_use : $@convention(thin) (@owned C) -> () {
entry(%instance : @owned $C):
  specify_test "lexical-destroy-folding @trace[0]"
  %copy_2 = copy_value %instance : $C
  %lifetime = begin_borrow [lexical] %instance : $C
  debug_value [trace] %lifetime : $C
  %callee_owned = function_ref @callee_owned : $@convention(thin) (@owned C) -> ()
  cond_br undef, left, right

left:
  %copy_1 = copy_value %lifetime : $C
  apply %callee_owned(%copy_1) : $@convention(thin) (@owned C) -> ()
  end_borrow %lifetime : $C
  destroy_value %instance : $C
  destroy_value %copy_2 : $C
  br exit

right:
  end_borrow %lifetime : $C
  destroy_value %instance : $C
  apply %callee_owned(%copy_2) : $@convention(thin) (@owned C) -> ()
  br exit

exit:
  %retval = tuple ()
  return %retval : $()
}