@@ -474,3 +474,59 @@ bb0:
474
474
%tuple = tuple()
475
475
return %tuple : $()
476
476
}
477
+
478
+ sil private [dynamically_replacable] @closure0_guaranteed2 : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <Foo>, @guaranteed <τ_0_0> { var τ_0_0 } <Baz>, @guaranteed <τ_0_0> { var τ_0_0 } <Int>) -> Int {
479
+ bb0(%0 : $<τ_0_0> { var τ_0_0 } <Foo>, %2 : $<τ_0_0> { var τ_0_0 } <Baz>, %4 : $<τ_0_0> { var τ_0_0 } <Int>):
480
+ %1 = project_box %0 : $<τ_0_0> { var τ_0_0 } <Foo>, 0
481
+ %3 = project_box %2 : $<τ_0_0> { var τ_0_0 } <Baz>, 0
482
+ %5 = project_box %4 : $<τ_0_0> { var τ_0_0 } <Int>, 0
483
+ %6 = tuple ()
484
+ %7 = function_ref @dummy_func : $@convention(thin) (Int, Int, Int) -> Int
485
+ %8 = load %1 : $*Foo
486
+ strong_retain %8 : $Foo
487
+ %10 = class_method %8 : $Foo, #Foo.foo!1 : (Foo) -> () -> Int, $@convention(method) (@guaranteed Foo) -> Int
488
+ %11 = apply %10(%8) : $@convention(method) (@guaranteed Foo) -> Int
489
+ %12 = struct_element_addr %3 : $*Baz, #Baz.x
490
+ %13 = load %12 : $*Int
491
+ %14 = load %5 : $*Int
492
+ %15 = apply %7(%11, %13, %14) : $@convention(thin) (Int, Int, Int) -> Int
493
+ return %15 : $Int
494
+ }
495
+
496
+ // This should not crash.
497
+ sil @test_capture_promotion_dynamic_function_ref : $@convention(thin) () -> () {
498
+ bb0:
499
+ %0 = tuple ()
500
+ %1 = alloc_box $<τ_0_0> { var τ_0_0 } <Foo>
501
+ %1a = project_box %1 : $<τ_0_0> { var τ_0_0 } <Foo>, 0
502
+ %2 = function_ref @foo_allocating_init : $@convention(thin) (@thick Foo.Type) -> @owned Foo
503
+ %3 = metatype $@thick Foo.Type
504
+ %4 = apply %2(%3) : $@convention(thin) (@thick Foo.Type) -> @owned Foo
505
+ store %4 to %1a : $*Foo
506
+ %6 = alloc_box $<τ_0_0> { var τ_0_0 } <Baz>
507
+ %6a = project_box %6 : $<τ_0_0> { var τ_0_0 } <Baz>, 0
508
+ %7 = function_ref @baz_init : $@convention(thin) (@thin Baz.Type) -> @owned Baz
509
+ %8 = metatype $@thin Baz.Type
510
+ %9 = apply %7(%8) : $@convention(thin) (@thin Baz.Type) -> @owned Baz
511
+ store %9 to %6a : $*Baz
512
+ %11 = alloc_box $<τ_0_0> { var τ_0_0 } <Int>
513
+ %11a = project_box %11 : $<τ_0_0> { var τ_0_0 } <Int>, 0
514
+ %12 = function_ref @convert_from_integer_literal : $@convention(thin) (Builtin.Word, @thin Int.Type) -> Int
515
+ %13 = metatype $@thin Int.Type
516
+ %14 = integer_literal $Builtin.Word, 3
517
+ %15 = apply %12(%14, %13) : $@convention(thin) (Builtin.Word, @thin Int.Type) -> Int
518
+ store %15 to %11a : $*Int
519
+
520
+ %17 = dynamic_function_ref @closure0_guaranteed2 : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <Foo>, @guaranteed <τ_0_0> { var τ_0_0 } <Baz>, @guaranteed <τ_0_0> { var τ_0_0 } <Int>) -> Int
521
+ %21 = partial_apply [callee_guaranteed] [on_stack] %17(%1, %6, %11) : $@convention(thin) (@guaranteed <τ_0_0> { var τ_0_0 } <Foo>, @guaranteed <τ_0_0> { var τ_0_0 } <Baz>, @guaranteed <τ_0_0> { var τ_0_0 } <Int>) -> Int
522
+ %md = mark_dependence %21 :$@noescape @callee_guaranteed () -> Int on %1 : $<τ_0_0> { var τ_0_0 } <Foo>
523
+ %md2 = mark_dependence %md :$@noescape @callee_guaranteed () -> Int on %6 : $<τ_0_0> { var τ_0_0 } <Baz>
524
+ %md3 = mark_dependence %md2 :$@noescape @callee_guaranteed () -> Int on %11 : $<τ_0_0> { var τ_0_0 } <Int>
525
+ apply %md3() : $@noescape @callee_guaranteed () -> Int
526
+ dealloc_stack %21 : $@noescape @callee_guaranteed () -> Int
527
+ strong_release %11 : $<τ_0_0> { var τ_0_0 } <Int>
528
+ strong_release %6 : $<τ_0_0> { var τ_0_0 } <Baz>
529
+ strong_release %1 : $<τ_0_0> { var τ_0_0 } <Foo>
530
+ %tuple = tuple()
531
+ return %tuple : $()
532
+ }
0 commit comments