@@ -16,6 +16,11 @@ enum Numerals {
1616 case Four
1717}
1818
19+ protocol P {
20+ mutating func foo()
21+ }
22+
23+ sil @createit : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@thick τ_0_0.Type) -> @out τ_0_0
1924sil @external_func: $@convention(thin) () -> ()
2025
2126//CHECK-LABEL: eliminate_sw_enum_addr
@@ -663,3 +668,38 @@ bb0(%0 : $S):
663668 return %11 : $()
664669}
665670
671+ // CHECK-LABEL: sil @dont_promote_existential_type_from_non_dominating_block :
672+ // Just check that this doesn't crash
673+ // CHECK: } // end sil function 'dont_promote_existential_type_from_non_dominating_block'
674+ sil @dont_promote_existential_type_from_non_dominating_block : $@convention(thin) (@thick any P.Type) -> () {
675+ bb0(%0 : $@thick any P.Type):
676+ %1 = alloc_stack $Optional<any P>
677+ cond_br undef, bb1, bb2
678+
679+ bb1:
680+ inject_enum_addr %1 : $*Optional<any P>, #Optional.none!enumelt
681+ br bb3
682+
683+ bb2:
684+ %5 = init_enum_data_addr %1 : $*Optional<any P>, #Optional.some!enumelt
685+ %6 = open_existential_metatype %0 : $@thick any P.Type to $@thick (@opened("B0100688-9C78-11EF-8A3C-4EA2A866E4C4", any P) Self).Type
686+ %7 = init_existential_addr %5 : $*any P, $@opened("B0100688-9C78-11EF-8A3C-4EA2A866E4C4", any P) Self
687+ %f = function_ref @createit : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@thick τ_0_0.Type) -> @out τ_0_0
688+ %a = apply %f<@opened("B0100688-9C78-11EF-8A3C-4EA2A866E4C4", any P) Self>(%7, %6) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@thick τ_0_0.Type) -> @out τ_0_0
689+ inject_enum_addr %1 : $*Optional<any P>, #Optional.some!enumelt
690+ br bb3
691+
692+ bb3:
693+ %9 = unchecked_take_enum_data_addr %1 : $*Optional<any P>, #Optional.some!enumelt
694+ dealloc_stack %1 : $*Optional<any P>
695+ %11 = alloc_stack [lexical] [var_decl] $any P, var, name "comp"
696+ copy_addr [take] %9 to [init] %11 : $*any P
697+ %13 = open_existential_addr mutable_access %11 : $*any P to $*@opened("36EE10D8-9C78-11EF-8A3C-4EA2A866E4C4", any P) Self
698+ %14 = witness_method $@opened("36EE10D8-9C78-11EF-8A3C-4EA2A866E4C4", any P) Self, #P.foo : <Self where Self : P> (inout Self) -> () -> (), %13 : $*@opened("36EE10D8-9C78-11EF-8A3C-4EA2A866E4C4", any P) Self : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> ()
699+ %15 = apply %14<@opened("36EE10D8-9C78-11EF-8A3C-4EA2A866E4C4", any P) Self>(%13) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@inout τ_0_0) -> ()
700+ destroy_addr %11 : $*any P
701+ dealloc_stack %11 : $*any P
702+ %18 = tuple ()
703+ return %18 : $()
704+ }
705+
0 commit comments