|
| 1 | +// RUN: %target-swift-frontend -emit-ir %s -enable-experimental-feature VariadicGenerics | %FileCheck %s -DINT=i%target-ptrsize |
| 2 | + |
| 3 | +// Because of -enable-experimental-feature VariadicGenerics |
| 4 | +// REQUIRES: asserts |
| 5 | + |
| 6 | +public func has_metadata_pack<each T>(t: repeat each T) -> () -> () { |
| 7 | + return { _ = (repeat each T).self } |
| 8 | +} |
| 9 | + |
| 10 | +// CHECK-LABEL: define{{( protected)?}}{{( dllexport)?}} swiftcc { i8*, %swift.refcounted* } @"$s25variadic_generic_captures17has_metadata_pack1tyycxxQp_tRvzlF"(%swift.opaque** noalias nocapture %0, i64 %1, %swift.type** %T) #0 { |
| 11 | +// CHECK: [[CONTEXT0:%.*]] = call noalias %swift.refcounted* @swift_allocObject( |
| 12 | +// CHECK: [[CONTEXT:%.*]] = bitcast %swift.refcounted* [[CONTEXT0]] to <{{.*}}>* |
| 13 | + |
| 14 | +// CHECK: [[GENERIC_ARGS_ADDR:%.*]] = getelementptr inbounds {{.*}}* [[CONTEXT]], i32 0, i32 {{(1|2)}} |
| 15 | +// CHECK: [[GENERIC_ARGS:%.*]] = bitcast {{.*}} [[GENERIC_ARGS_ADDR]] to %swift.type** |
| 16 | +// CHECK: [[SHAPE_PTR:%.*]] = bitcast %swift.type** [[GENERIC_ARGS]] to [[INT]]* |
| 17 | +// CHECK: store [[INT]] %1, [[INT]]* [[SHAPE_PTR]] |
| 18 | + |
| 19 | +// CHECK: [[T_ADDR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[GENERIC_ARGS]], i32 1 |
| 20 | +// CHECK: [[T_ADDR2:%.*]] = bitcast %swift.type** [[T_ADDR]] to %swift.type*** |
| 21 | +// CHECK: store %swift.type** %T, %swift.type*** [[T_ADDR2]] |
| 22 | + |
| 23 | +// CHECK: [[CONTEXT1:%.*]] = insertvalue {{.*}} @"$s25variadic_generic_captures17has_metadata_pack1tyycxxQp_tRvzlFyycfU_TA" |
| 24 | +// CHECK: ret { i8*, %swift.refcounted* } [[CONTEXT1]] |
| 25 | + |
| 26 | +// CHECK-LABEL: define internal swiftcc void @"$s25variadic_generic_captures17has_metadata_pack1tyycxxQp_tRvzlFyycfU_TA"(%swift.refcounted* swiftself %0) |
| 27 | +// CHECK: [[CONTEXT:%.*]] = bitcast %swift.refcounted* %0 to {{.*}}* |
| 28 | +// CHECK: [[GENERIC_ARGS_ADDR:%.*]] = getelementptr inbounds {{.*}}* [[CONTEXT]], i32 0, i32 {{(1|2)}} |
| 29 | +// CHECK: [[GENERIC_ARGS:%.*]] = bitcast {{.*}} to %swift.type** |
| 30 | + |
| 31 | +// CHECK: [[SHAPE_PTR:%.*]] = bitcast %swift.type** [[GENERIC_ARGS]] to [[INT]]* |
| 32 | +// CHECK: [[SHAPE:%.*]] = load [[INT]], [[INT]]* [[SHAPE_PTR]] |
| 33 | + |
| 34 | +// CHECK: [[T_ADDR:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[GENERIC_ARGS]], i32 1 |
| 35 | +// CHECK: [[T_PTR:%.*]] = bitcast %swift.type** [[T_ADDR]] to %swift.type*** |
| 36 | +// CHECK: [[T:%.*]] = load %swift.type**, %swift.type*** [[T_PTR]] |
| 37 | + |
| 38 | +// CHECK: tail call swiftcc void @"$s25variadic_generic_captures17has_metadata_pack1tyycxxQp_tRvzlFyycfU_"([[INT]] [[SHAPE]], %swift.type** [[T]]) |
| 39 | +// CHECK: ret void |
| 40 | + |
| 41 | +public func has_witness_table_pack<each T: Sequence>(t: repeat each T) -> () -> () { |
| 42 | + return { _ = (repeat (each T).Element).self } |
| 43 | +} |
| 44 | + |
| 45 | +public func has_witness_table_pack2<each T: Sequence>(t: repeat each T) -> () -> () |
| 46 | + where each T.Element: Sequence { |
| 47 | + return { _ = (repeat (each T).Element.Element).self } |
| 48 | +} |
0 commit comments