Skip to content

Commit d78dc03

Browse files
committed
[metadata prespecialization] Specialize VWTs.
Prespecialized metadata records must refer to value witness tables that have correct values for size and stride. In order to do that, a prespecialized value witness table must emitted and referred to. Here, a fully specialized value witness table is emitted. For the moment, the value witness table is fully specialized. Having it be specialized, though, will likely cause serious code size problems, since it results in specialized value witness functions being generated. rdar://problem/58088270
1 parent 686c49a commit d78dc03

File tree

32 files changed

+366
-222
lines changed

32 files changed

+366
-222
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4069,10 +4069,6 @@ Optional<llvm::Function*> IRGenModule::getAddrOfIVarInitDestroy(
40694069
llvm::Function *IRGenModule::getAddrOfValueWitness(CanType abstractType,
40704070
ValueWitness index,
40714071
ForDefinition_t forDefinition) {
4072-
// We shouldn't emit value witness symbols for generic type instances.
4073-
assert(!isa<BoundGenericType>(abstractType) &&
4074-
"emitting value witness for generic type instance?!");
4075-
40764072
LinkEntity entity = LinkEntity::forValueWitness(abstractType, index);
40774073

40784074
llvm::Function *&entry = GlobalFuncs[entity];

lib/IRGen/GenMeta.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3740,10 +3740,12 @@ namespace {
37403740

37413741
SILType getLoweredType() { return SILType::getPrimitiveObjectType(type); }
37423742

3743+
ConstantReference emitValueWitnessTable(bool relativeReference) {
3744+
return irgen::emitValueWitnessTable(IGM, type, false, relativeReference);
3745+
}
3746+
37433747
ConstantReference getValueWitnessTable(bool relativeReference) {
3744-
auto type = this->Target->getDeclaredType()->getCanonicalType();
3745-
return ConstantReference(IGM.getAddrOfEffectiveValueWitnessTable(type),
3746-
irgen::ConstantReference::Direct);
3748+
return emitValueWitnessTable(relativeReference);
37473749
}
37483750

37493751
void addGenericArgument(GenericRequirement requirement) {

lib/IRGen/GenValueWitness.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,10 +1038,6 @@ ConstantReference irgen::emitValueWitnessTable(IRGenModule &IGM,
10381038
CanType abstractType,
10391039
bool isPattern,
10401040
bool relativeReference) {
1041-
// We shouldn't emit global value witness tables for generic type instances.
1042-
assert(!isa<BoundGenericType>(abstractType) &&
1043-
"emitting VWT for generic instance");
1044-
10451041
// See if we can use a prefab witness table from the runtime.
10461042
if (!isPattern) {
10471043
if (auto known = getAddrOfKnownValueWitnessTable(IGM, abstractType,

test/IRGen/prespecialized-metadata/class-inmodule-0argument-within-class-1argument-1distinct_use.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// RUN: %swift -target %module-target-future -parse-stdlib -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s
1+
// RUN: %swift -target %module-target-future -parse-stdlib -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment
2+
3+
// UNSUPPORTED: CPU=i386 && OS=ios
4+
// UNSUPPORTED: CPU=armv7 && OS=ios
5+
// UNSUPPORTED: CPU=armv7s && OS=ios
26

37
precedencegroup AssignmentPrecedence {}
48

@@ -18,7 +22,7 @@ func consume<T>(_ t: T) {
1822

1923
// CHECK: define hidden swiftcc void @"$s4main4doityyF"() #{{[0-9]+}} {
2024
// CHECK: entry:
21-
// CHECK: [[METADATA_RESPONSE:%[0-9]+]] = call swiftcc %swift.metadata_response @"$s4main9NamespaceCA2A4ZangCRszlE19ExtensionNonGenericCyAE_GMa"(i64 0) #{{[0-9]+}}
25+
// CHECK: [[METADATA_RESPONSE:%[0-9]+]] = call swiftcc %swift.metadata_response @"$s4main9NamespaceCA2A4ZangCRszlE19ExtensionNonGenericCyAE_GMa"([[INT]] 0) #{{[0-9]+}}
2226
// CHECK: [[METADATA:%[0-9]+]] = extractvalue %swift.metadata_response [[METADATA_RESPONSE]], 0
2327
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture %5, %swift.type* [[METADATA]])
2428
// CHECK: }
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
// RUN: %swift -target %module-target-future -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s
1+
// RUN: %swift -target %module-target-future -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment
22

3-
// CHECK: @"$s4main5Value[[UNIQUE_ID_1:[0-9A-Z_]+]]VySiGMf" = internal constant <{ i8**, i64, %swift.type_descriptor*, %swift.type*, i32, [4 x i8], i64 }> <{ i8** getelementptr inbounds (%swift.vwtable, %swift.vwtable* @"$s4main5Value[[UNIQUE_ID_1]]VWV", i32 0, i32 0), i64 512, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main5Value[[UNIQUE_ID_1]]VMn" to %swift.type_descriptor*), %swift.type* @"$sSiN", i32 0, [4 x i8] zeroinitializer, i64 3 }>, align 8
3+
// UNSUPPORTED: CPU=i386 && OS=ios
4+
// UNSUPPORTED: CPU=armv7 && OS=ios
5+
// UNSUPPORTED: CPU=armv7s && OS=ios
6+
7+
// CHECK: @"$sB[[INT]]_WV" = external global i8*, align [[ALIGNMENT]]
8+
// CHECK: @"$s4main5Value[[UNIQUE_ID_1:[0-9A-Z_]+]]VySiGMf" = internal constant <{ i8**, [[INT]], %swift.type_descriptor*, %swift.type*, i32{{(, \[4 x i8\])?}}, i64 }> <{ i8** @"$sB[[INT]]_WV", [[INT]] 512, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main5Value[[UNIQUE_ID_1:[0-9A-Z_]+]]VMn" to %swift.type_descriptor*), %swift.type* @"$sSiN", i32 0{{(, \[4 x i8\] zeroinitializer)?}}, i64 3 }>, align [[ALIGNMENT]]
49
fileprivate struct Value<First> {
510
let first: First
611
}
@@ -12,15 +17,15 @@ func consume<T>(_ t: T) {
1217
}
1318

1419
// CHECK: define hidden swiftcc void @"$s4main4doityyF"() #{{[0-9]+}} {
15-
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture %{{[0-9]+}}, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, i64, %swift.type_descriptor*, %swift.type*, i32, [4 x i8], i64 }>* @"$s4main5Value[[UNIQUE_ID_1]]VySiGMf" to %swift.full_type*), i32 0, i32 1))
20+
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture %{{[0-9]+}}, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, [[INT]], %swift.type_descriptor*, %swift.type*, i32{{(, \[4 x i8\])?}}, i64 }>* @"$s4main5Value[[UNIQUE_ID_1]]VySiGMf" to %swift.full_type*), i32 0, i32 1))
1621
// CHECK: }
1722
func doit() {
1823
consume( Value(first: 13) )
1924
}
2025
doit()
2126

