Files
swift-mirror/validation-test/SIL/crashers/cse-open-existential-ref-term-inst.sil
Anthony Latsis d650ce47f3 SILOptimizer: Fix some issues with CSE of open_existential_ref
* A direct user might have a dependent result
* An indirect user can also be a terminator instruction
2023-03-13 21:41:02 +03:00

28 lines
1.4 KiB
Plaintext

// RUN: not --crash %target-sil-opt -enable-sil-verify-all %s -cse
// Move this test case to 'test/SILOptimizer/cse_open_existential_ref.sil' once
// it is fixed.
import Builtin
import Swift
protocol P {}
sil @test_br_use : $@convention(thin) (@guaranteed any P) -> () {
bb0(%p : $any P):
%blackhole = function_ref @blackhole : $@convention(thin) <τ_0_0> (@guaranteed τ_0_0) -> ()
%opened1 = open_existential_ref %p : $any P to $@opened("00000000-0000-0000-0000-000000000009", any P) Self
// Don't let the first opened existential get optimized away.
%void1 = apply %blackhole<@opened("00000000-0000-0000-0000-000000000009", any P) Self>(%opened1) : $@convention(thin) <τ_0_0> (@guaranteed τ_0_0) -> ()
%opened2 = open_existential_ref %p : $any P to $@opened("00000000-0000-0000-0000-000000000010", any P) Self
br bb1(%opened2 : $@opened("00000000-0000-0000-0000-000000000010", any P) Self)
bb1(%arg : $@opened("00000000-0000-0000-0000-000000000010", any P) Self):
%optional = enum $Optional<@opened("00000000-0000-0000-0000-000000000010", any P) Self>, #Optional.some!enumelt, %arg : $@opened("00000000-0000-0000-0000-000000000010", any P) Self
%void2 = apply %blackhole<Optional<@opened("00000000-0000-0000-0000-000000000010", any P) Self>>(%optional) : $@convention(thin) <τ_0_0> (@guaranteed τ_0_0) -> ()
%result = tuple ()
return %result : $()
}