@@ -478,6 +478,46 @@ bb0(%0 : $Builtin.Int32, %1 : $<τ_0_0> { var τ_0_0 } <Builtin.Int32>):
478
478
return %7 : $()
479
479
}
480
480
481
+ // Check that we don't crash with this:
482
+ // CHECK-LABEL: sil @test_box_with_named_elements_tuple
483
+ sil @test_box_with_named_elements_tuple: $@convention(thin) () -> Builtin.Int32 {
484
+ bb0:
485
+ %0 = alloc_box ${ let (first: Builtin.Int32, second: Builtin.Int32) }
486
+ %0p = project_box %0 : ${ let (first: Builtin.Int32, second: Builtin.Int32) }, 0
487
+ %0a = tuple_element_addr %0p : $*(first: Builtin.Int32, second: Builtin.Int32), 0
488
+ %0b = tuple_element_addr %0p : $*(first: Builtin.Int32, second: Builtin.Int32), 1
489
+ %1 = integer_literal $Builtin.Int32, 0
490
+ store %1 to %0a : $*Builtin.Int32
491
+ store %1 to %0b : $*Builtin.Int32
492
+ %4 = function_ref @closure_with_named_elements_tuple : $@convention(thin) (Builtin.Int32, @owned { let (first: Builtin.Int32, second: Builtin.Int32) }) -> ()
493
+ strong_retain %0 : ${ let (first: Builtin.Int32, second: Builtin.Int32) }
494
+ %6 = partial_apply %4(%0) : $@convention(thin) (Builtin.Int32, @owned { let (first: Builtin.Int32, second: Builtin.Int32) }) -> ()
495
+ %7 = alloc_stack $Builtin.Int32
496
+ %9 = integer_literal $Builtin.Int32, 1
497
+ store %9 to %7 : $*Builtin.Int32
498
+ %12 = function_ref @$s4main5inneryys5Int32Vz_yADctF: $@convention(thin) (@inout Builtin.Int32, @owned @callee_owned (Builtin.Int32) -> ()) -> ()
499
+ strong_retain %6 : $@callee_owned (Builtin.Int32) -> ()
500
+ %14 = apply %12(%7, %6) : $@convention(thin) (@inout Builtin.Int32, @owned @callee_owned (Builtin.Int32) -> ()) -> ()
501
+ strong_release %6 : $@callee_owned (Builtin.Int32) -> ()
502
+ %16 = tuple ()
503
+ dealloc_stack %7 : $*Builtin.Int32
504
+ %18 = load %0a : $*Builtin.Int32
505
+ strong_release %0 : ${ let (first: Builtin.Int32, second: Builtin.Int32) }
506
+ return %18 : $Builtin.Int32
507
+ }
508
+
509
+ // CHECK-LABEL: sil shared @closure_with_named_elements_tuple
510
+ sil shared @closure_with_named_elements_tuple : $@convention(thin) (Builtin.Int32, @owned { let (first: Builtin.Int32, second: Builtin.Int32) }) -> () {
511
+ bb0(%0 : $Builtin.Int32, %1 : ${ let (first: Builtin.Int32, second: Builtin.Int32) }):
512
+ %3 = project_box %1 : ${ let (first: Builtin.Int32, second: Builtin.Int32) }, 0
513
+ %4 = tuple_element_addr %3 : $*(first: Builtin.Int32, second: Builtin.Int32), 0
514
+ store %0 to %4 : $*Builtin.Int32
515
+ strong_release %1 : ${ let (first: Builtin.Int32, second: Builtin.Int32) }
516
+ %7 = tuple ()
517
+ return %7 : $()
518
+ }
519
+
520
+
481
521
// The specialized function should always be a thin function, regardless of the
482
522
// representation of the original function.
483
523
0 commit comments