2227
// CHECK: ; Function Attrs: noinline nounwind readnone
23-
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]VMa"(i64, %swift.type*) #{{[0-9]+}} {
28+
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]VMa"([[INT]], %swift.type*) #{{[0-9]+}} {
2429
// CHECK: entry:
2530
// CHECK: [[ERASED_TYPE:%[0-9]+]] = bitcast %swift.type* %1 to i8*
2631
// CHECK: br label %[[TYPE_COMPARISON_LABEL:[0-9]+]]
@@ -29,8 +34,8 @@ doit()
2934
// CHECK: [[EQUAL_TYPES:%[0-9]+]] = and i1 true, [[EQUAL_TYPE]]
3035
// CHECK: br i1 [[EQUAL_TYPES]], label %[[EXIT_PRESPECIALIZED:[0-9]+]], label %[[EXIT_NORMAL:[0-9]+]]
3136
// CHECK: [[EXIT_PRESPECIALIZED]]:
32-
// CHECK: ret %swift.metadata_response { %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, i64, %swift.type_descriptor*, %swift.type*, i32, [4 x i8], i64 }>* @"$s4main5Value[[UNIQUE_ID_1]]VySiGMf" to %swift.full_type*), i32 0, i32 1), i64 0 }
37+
// CHECK: ret %swift.metadata_response { %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, [[INT]], %swift.type_descriptor*, %swift.type*, i32{{(, \[4 x i8\])?}}, i64 }>* @"$s4main5Value[[UNIQUE_ID_1]]VySiGMf" to %swift.full_type*), i32 0, i32 1), [[INT]] 0 }
3338
// CHECK: [[EXIT_NORMAL]]:
34-
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateGenericMetadata(i64 %0, i8* [[ERASED_TYPE]], i8* undef, i8* undef, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main5Value[[UNIQUE_ID_1]]VMn" to %swift.type_descriptor*)) #{{[0-9]+}}
39+
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateGenericMetadata([[INT]] %0, i8* [[ERASED_TYPE]], i8* undef, i8* undef, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main5Value[[UNIQUE_ID_1]]VMn" to %swift.type_descriptor*)) #{{[0-9]+}}
3540
// CHECK: ret %swift.metadata_response {{%[0-9]+}}
3641
// CHECK: }

test/IRGen/prespecialized-metadata/struct-inmodule-0argument-within-class-1argument-1distinct_use.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
// RUN: %swift -target %module-target-future -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s
1+
// RUN: %swift -target %module-target-future -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment
22

3-
// CHECK: @"$s4main9NamespaceC5ValueVySi_GMf" = internal constant <{ i8**, i64, %swift.type_descriptor*, %swift.type*, i32, [4 x i8], i64 }> <{ i8** getelementptr inbounds (%swift.vwtable, %swift.vwtable* @"$s4main9NamespaceC5ValueVWV", i32 0, i32 0), i64 512, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main9NamespaceC5ValueVMn" to %swift.type_descriptor*), %swift.type* @"$sSiN", i32 0, [4 x i8] zeroinitializer, i64 3 }>, align 8
3+
// UNSUPPORTED: CPU=i386 && OS=ios
4+
// UNSUPPORTED: CPU=armv7 && OS=ios
5+
// UNSUPPORTED: CPU=armv7s && OS=ios
6+
7+
// CHECK: @"$sB[[INT]]_WV" = external global i8*, align [[ALIGNMENT]]
8+
// CHECK: @"$s4main9NamespaceC5ValueVySi_GMf" = internal constant <{ i8**, [[INT]], %swift.type_descriptor*, %swift.type*, i32{{(, \[4 x i8\])?}}, i64 }> <{ i8** @"$sB[[INT]]_WV", [[INT]] 512, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main9NamespaceC5ValueVMn" to %swift.type_descriptor*), %swift.type* @"$sSiN", i32 0{{(, \[4 x i8\] zeroinitializer)?}}, i64 3 }>, align [[ALIGNMENT]]
49
final class Namespace<Arg> {
510
struct Value {
611
let first: Arg
@@ -14,15 +19,15 @@ func consume<T>(_ t: T) {
1419
}
1520

1621
// CHECK: define hidden swiftcc void @"$s4main4doityyF"() #{{[0-9]+}} {
17-
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture %{{[0-9]+}}, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, i64, %swift.type_descriptor*, %swift.type*, i32, [4 x i8], i64 }>* @"$s4main9NamespaceC5ValueVySi_GMf" to %swift.full_type*), i32 0, i32 1))
22+
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture %{{[0-9]+}}, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, [[INT]], %swift.type_descriptor*, %swift.type*, i32{{(, \[4 x i8\])?}}, i64 }>* @"$s4main9NamespaceC5ValueVySi_GMf" to %swift.full_type*), i32 0, i32 1))
1823
// CHECK: }
1924
func doit() {
2025
consume( Namespace.Value(first: 13) )
2126
}
2227
doit()
2328

