File: instruction_deleter.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-- 2,303 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 -test-runner %s -o /dev/null 2>&1 | %FileCheck %s

import Swift

struct MOS : ~Copyable {}

sil @getMOS : $() -> (@owned MOS)
sil @barrier : $() -> ()

class C {}

sil @get : $<T> () -> (@out T)

// CHECK-LABEL: begin running test {{.*}} on dontDeleteDeadMoveOnlyValue
// CHECK:       Deleting-if-dead {{.*}} move_value
// CHECK:       deleteIfDead returned 0
// CHECK-LABEL: sil [ossa] @dontDeleteDeadMoveOnlyValue : {{.*}} {
// CHECK:         [[GET:%[^,]+]] = function_ref @getMOS
// CHECK:         [[BARRIER:%[^,]+]] = function_ref @barrier
// CHECK:         [[MOS:%[^,]+]] = apply [[GET]]()
// CHECK:         [[MOV:%[^,]+]] = move_value [[MOS]]
// CHECK:         apply [[BARRIER]]()
// CHECK:         destroy_value [[MOV]]
// CHECK-LABEL: } // end sil function 'dontDeleteDeadMoveOnlyValue'
// CHECK-LABEL: end running test {{.*}} on dontDeleteDeadMoveOnlyValue
sil [ossa] @dontDeleteDeadMoveOnlyValue : $() -> () {
  %get = function_ref @getMOS : $@convention(thin) () -> (@owned MOS)
  %barrier = function_ref @barrier : $@convention(thin) () -> ()
  %mos = apply %get() : $@convention(thin) () -> (@owned MOS)
  specify_test "deleter-delete-if-dead @instruction"
  %mov = move_value %mos : $MOS
  apply %barrier() : $@convention(thin) () -> ()
  destroy_value %mov : $MOS
  %retval = tuple ()
  return %retval : $()
}

// CHECK-LABEL: begin running test {{.*}} on doDeleteLoadTake
// CHECK:       Deleting-if-dead   {{%[^,]+}} = load [take]
// CHECK:       deleteIfDead returned 1
// CHECK-LABEL: sil [ossa] @doDeleteLoadTake : {{.*}} {
// CHECK:         [[STACK:%[^,]+]] = alloc_stack $C
// CHECK:         [[GET:%[^,]+]] = function_ref @get
// CHECK:         apply [[GET]]<C>([[STACK]])
// CHECK:         destroy_addr [[STACK]]
// CHECK:         dealloc_stack [[STACK]]
// CHECK-LABEL: } // end sil function 'doDeleteLoadTake'
// CHECK-LABEL: end running test {{.*}} on doDeleteLoadTake
sil [ossa] @doDeleteLoadTake : $() -> () {
  %stack = alloc_stack $C
  %get = function_ref @get : $@convention(thin) <T> () -> (@out T)
  apply %get<C>(%stack) : $@convention(thin) <T> () -> (@out T)
  specify_test "deleter-delete-if-dead @instruction"
  %c = load [take] %stack : $*C
  destroy_value %c : $C
  dealloc_stack %stack : $*C
  %retval = tuple ()
  return %retval : $()
}