@@ -56,8 +56,10 @@ bb2: // Preds: bb0
56
56
57
57
// CHECK-LABEL: sil [ossa] @eliminate_select_enum_addr :
58
58
// CHECK-NOT: select_enum_addr
59
- // CHECK: [[BORROWED_VAL:%.*]] = load_borrow
60
- // CHECK: select_enum [[BORROWED_VAL]]
59
+ // CHECK-NOT: select_enum
60
+ // CHECK: switch_enum
61
+ // CHECK-NOT: select_enum_addr
62
+ // CHECK-NOT: select_enum
61
63
// CHECK: } // end sil function 'eliminate_select_enum_addr'
62
64
sil [ossa] @eliminate_select_enum_addr : $@convention(thin) () -> Int {
63
65
bb0:
@@ -278,11 +280,11 @@ bb2:
278
280
279
281
// Check the cond_br(select_enum) -> switch_enum conversion.
280
282
//
281
- // CHECK-LABEL: sil [ossa] @convert_select_enum_cond_br_to_switch_enum
282
- // XHECK -NOT: select_enum
283
- // XHECK : switch_enum
284
- // XHECK : return
285
-
283
+ // CHECK-LABEL: sil [ossa] @convert_select_enum_cond_br_to_switch_enum :
284
+ // CHECK -NOT: select_enum
285
+ // CHECK : switch_enum
286
+ // CHECK : return
287
+ // CHECK: } // end sil function 'convert_select_enum_cond_br_to_switch_enum'
286
288
sil [ossa] @convert_select_enum_cond_br_to_switch_enum : $@convention(thin) (@owned Optional<SomeClass>) -> Int {
287
289
bb0(%0 : @owned $Optional<SomeClass>):
288
290
%1 = integer_literal $Builtin.Int1, 0
@@ -304,13 +306,13 @@ bb2:
304
306
}
305
307
306
308
// Check that cond_br(select_enum) is converted into switch_enum.
307
- // CHECK-LABEL: sil [ossa] @convert_select_enum_cond_br_to_switch_enum2
308
- // XHECK : bb0
309
- // XHECK -NOT: select_enum
310
- // XHECK -NOT: return
311
- // XHECK : switch_enum %0 : $Numerals, case #Numerals.Two!enumelt: bb3, default bb2
312
- // XHECK : return
313
- // XHECK : }
309
+ // CHECK-LABEL: sil [ossa] @convert_select_enum_cond_br_to_switch_enum2 :
310
+ // CHECK : bb0
311
+ // CHECK -NOT: select_enum
312
+ // CHECK -NOT: return
313
+ // CHECK : switch_enum %0 : $Numerals, case #Numerals.Two!enumelt: bb3, default bb2
314
+ // CHECK : return
315
+ // CHECK : } // end sil function 'convert_select_enum_cond_br_to_switch_enum2'
314
316
sil [ossa] @convert_select_enum_cond_br_to_switch_enum2 : $@convention(thin) (Numerals) -> Builtin.Int64 {
315
317
bb0(%0 : $Numerals):
316
318
%2 = integer_literal $Builtin.Int1, 0
@@ -336,12 +338,12 @@ bb3:
336
338
// Check that cond_br(select_enum) is converted into switch_enum.
337
339
// This test checks that select_enum instructions with default cases are handled correctly.
338
340
// CHECK-LABEL: sil [ossa] @convert_select_enum_cond_br_to_switch_enum3
339
- // XHECK : bb0
340
- // XHECK -NOT: select_enum
341
- // XHECK -NOT: return
342
- // XHECK : switch_enum %0 : $Numerals, case #Numerals.Two!enumelt: bb3, default bb2
343
- // XHECK : return
344
- // XHECK : }
341
+ // CHECK : bb0
342
+ // CHECK -NOT: select_enum
343
+ // CHECK -NOT: return
344
+ // CHECK : switch_enum %0 : $Numerals, case #Numerals.Two!enumelt: bb3, default bb2
345
+ // CHECK : return
346
+ // CHECK : } // end sil function 'convert_select_enum_cond_br_to_switch_enum3'
345
347
sil [ossa] @convert_select_enum_cond_br_to_switch_enum3 : $@convention(thin) (Numerals) -> Builtin.Int64 {
346
348
bb0(%0 : $Numerals):
347
349
%2 = integer_literal $Builtin.Int1, 0
@@ -365,74 +367,12 @@ bb3:
365
367
br bb1
366
368
}
367
369
368
-
369
- // Check that cond_br(select_enum) is not converted into switch_enum as it would create a critical edge, which
370
- // is not originating from cond_br/br. And this is forbidden in a canonical SIL form.
371
- //
372
- // CHECK-LABEL: sil [ossa] @dont_convert_select_enum_cond_br_to_switch_enum
373
- // XHECK: select_enum
374
- // XHECK-NOT: switch_enum
375
- // XHECK: return
376
- sil [ossa] @dont_convert_select_enum_cond_br_to_switch_enum : $@convention(thin) (@owned Optional<SomeClass>) -> Int {
377
- bb0(%0 : @owned $Optional<SomeClass>):
378
- %2 = integer_literal $Builtin.Int1, 0
379
- %3 = integer_literal $Builtin.Int1, -1
380
- %4 = select_enum %0 : $Optional<SomeClass>, case #Optional.none!enumelt: %3, case #Optional.some!enumelt: %2 : $Builtin.Int1
381
- cond_br %4, bb2, bb1a
382
-
383
- bb1a:
384
- br bb1
385
-
386
- bb1:
387
- %5 = unchecked_enum_data %0 : $Optional<SomeClass>, #Optional.some!enumelt
388
- %6 = class_method %5 : $SomeClass, #SomeClass.hash : (SomeClass) -> () -> Int, $@convention(method) (@guaranteed SomeClass) -> Int
389
- %7 = apply %6(%5) : $@convention(method) (@guaranteed SomeClass) -> Int
390
- fix_lifetime %5 : $SomeClass
391
- destroy_value %5 : $SomeClass
392
- return %7 : $Int
393
-
394
- bb2:
395
- %10 = function_ref @external_func: $@convention(thin) () -> ()
396
- apply %10(): $@convention(thin) () -> ()
397
- br bb1
398
- }
399
-
400
- // Check that cond_br(select_enum) is not converted into switch_enum as it would create a critical edge, which
401
- // is not originating from cond_br/br. And this is forbidden in a canonical SIL form.
402
- //
403
- // CHECK-LABEL: sil [ossa] @dont_convert_select_enum_cond_br_to_switch_enum2
404
- // XHECK: select_enum
405
- // XHECK-NOT: switch_enum
406
- // XHECK: return
407
- sil [ossa] @dont_convert_select_enum_cond_br_to_switch_enum2 : $@convention(thin) (Numerals) -> Builtin.Int64 {
408
- bb0(%0 : $Numerals):
409
- %2 = integer_literal $Builtin.Int1, 0
410
- %3 = integer_literal $Builtin.Int1, -1
411
- // There are two cases for each possible outcome.
412
- // This means that we would always get a critical edge, if we convert it into a switch_enum.
413
- %4 = select_enum %0 : $Numerals, case #Numerals.One!enumelt: %3, case #Numerals.Two!enumelt: %2, case #Numerals.Three!enumelt: %3, case #Numerals.Four!enumelt: %2 : $Builtin.Int1
414
-
415
- cond_br %4, bb2, bb3
416
-
417
- bb1:
418
- %7 = integer_literal $Builtin.Int64, 10
419
- return %7 : $Builtin.Int64
420
-
421
- bb2:
422
- %10 = function_ref @external_func: $@convention(thin) () -> ()
423
- apply %10(): $@convention(thin) () -> ()
424
- br bb1
425
-
426
- bb3:
427
- br bb1
428
- }
429
-
430
370
// Check that cond_br(select_enum) is not converted into switch_enum,
431
371
// because the result of the default case is not an integer literal.
432
- // CHECK-LABEL: sil [ossa] @dont_convert_select_enum_cond_br_to_switch_enum3
433
- // XHECK : select_enum
434
- // XHECK -NOT: switch_enum
435
- // XHECK: return
372
+ // CHECK-LABEL: sil [ossa] @dont_convert_select_enum_cond_br_to_switch_enum3 :
373
+ // CHECK : select_enum
374
+ // CHECK -NOT: switch_enum
375
+ // CHECK: } // end sil function 'dont_convert_select_enum_cond_br_to_switch_enum3'
436
376
sil [ossa] @dont_convert_select_enum_cond_br_to_switch_enum3 : $@convention(thin) (Numerals, Builtin.Int1) -> Builtin.Int64 {
437
377
bb0(%0 : $Numerals, %1 : $Builtin.Int1):
438
378
%2 = integer_literal $Builtin.Int1, 0
@@ -478,33 +418,33 @@ public enum Y {
478
418
// the types involved, and we'll generate a trap at IRGen-time if the
479
419
// bitcasted types are not the same size.
480
420
481
- // CHECK-LABEL: sil [ossa] @keep_unchecked_enum_data
482
- // TODO: Fix
421
+ // CHECK-LABEL: sil [ossa] @keep_unchecked_enum_data :
422
+ // CHECK: bb0
423
+ // CHECK: [[CAST:%.*]] = unchecked_bitwise_cast %0 : $X to $Y
424
+ // CHECK: bb1
425
+ // CHECK: bb2
426
+ // CHECK: bb3
427
+ // CHECK: return
428
+ // CHECK: } // end sil function 'keep_unchecked_enum_data'
483
429
sil [ossa] @keep_unchecked_enum_data : $@convention(thin) (@owned X, @owned T) -> @owned T {
484
- // XHECK: bb0
485
430
bb0(%0 : @owned $X, %1 : @owned $T):
486
- // XHECK: [[CAST:%.*]] = unchecked_bitwise_cast %0 : $X to $Y
487
431
%4 = unchecked_bitwise_cast %0 : $X to $Y
488
432
%5 = copy_value %4 : $Y
489
433
switch_enum %5 : $Y, case #Y.none!enumelt: bb1, case #Y.some!enumelt: bb2
490
434
491
- // XHECK: bb1
492
435
bb1:
493
436
(%7, %8) = destructure_struct %1 : $T
494
437
br bb3(%7 : $C)
495
438
496
- // XHECK: bb2
497
439
bb2(%10 : @owned $T):
498
440
(%12a, %12b) = destructure_struct %10 : $T
499
441
destroy_value %1 : $T
500
442
br bb3(%12a : $C)
501
443
502
- // XHECK: bb3
503
444
bb3(%14 : @owned $C):
504
445
%15 = struct $S ()
505
446
%16 = struct $T (%14 : $C, %15 : $S)
506
447
destroy_value %0 : $X
507
- // XHECK: return
508
448
return %16 : $T
509
449
}
510
450
0 commit comments