Files
swift-mirror/test/SILOptimizer/mandatory_inlining_open_existential.sil
Arnold Schwaighofer 876cea81ae SIL: Add an allowed access kind to the opened value of an open_existential_addr instruction
Once we move to a copy-on-write implementation of existential value buffers we
can no longer consume or destroy values of an opened existential unless the
buffer is uniquely owned.

Therefore we need to track the allowed operation on opened values.

Add qualifiers "mutable_access" and "immutable_access" to open_existential_addr
instructions to indicate the allowed access to the opened value.

Once we move to a copy-on-write implementation, an "open_existential_addr
mutable_access" instruction will ensure unique ownership of the value buffer.
2017-02-15 14:23:12 -08:00

46 lines
1.8 KiB
Plaintext

// RUN: %target-sil-opt -enable-sil-verify-all %s -mandatory-inlining
sil_stage raw
import Builtin
import Swift
import SwiftShims
protocol P {
func f7() -> () -> Self
}
sil hidden @caller : $@convention(thin) (@in P) -> () {
bb0(%0 : $*P):
%2 = open_existential_addr immutable_access %0 : $*P to $*@opened("214EF566-CD33-11E6-A1F0-34363BD08DA0") P
%3 = witness_method $@opened("214EF566-CD33-11E6-A1F0-34363BD08DA0") P, #P.f7!1, %2 : $*@opened("214EF566-CD33-11E6-A1F0-34363BD08DA0") P : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @owned @callee_owned () -> @out τ_0_0
%4 = apply %3<@opened("214EF566-CD33-11E6-A1F0-34363BD08DA0") P>(%2) : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @owned @callee_owned () -> @out τ_0_0
%5 = function_ref @callee : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned @callee_owned () -> @out τ_0_0) -> @out P
%6 = partial_apply %5<@opened("214EF566-CD33-11E6-A1F0-34363BD08DA0") P>(%4) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned @callee_owned () -> @out τ_0_0) -> @out P
%9 = alloc_stack $P
%8 = copy_value %6 : $@callee_owned () -> @out P
%10 = apply %8(%9) : $@callee_owned () -> @out P
destroy_addr %9 : $*P
dealloc_stack %9 : $*P
destroy_value %6 : $@callee_owned () -> @out P
destroy_addr %0 : $*P
%15 = tuple ()
return %15 : $()
}
sil hidden [transparent] @callee : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned @callee_owned () -> @out τ_0_0) -> @out P {
bb0(%0 : $*P, %1 : $@callee_owned () -> @out τ_0_0):
%2 = alloc_stack $τ_0_0
%3 = apply %1(%2) : $@callee_owned () -> @out τ_0_0
%4 = init_existential_addr %0 : $*P, $τ_0_0
copy_addr [take] %2 to [initialization] %4 : $*τ_0_0
%6 = tuple ()
dealloc_stack %2 : $*τ_0_0
return %6 : $()
}
sil_default_witness_table hidden P {
no_default
}