File: opaque_values_mandatory.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 (85 lines) | stat: -rw-r--r-- 3,560 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// RUN: %target-sil-opt -diagnostics -enable-sil-opaque-values %s | \
// RUN:     %target-sil-opt -Onone-performance -enable-sil-verify-all \
// RUN:                     -enable-sil-opaque-values -emit-sorted-sil \
// RUN:                     -enable-ossa-modules -enable-copy-propagation \
// RUN:                     -enable-lexical-borrow-scopes | \
// RUN:     %FileCheck %s
//
// These tests assume that opaque values are not lowered until OSSA lowering.
// REQUIRES: enable_opaque_values

import Builtin

sil_stage raw

typealias Int = Builtin.Int64

// CHECK-LABEL: sil hidden @f010_diagnose_identity : $@convention(thin) <T> (@in T) -> @out T {
// CHECK: bb0(%0 : $T):
// CHECK: return %0 : $T
// CHECK-LABEL: } // end sil function 'f010_diagnose_identity'
sil hidden [ossa] @f010_diagnose_identity : $@convention(thin) <T> (@in T) -> @out T {
bb0(%0 : @owned $T):
  %c = copy_value %0 : $T
  destroy_value %0 : $T
  return %c : $T
}

// Test lowerAssignment, createLoad, checkLoadInst, checkStoreInst.
// ---
// CHECK-LABEL: sil hidden @f020_assign_inout : $@convention(thin) <T> (@inout T, @in T) -> () {
// CHECK: bb0(%0 : $*T, %1 : $T):
// CHECK: %[[CPY:.*]] = copy_value %1 : $T
// CHECK: %[[LD:.*]] = load %0 : $*T
// CHECK: store %2 to %0 : $*T
// CHECK: destroy_value %[[LD]] : $T
// CHECK: destroy_value %1 : $T
// CHECK: return %{{.*}} : $()
// CHECK-LABEL: } // end sil function 'f020_assign_inout'
sil [ossa] @f020_assign_inout : $@convention(thin) <T> (@inout T, @in T) -> () {
bb0(%0 : $*T, %1 : @owned $T):
  %2 = copy_value %1 : $T
  assign %2 to %0 : $*T
  destroy_value %1 : $T
  %5 = tuple ()
  return %5 : $()
}

// Test returning an opaque tuple of tuples as a concrete tuple.
// ---
// CHECK-LABEL: sil @f030_callMultiResult : $@convention(thin) (Builtin.Int64) -> (Builtin.Int64, Builtin.Int64, Builtin.Int64) {
// CHECK: bb0(%0 : $Builtin.Int64):
// CHECK:   %1 = function_ref @f040_multiResult : $@convention(thin) <τ_0_0> (@in τ_0_0) -> (@out τ_0_0, @out τ_0_0, @out τ_0_0)
// CHECK:   %2 = apply %1<Builtin.Int64>(%0) : $@convention(thin) <τ_0_0> (@in τ_0_0) -> (@out τ_0_0, @out τ_0_0, @out τ_0_0)
// Note: the tuple construction is simplified away.
// CHECK:   return %2 : $(Builtin.Int64, Builtin.Int64, Builtin.Int64)
// CHECK-LABEL: } // end sil function 'f030_callMultiResult'
sil [ossa] @f030_callMultiResult : $@convention(thin) (Int) -> (Int, Int, Int) {
bb0(%0 : $Int):
  %1 = function_ref @f040_multiResult : $@convention(thin) <τ_0_0> (@in τ_0_0) -> (@out τ_0_0, @out τ_0_0, @out τ_0_0)
  %2 = apply %1<Int>(%0) : $@convention(thin) <τ_0_0> (@in τ_0_0) -> (@out τ_0_0, @out τ_0_0, @out τ_0_0)
  (%3, %4, %5) = destructure_tuple %2 : $(Int, Int, Int)
  %6 = tuple (%3 : $Int, %4 : $Int, %5 : $Int)
  return %6 : $(Int, Int, Int)
}

// Test returning an opaque tuple of tuples.
// ---
// CHECK-LABEL: sil [noinline] @f040_multiResult : $@convention(thin) <T> (@in T) -> (@out T, @out T, @out T) {
// CHECK: bb0(%0 : $T):
// CHECK:   %1 = copy_value %0 : $T
// CHECK:   %2 = copy_value %0 : $T
// CHECK:   %3 = copy_value %0 : $T
// CHECK:   destroy_value %0
// CHECK:   %5 = tuple (%1 : $T, %2 : $T, %3 : $T)
// CHECK:   return %5 : $(T, T, T)
// CHECK-LABEL: } // end sil function 'f040_multiResult'
sil [noinline] [ossa] @f040_multiResult : $@convention(thin) <T> (@in T) -> (@out T, @out T, @out T) {
bb0(%0 : @owned $T):
  %2 = copy_value %0 : $T
  %3 = copy_value %0 : $T
  %4 = copy_value %0 : $T
  destroy_value %0 : $T
  %6 = tuple (%2 : $T, %3 : $T, %4 : $T)
  return %6 : $(T, T, T)
}