2429
// CHECK: ; Function Attrs: noinline nounwind readnone
25-
// CHECK: define hidden swiftcc %swift.metadata_response @"$s4main9NamespaceC5ValueVMa"(i64, %swift.type*) #{{[0-9]+}} {
30+
// CHECK: define hidden swiftcc %swift.metadata_response @"$s4main9NamespaceC5ValueVMa"([[INT]], %swift.type*) #{{[0-9]+}} {
2631
// CHECK: entry:
2732
// CHECK: [[ERASED_TYPE_1:%[0-9]+]] = bitcast %swift.type* %1 to i8*
2833
// CHECK: br label %[[TYPE_COMPARISON_1:[0-9]+]]
@@ -31,8 +36,8 @@ doit()
3136
// CHECK: [[EQUAL_TYPES_1_1:%[0-9]+]] = and i1 true, [[EQUAL_TYPE_1_1]]
3237
// CHECK: br i1 [[EQUAL_TYPES_1_1]], label %[[EXIT_PRESPECIALIZED_1:[0-9]+]], label %[[EXIT_NORMAL:[0-9]+]]
3338
// CHECK: [[EXIT_PRESPECIALIZED_1]]:
34-
// CHECK: ret %swift.metadata_response { %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, i64, %swift.type_descriptor*, %swift.type*, i32, [4 x i8], i64 }>* @"$s4main9NamespaceC5ValueVySi_GMf" to %swift.full_type*), i32 0, i32 1), i64 0 }
39+
// CHECK: ret %swift.metadata_response { %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, [[INT]], %swift.type_descriptor*, %swift.type*, i32{{(, \[4 x i8\])?}}, i64 }>* @"$s4main9NamespaceC5ValueVySi_GMf" to %swift.full_type*), i32 0, i32 1), [[INT]] 0 }
3540
// CHECK: [[EXIT_NORMAL]]:
36-
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateGenericMetadata(i64 %0, i8* [[ERASED_TYPE_1]], i8* undef, i8* undef, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main9NamespaceC5ValueVMn" to %swift.type_descriptor*)) #{{[0-9]+}}
41+
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateGenericMetadata([[INT]] %0, i8* [[ERASED_TYPE_1]], i8* undef, i8* undef, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main9NamespaceC5ValueVMn" to %swift.type_descriptor*)) #{{[0-9]+}}
3742
// CHECK: ret %swift.metadata_response {{%[0-9]+}}
3843
// CHECK: }

test/IRGen/prespecialized-metadata/struct-inmodule-0argument.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// RUN: %swift -target %module-target-future -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s
1+
// RUN: %swift -target %module-target-future -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment
2+
3+
// UNSUPPORTED: CPU=i386 && OS=ios
4+
// UNSUPPORTED: CPU=armv7 && OS=ios
5+
// UNSUPPORTED: CPU=armv7s && OS=ios
26

37
struct Value {
48
let first: Int
@@ -11,7 +15,7 @@ func consume<T>(_ t: T) {
1115
}
1216

1317
// CHECK: define hidden swiftcc void @"$s4main4doityyF"() #0 {
14-
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture %{{[0-9]+}}, %swift.type* bitcast (i64* getelementptr inbounds (<{ i8**, i64, <{ i32, i32, i32, i32, i32, i32, i32 }>*, i32, [4 x i8], i64 }>, <{ i8**, i64, <{ i32, i32, i32, i32, i32, i32, i32 }>*, i32, [4 x i8], i64 }>* @"$s4main5ValueVMf", i32 0, i32 1) to %swift.type*))
18+
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture %{{[0-9]+}}, %swift.type* bitcast ([[INT]]* getelementptr inbounds (<{ i8**, [[INT]], <{ i32, i32, i32, i32, i32, i32, i32 }>*, i32{{(, \[4 x i8\])?}}, i64 }>, <{ i8**, [[INT]], <{ i32, i32, i32, i32, i32, i32, i32 }>*, i32{{(, \[4 x i8\])?}}, i64 }>* @"$s4main5ValueVMf", i32 0, i32 1) to %swift.type*))
1519
// CHECK: }
1620
func doit() {
1721
consume( Value(first: 13) )

test/IRGen/prespecialized-metadata/struct-inmodule-1argument-0distinct_use.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// RUN: %swift -target %module-target-future -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s
1+
// RUN: %swift -target %module-target-future -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment
2+
3+
// UNSUPPORTED: CPU=i386 && OS=ios
4+
// UNSUPPORTED: CPU=armv7 && OS=ios
5+
// UNSUPPORTED: CPU=armv7s && OS=ios
26

37
struct Value<First> {
48
let first: First
@@ -17,9 +21,9 @@ func doit() {
1721
doit()
1822

1923
// CHECK: ; Function Attrs: noinline nounwind readnone
20-
// CHECK: define hidden swiftcc %swift.metadata_response @"$s4main5ValueVMa"(i64, %swift.type*) #{{[0-9]+}} {
24+
// CHECK: define hidden swiftcc %swift.metadata_response @"$s4main5ValueVMa"([[INT]], %swift.type*) #{{[0-9]+}} {
2125
// CHECK: entry:
2226
// CHECK: [[ERASED_TYPE:%[0-9]+]] = bitcast %swift.type* %1 to i8*
23-
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateGenericMetadata(i64 %0, i8* [[ERASED_TYPE]], i8* undef, i8* undef, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main5ValueVMn" to %swift.type_descriptor*)) #{{[0-9]+}}
27+
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateGenericMetadata([[INT]] %0, i8* [[ERASED_TYPE]], i8* undef, i8* undef, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8 }>* @"$s4main5ValueVMn" to %swift.type_descriptor*)) #{{[0-9]+}}
2428
// CHECK: ret %swift.metadata_response {{%[0-9]+}}
2529
// CHECK: }

test/IRGen/prespecialized-metadata/struct-inmodule-1argument-1conformance-1distinct_use.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
// RUN: %swift -target %module-target-future -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s
1+
// RUN: %swift -target %module-target-future -emit-ir -prespecialize-generic-metadata %s | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment
2+
3+
// UNSUPPORTED: CPU=i386 && OS=ios
4+
// UNSUPPORTED: CPU=armv7 && OS=ios
5+
// UNSUPPORTED: CPU=armv7s && OS=ios
26

37
// CHECK: @"$sytN" = external global %swift.full_type
4-
// CHECK: @"$s4main5ValueVySiGMf" = internal constant <{ i8**, i64, %swift.type_descriptor*, %swift.type*, i8**, i32, [4 x i8], i64 }> <{ i8** getelementptr inbounds (%swift.vwtable, %swift.vwtable* @"$s4main5ValueVWV", i32 0, i32 0), i64 512, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8, i32, i32, i32 }>* @"$s4main5ValueVMn" to %swift.type_descriptor*), %swift.type* @"$sSiN", i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @"$sSi4main1PAAWP", i32 0, i32 0), i32 0, [4 x i8] zeroinitializer, i64 3 }>, align 8
8+
// CHECK: @"$sB[[INT]]_WV" = external global i8*, align [[ALIGNMENT]]
9+
// CHECK: @"$s4main5ValueVySiGMf" = internal constant <{ i8**, [[INT]], %swift.type_descriptor*, %swift.type*, i8**, i32{{(, \[4 x i8\])?}}, i64 }> <{ i8** @"$sB[[INT]]_WV", [[INT]] 512, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8, i32, i32, i32 }>* @"$s4main5ValueVMn" to %swift.type_descriptor*), %swift.type* @"$sSiN", i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @"$sSi4main1PAAWP", i32 0, i32 0), i32 0{{(, \[4 x i8\] zeroinitializer)?}}, i64 3 }>, align [[ALIGNMENT]]
510
protocol P {}
611
extension Int : P {}
712
struct Value<First : P> {
@@ -15,15 +20,15 @@ func consume<T>(_ t: T) {
1520
}
1621

1722
// CHECK: define hidden swiftcc void @"$s4main4doityyF"() #{{[0-9]+}} {
18-
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture %{{[0-9]+}}, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, i64, %swift.type_descriptor*, %swift.type*, i8**, i32, [4 x i8], i64 }>* @"$s4main5ValueVySiGMf" to %swift.full_type*), i32 0, i32 1))
23+
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture %{{[0-9]+}}, %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, [[INT]], %swift.type_descriptor*, %swift.type*, i8**, i32{{(, \[4 x i8\])?}}, i64 }>* @"$s4main5ValueVySiGMf" to %swift.full_type*), i32 0, i32 1))
1924
// CHECK: }
2025
func doit() {
2126
consume( Value(first: 13) )
2227
}
2328
doit()
2429

