mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
OSSA modules are enabled by default. The compiler still accepts this option but it has no effect.
86 lines
3.5 KiB
Plaintext
86 lines
3.5 KiB
Plaintext
// 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-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)
|
|
}
|