Skip to content

Commit 90ec4a9

Browse files
committed
[6.0] Disable SILCombine::visitInjectEnumAddrInst for empty tuple types
1 parent b0ac3e0 commit 90ec4a9

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,16 @@ SILCombiner::visitInjectEnumAddrInst(InjectEnumAddrInst *IEAI) {
948948
if (IEAI->getFunction()->hasOwnership())
949949
return nullptr;
950950

951+
// Disable this for empty typle type because empty tuple stack locations maybe
952+
// uninitialized. And converting to value form loses tag information.
953+
if (IEAI->getElement()->hasAssociatedValues()) {
954+
SILType elemType = IEAI->getOperand()->getType().getEnumElementType(
955+
IEAI->getElement(), IEAI->getFunction());
956+
if (elemType.isEmpty(*IEAI->getFunction())) {
957+
return nullptr;
958+
}
959+
}
960+
951961
// Given an inject_enum_addr of a concrete type without payload, promote it to
952962
// a store of an enum. Mem2reg/load forwarding will clean things up for us. We
953963
// can't handle the payload case here due to the flow problems caused by the

test/SILOptimizer/sil_combine_enum_addr.sil

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ bb22:
260260
sil @no_init : $@convention(thin) () -> (@out ())
261261

262262
// CHECK-LABEL: sil @test_empty_tuple_uninintialized : $@convention(thin) () -> () {
263-
// CHECK-NOT: inject_enum_addr
263+
// TODO-NOT: inject_enum_addr
264264
// CHECK-LABEL: } // end sil function 'test_empty_tuple_uninintialized'
265265
sil @test_empty_tuple_uninintialized : $@convention(thin) () -> () {
266266
bb0:
@@ -287,7 +287,7 @@ bb3:
287287
sil @no_init_nested_tuple : $@convention(thin) () -> (@out ((), ()))
288288

289289
// CHECK-LABEL: sil @test_empty_nested_tuple_uninintialized : $@convention(thin) () -> () {
290-
// CHECK-NOT: inject_enum_addr
290+
// TODO-NOT: inject_enum_addr
291291
// CHECK-LABEL: } // end sil function 'test_empty_nested_tuple_uninintialized'
292292
sil @test_empty_nested_tuple_uninintialized : $@convention(thin) () -> () {
293293
bb0:
@@ -314,7 +314,7 @@ bb3:
314314
sil @no_init_struct : $@convention(thin) () -> (@out ResilientEmptyStruct)
315315

316316
// CHECK-LABEL: sil @test_empty_struct_uninitialized : $@convention(thin) () -> () {
317-
// CHECK-NOT: switch_enum_addr
317+
// TODO-NOT: switch_enum_addr
318318
// CHECK-LABEL: } // end sil function 'test_empty_struct_uninitialized'
319319
sil @test_empty_struct_uninitialized : $@convention(thin) () -> () {
320320
bb0:
@@ -340,7 +340,7 @@ bb3:
340340
sil @no_init_c_union : $@convention(thin) () -> (@out EmptyCUnion)
341341

342342
// CHECK-LABEL: sil @test_empty_c_union : $@convention(thin) () -> () {
343-
// CHECK: inject_enum_addr
343+
// TODO: inject_enum_addr
344344
// CHECK-LABEL: } // end sil function 'test_empty_c_union'
345345
sil @test_empty_c_union : $@convention(thin) () -> () {
346346
bb0:
@@ -370,7 +370,7 @@ struct NestedUnreferenceableStorage {
370370
sil @no_init_nested_c_union : $@convention(thin) () -> (@out NestedUnreferenceableStorage)
371371

372372
// CHECK-LABEL: sil @test_empty_nested_c_union : $@convention(thin) () -> () {
373-
// CHECK: inject_enum_addr
373+
// TODO: inject_enum_addr
374374
// CHECK-LABEL: } // end sil function 'test_empty_nested_c_union'
375375
sil @test_empty_nested_c_union : $@convention(thin) () -> () {
376376
bb0:

0 commit comments

Comments
 (0)