|
| 1 | +// RUN: %target-sil-opt -enable-sil-opaque-values -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all -generic-specializer %s | %FileCheck %s |
| 2 | + |
| 3 | +sil_stage canonical |
| 4 | + |
| 5 | +import Builtin |
| 6 | + |
| 7 | +// Test that foo is specialized on Builtin.Int64 and the copy_values and destroy_values are dropped. |
| 8 | +// |
| 9 | +// CHECK-LABEL: sil shared @_T03fooBi64__Tg5 : $@convention(thin) (Builtin.Int64, Builtin.Int64) -> () { |
| 10 | +// CHECK: bb0(%0 : $Builtin.Int64, %1 : $Builtin.Int64): |
| 11 | +// CHECK: [[F:%.*]] = function_ref @_T03fooBi64__Tg5 : $@convention(thin) (Builtin.Int64, Builtin.Int64) -> () |
| 12 | +// CHECK: %{{.*}} = apply [[F]](%0, %1) : $@convention(thin) (Builtin.Int64, Builtin.Int64) -> () |
| 13 | +// CHECK-NOT: copy_value |
| 14 | +// CHECK-NOT: destroy_value |
| 15 | +// CHECK: return %{{.*}} : $() |
| 16 | +// CHECK-LABEL: } // end sil function '_T03fooBi64__Tg5' |
| 17 | +sil hidden @foo : $@convention(thin) <T> (@in T, @in T) -> () { |
| 18 | +bb0(%0 : $T, %1 : $T): |
| 19 | + %f = function_ref @foo : $@convention(thin) <τ_0_0> (@in τ_0_0, @in τ_0_0) -> () |
| 20 | + %cp0 = copy_value %0 : $T |
| 21 | + %cp1 = copy_value %1 : $T |
| 22 | + %call = apply %f<T>(%cp0, %cp1) : $@convention(thin) <τ_0_0> (@in τ_0_0, @in τ_0_0) -> () |
| 23 | + destroy_value %1 : $T |
| 24 | + destroy_value %0 : $T |
| 25 | + %10 = tuple () |
| 26 | + return %10 : $() |
| 27 | +} |
| 28 | + |
| 29 | +sil @testSpecialize : $@convention(thin) (Builtin.Int64) -> () { |
| 30 | +bb0(%0: $Builtin.Int64): |
| 31 | + %f = function_ref @foo : $@convention(thin) <T> (@in T, @in T) -> () |
| 32 | + %call = apply %f<Builtin.Int64>(%0, %0) : $@convention(thin) <τ_0_0> (@in τ_0_0, @in τ_0_0) -> () |
| 33 | + %999 = tuple () |
| 34 | + return %999 : $() |
| 35 | +} |
0 commit comments