3
3
// RUN: -emit-module-path=%t/resilient_struct.swiftmodule \
4
4
// RUN: -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
5
5
6
- // RUN: %target-sil-opt -enable-sil-verify-all %s -sil-combine -jumpthread-simplify-cfg -I %t | %FileCheck %s
6
+ // RUN: %target-sil-opt -sdk %clang-importer-sdk-path - enable-sil-verify-all %s -sil-combine -jumpthread-simplify-cfg -I %t | %FileCheck %s
7
7
8
8
sil_stage canonical
9
9
10
10
import Builtin
11
11
import Swift
12
12
13
13
import resilient_struct
14
+ import ctypes
14
15
15
16
// CHECK-LABEL: sil @convert_inject_enum_addr_select_enum_addr_into_cond_br : $@convention(thin) (@in Int, @inout _Stdout) -> ()
16
17
// CHECK-NOT: init_existential_addr
47
48
br bb1
48
49
}
49
50
50
-
51
51
// CHECK-LABEL: sil @convert_inject_enum_addr_switch_enum_addr_into_cond_br : $@convention(thin) (@in Int, @inout _Stdout) -> ()
52
52
// CHECK-NOT: init_existential_addr
53
53
// CHECK-NOT: inject_enum_addr
@@ -122,7 +122,6 @@ bb22:
122
122
br bb2
123
123
}
124
124
125
-
126
125
class A {
127
126
128
127
}
@@ -314,10 +313,10 @@ bb3:
314
313
315
314
sil @no_init_struct : $@convention(thin) () -> (@out ResilientEmptyStruct)
316
315
317
- // CHECK-LABEL: sil @test_empty_struct_uninintialized : $@convention(thin) () -> () {
316
+ // CHECK-LABEL: sil @test_empty_struct_uninitialized : $@convention(thin) () -> () {
318
317
// CHECK-NOT: switch_enum_addr
319
- // CHECK-LABEL: } // end sil function 'test_empty_struct_uninintialized '
320
- sil @test_empty_struct_uninintialized : $@convention(thin) () -> () {
318
+ // CHECK-LABEL: } // end sil function 'test_empty_struct_uninitialized '
319
+ sil @test_empty_struct_uninitialized : $@convention(thin) () -> () {
321
320
bb0:
322
321
%0 = alloc_stack $Optional<ResilientEmptyStruct>
323
322
%1 = init_enum_data_addr %0 : $*Optional<ResilientEmptyStruct>, #Optional.some!enumelt
@@ -337,3 +336,29 @@ bb3:
337
336
%8 = tuple ()
338
337
return %8 : $()
339
338
}
339
+
340
+ sil @no_init_c_union : $@convention(thin) () -> (@out EmptyCUnion)
341
+
342
+ // CHECK-LABEL: sil @test_empty_c_union : $@convention(thin) () -> () {
343
+ // CHECK: inject_enum_addr
344
+ // CHECK-LABEL: } // end sil function 'test_empty_c_union'
345
+ sil @test_empty_c_union : $@convention(thin) () -> () {
346
+ bb0:
347
+ %0 = alloc_stack $Optional<EmptyCUnion>
348
+ %1 = init_enum_data_addr %0 : $*Optional<EmptyCUnion>, #Optional.some!enumelt
349
+ %f = function_ref @no_init_c_union : $@convention(thin) () -> (@out EmptyCUnion)
350
+ apply %f(%1) : $@convention(thin) () -> (@out EmptyCUnion)
351
+ inject_enum_addr %0 : $*Optional<EmptyCUnion>, #Optional.some!enumelt
352
+ switch_enum_addr %0 : $*Optional<EmptyCUnion>, case #Optional.some!enumelt: bb1, case #Optional.none!enumelt: bb2
353
+
354
+ bb1:
355
+ br bb3
356
+
357
+ bb2:
358
+ br bb3
359
+
360
+ bb3:
361
+ dealloc_stack %0 : $*Optional<EmptyCUnion>
362
+ %8 = tuple ()
363
+ return %8 : $()
364
+ }
0 commit comments