2530
// CHECK: ; Function Attrs: noinline nounwind readnone
26-
// CHECK: define hidden swiftcc %swift.metadata_response @"$s4main5ValueVMa"(i64, %swift.type*, i8**) #{{[0-9]+}} {
31+
// CHECK: define hidden swiftcc %swift.metadata_response @"$s4main5ValueVMa"([[INT]], %swift.type*, i8**) #{{[0-9]+}} {
2732
// CHECK: entry:
2833
// CHECK: [[ERASED_TYPE:%[0-9]+]] = bitcast %swift.type* %1 to i8*
2934
// CHECK: [[ERASED_TABLE:%[0-9]+]] = bitcast i8** %2 to i8*
@@ -33,8 +38,8 @@ doit()
3338
// CHECK: [[EQUAL_TYPES:%[0-9]+]] = and i1 true, [[EQUAL_TYPE]]
3439
// CHECK: br i1 [[EQUAL_TYPES]], label %[[EXIT_PRESPECIALIZED:[0-9]+]], label %[[EXIT_NORMAL:[0-9]+]]
3540
// CHECK: [[EXIT_PRESPECIALIZED]]:
36-
// CHECK: ret %swift.metadata_response { %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, i64, %swift.type_descriptor*, %swift.type*, i8**, i32, [4 x i8], i64 }>* @"$s4main5ValueVySiGMf" to %swift.full_type*), i32 0, i32 1), i64 0 }
41+
// CHECK: ret %swift.metadata_response { %swift.type* getelementptr inbounds (%swift.full_type, %swift.full_type* bitcast (<{ i8**, [[INT]], %swift.type_descriptor*, %swift.type*, i8**, i32{{(, \[4 x i8\])?}}, i64 }>* @"$s4main5ValueVySiGMf" to %swift.full_type*), i32 0, i32 1), [[INT]] 0 }
3742
// CHECK: [[EXIT_NORMAL]]:
38-
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateGenericMetadata(i64 %0, i8* [[ERASED_TYPE]], i8* [[ERASED_TABLE]], i8* undef, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8, i32, i32, i32 }>* @"$s4main5ValueVMn" to %swift.type_descriptor*)) #12
43+
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateGenericMetadata([[INT]] %0, i8* [[ERASED_TYPE]], i8* [[ERASED_TABLE]], i8* undef, %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8, i32, i32, i32 }>* @"$s4main5ValueVMn" to %swift.type_descriptor*)) #12
3944
// CHECK: ret %swift.metadata_response {{%[0-9]+}}
4045
// CHECK: }

0 commit comments

Comments
 (0)