1- // RUN: %target-sil-opt -enable-sil-verify-all %s -sil-combine -jumpthread-simplify-cfg | %FileCheck %s
1+ // RUN: %empty-directory(%t)
2+ // RUN: %target-swift-frontend -emit-module -enable-library-evolution \
3+ // RUN: -emit-module-path=%t/resilient_struct.swiftmodule \
4+ // RUN: -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
5+
6+ // RUN: %target-sil-opt -enable-sil-verify-all %s -sil-combine -jumpthread-simplify-cfg -I %t | %FileCheck %s
27
38sil_stage canonical
49
510import Builtin
611import Swift
712
13+ import resilient_struct
14+
815// CHECK-LABEL: sil @convert_inject_enum_addr_select_enum_addr_into_cond_br : $@convention(thin) (@in Int, @inout _Stdout) -> ()
916// CHECK-NOT: init_existential_addr
1017// CHECK-NOT: inject_enum_addr
@@ -254,8 +261,7 @@ bb22:
254261sil @no_init : $@convention(thin) () -> (@out ())
255262
256263// CHECK-LABEL: sil @test_empty_tuple_uninintialized : $@convention(thin) () -> () {
257- // CHECK: init_enum_data_addr
258- // CHECK: inject_enum_addr
264+ // CHECK-NOT: inject_enum_addr
259265// CHECK-LABEL: } // end sil function 'test_empty_tuple_uninintialized'
260266sil @test_empty_tuple_uninintialized : $@convention(thin) () -> () {
261267bb0:
@@ -279,3 +285,55 @@ bb3:
279285 return %8 : $()
280286}
281287
288+ sil @no_init_nested_tuple : $@convention(thin) () -> (@out ((), ()))
289+
290+ // CHECK-LABEL: sil @test_empty_nested_tuple_uninintialized : $@convention(thin) () -> () {
291+ // CHECK-NOT: inject_enum_addr
292+ // CHECK-LABEL: } // end sil function 'test_empty_nested_tuple_uninintialized'
293+ sil @test_empty_nested_tuple_uninintialized : $@convention(thin) () -> () {
294+ bb0:
295+ %0 = alloc_stack $Optional<((), ())>
296+ %1 = init_enum_data_addr %0 : $*Optional<((), ())>, #Optional.some!enumelt
297+ %f = function_ref @no_init_nested_tuple : $@convention(thin) () -> (@out ((), ()))
298+ apply %f(%1) : $@convention(thin) () -> (@out ((), ()))
299+ inject_enum_addr %0 : $*Optional<((), ())>, #Optional.some!enumelt
300+ %2 = load %0 : $*Optional<((), ())>
301+ switch_enum %2 : $Optional<((), ())>, case #Optional.some!enumelt: bb1, case #Optional.none!enumelt: bb2
302+
303+ bb1(%4 : $((), ())):
304+ br bb3
305+
306+ bb2:
307+ br bb3
308+
309+ bb3:
310+ dealloc_stack %0 : $*Optional<((), ())>
311+ %8 = tuple ()
312+ return %8 : $()
313+ }
314+
315+ sil @no_init_struct : $@convention(thin) () -> (@out ResilientEmptyStruct)
316+
317+ // CHECK-LABEL: sil @test_empty_struct_uninintialized : $@convention(thin) () -> () {
318+ // CHECK-NOT: switch_enum_addr
319+ // CHECK-LABEL: } // end sil function 'test_empty_struct_uninintialized'
320+ sil @test_empty_struct_uninintialized : $@convention(thin) () -> () {
321+ bb0:
322+ %0 = alloc_stack $Optional<ResilientEmptyStruct>
323+ %1 = init_enum_data_addr %0 : $*Optional<ResilientEmptyStruct>, #Optional.some!enumelt
324+ %f = function_ref @no_init_struct : $@convention(thin) () -> (@out ResilientEmptyStruct)
325+ apply %f(%1) : $@convention(thin) () -> (@out ResilientEmptyStruct)
326+ inject_enum_addr %0 : $*Optional<ResilientEmptyStruct>, #Optional.some!enumelt
327+ switch_enum_addr %0 : $*Optional<ResilientEmptyStruct>, case #Optional.some!enumelt: bb1, case #Optional.none!enumelt: bb2
328+
329+ bb1:
330+ br bb3
331+
332+ bb2:
333+ br bb3
334+
335+ bb3:
336+ dealloc_stack %0 : $*Optional<ResilientEmptyStruct>
337+ %8 = tuple ()
338+ return %8 : $()
339+ }
0 commit comments