Merge pull request #14823 from rjmccall/no-instantiate-field-type-vector-slot

diff --git a/lib/IRGen/GenMeta.cpp b/lib/IRGen/GenMeta.cpp
index 8a1b98e..1c61349 100644
--- a/lib/IRGen/GenMeta.cpp
+++ b/lib/IRGen/GenMeta.cpp
@@ -3222,9 +3222,6 @@
 
       asImpl().addDependentData();
       
-      // Save a slot for the field type vector address to be instantiated into.
-      asImpl().addFieldTypeVectorReferenceSlot();
-
       // Lay out the template data.
       super::layout();
       
@@ -3281,10 +3278,6 @@
       super::addGenericWitnessTable(type, conf, std::forward<T>(args)...);
     }
     
-    void addFieldTypeVectorReferenceSlot() {
-      B.addNullPointer(IGM.TypeMetadataPtrTy->getPointerTo());
-    }
-    
     // Can be overridden by subclassers to emit other dependent metadata.
     void addDependentData() {}
     
diff --git a/test/IRGen/enum_value_semantics.sil b/test/IRGen/enum_value_semantics.sil
index d98da2e..f944eec 100644
--- a/test/IRGen/enum_value_semantics.sil
+++ b/test/IRGen/enum_value_semantics.sil
@@ -156,7 +156,7 @@
 
 // CHECK-LABEL: @"$S20enum_value_semantics18GenericFixedLayoutOMP" = internal global <{{[{].*\* [}]}}> <{
 // CHECK:   %swift.type* (%swift.type_pattern*, i8**)* @create_generic_metadata_GenericFixedLayout
-// CHECK:   i32 40, i16 1, i16 16,
+// CHECK:   i32 32, i16 1, i16 8,
 // CHECK:   [16 x i8*] zeroinitializer,
 // CHECK:   i8** getelementptr inbounds ([18 x i8*], [18 x i8*]* @"$S20enum_value_semantics18GenericFixedLayoutOWV", i32 0, i32 0),
 // CHECK:   i64 2,
diff --git a/test/IRGen/field_type_vectors.sil b/test/IRGen/field_type_vectors.sil
deleted file mode 100644
index d4b1129..0000000
--- a/test/IRGen/field_type_vectors.sil
+++ /dev/null
@@ -1,67 +0,0 @@
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir | %FileCheck %s
-
-// REQUIRES: CPU=x86_64
-
-import Swift
-
-// CHECK-LABEL: @"$S18field_type_vectors3FooVMn" = hidden constant
-struct Foo {
-  var x: Int
-}
-
-// CHECK-LABEL: @"$S18field_type_vectors3BarVMn" = hidden constant
-// CHECK-LABEL: @"$S18field_type_vectors3BarVMP" = internal global
-// -- There should be 1 word between the field type vector slot, with type %swift.type**,
-//    and the address point
-// CHECK:       %swift.type**, i8**, i64, <{ {{.*}} }>*, %swift.type*, i64
-struct Bar<T> {
-  var y: Int
-}
-
-// CHECK-LABEL: @"$S18field_type_vectors3BasVMn" = hidden constant
-// CHECK-LABEL: @"$S18field_type_vectors3BasVMP" = internal global
-// -- There should be 1 word between the field type vector slot, with type %swift.type**,
-//    and the address point
-// CHECK:       %swift.type**, i8**, i64, <{ {{.*}} }>*, %swift.type*, %swift.type*, i64, i64
-struct Bas<T, U> {
-  var foo: Foo
-  var bar: Bar<T>
-}
-
-// CHECK-LABEL: @"$S18field_type_vectors3ZimCMn" = hidden constant
-// CHECK-LABEL: @"$S18field_type_vectors3ZimCMP" = internal global
-// -- There should be 1 word between the field type vector slot, with type %swift.type**,
-//    and the address point
-// CHECK:       %swift.type**, i8*, i8**, i64, %swift.type*, %swift.opaque*, %swift.opaque*, i64, i32, i32, i32, i16, i16, i32, i32, <{ {{.*}} }>*, i8*
-class Zim<T, U> {
-  var foo: Foo?
-  var bar: Bar<T>?
-  var bas: Bas<T, U>?
-}
-sil_vtable Zim {}
-
-sil @_TFC18field_type_vectors3ZimcU___fMGS0_Q_Q0__FT_GS0_Q_Q0__ : $@convention(method) <T, U> (@owned Zim<T, U>) -> @owned Zim<T, U>
-
-// CHECK-LABEL: @"$S18field_type_vectors4ZangCMn" = hidden constant
-// CHECK-LABEL: @"$S18field_type_vectors4ZangCMP" = internal global
-// -- There should be 1 word between the field type vector slot, with type %swift.type**,
-//    and the address point
-// CHECK:       %swift.type**, i8*, i8**, i64, %swift.type*, %swift.opaque*, %swift.opaque*, i64, i32, i32, i32, i16, i16, i32, i32, <{ {{.*}} }>*, i8*
-class Zang<V>: Zim<V, V> {
-  var zung: Int = 0
-}
-sil_vtable Zang {}
-
-sil @_TFC18field_type_vectors4ZangcU__fMGS0_Q__FT_GS0_Q__ : $@convention(method) <V> (@owned Zang<V>) -> @owned Zang<V>
-
-// -- For storage-qualified fields, we just report the formal type.
-class StorageQualified {
-  unowned var a: StorageQualified
-  weak var b: StorageQualified?
-
-  init(x: StorageQualified) {
-    a = x
-    b = x
-  }
-}
-sil_vtable StorageQualified {}
diff --git a/test/IRGen/generic_classes.sil b/test/IRGen/generic_classes.sil
index 3f0c58d..e4180d7 100644
--- a/test/IRGen/generic_classes.sil
+++ b/test/IRGen/generic_classes.sil
@@ -320,20 +320,20 @@
 // CHECK-objc:   [[METADATA_ARRAY:%.*]] = bitcast %swift.type* [[METADATA]] to i8**
 // CHECK-objc:   [[T0:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 0
 // CHECK-objc:   [[T1:%.*]] = bitcast i8** [[T0]] to %objc_class**
-// CHECK-objc:   [[T0:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 -26
+// CHECK-objc:   [[T0:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 -25
 // CHECK-objc:   [[METACLASS:%.*]] = bitcast i8** [[T0]] to %objc_class*
 // CHECK-objc:   store %objc_class* [[METACLASS]], %objc_class** [[T1]], align 8
 //   Set up the instance rodata pointer.
 // CHECK-objc:   [[T0:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 4
 // CHECK-objc:   [[T1:%.*]] = bitcast i8** [[T0]] to i64*
-// CHECK-objc:   [[RODATA:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 -21
+// CHECK-objc:   [[RODATA:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 -20
 // CHECK-objc:   [[T2:%.*]] = ptrtoint i8** [[RODATA]] to i64
 // CHECK-objc:   [[T3:%.*]] = or i64 [[T2]], 1
 // CHECK-objc:   store i64 [[T3]], i64* [[T1]], align 8
 //   Set up the class rodata pointer.
-// CHECK-objc:   [[T0:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 -22
+// CHECK-objc:   [[T0:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 -21
 // CHECK-objc:   [[T1:%.*]] = bitcast i8** [[T0]] to i64*
-// CHECK-objc:   [[META_RODATA:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 -12
+// CHECK-objc:   [[META_RODATA:%.*]] = getelementptr inbounds i8*, i8** [[METADATA_ARRAY]], i32 -11
 // CHECK-objc:   [[T2:%.*]] = ptrtoint i8** [[META_RODATA]] to i64
 // CHECK-objc:   store i64 [[T2]], i64* [[T1]], align 8
 //   Initialize our own dependent field offsets.
diff --git a/test/IRGen/generic_structs.sil b/test/IRGen/generic_structs.sil
index cadee5d..ab09ba6 100644
--- a/test/IRGen/generic_structs.sil
+++ b/test/IRGen/generic_structs.sil
@@ -39,7 +39,7 @@
 // CHECK: @"$S15generic_structs13SingleDynamicVMP" = internal global <{ {{.*}} }> <{
 // -- template header
 // CHECK-SAME:   %swift.type* (%swift.type_pattern*, i8**)* @create_generic_metadata_SingleDynamic,
-// CHECK-SAME:   i32 48, i16 1, i16 16, [{{[0-9]+}} x i8*] zeroinitializer,
+// CHECK-SAME:   i32 40, i16 1, i16 8, [{{[0-9]+}} x i8*] zeroinitializer,
 // -- vwtable pointer
 // CHECK-SAME:   @"$S15generic_structs13SingleDynamicVWV"
 // -- address point
diff --git a/test/IRGen/generic_types.swift b/test/IRGen/generic_types.swift
index b9d2540..3ffedf3 100644
--- a/test/IRGen/generic_types.swift
+++ b/test/IRGen/generic_types.swift
@@ -10,11 +10,11 @@
 
 // CHECK-LABEL: @"$S13generic_types1ACMP" = internal global
 // CHECK:   %swift.type* (%swift.type_pattern*, i8**)* @create_generic_metadata_A,
-// CHECK-native-SAME: i32 104,
-// CHECK-objc-SAME:   i32 288,
+// CHECK-native-SAME: i32 96,
+// CHECK-objc-SAME:   i32 280,
 // CHECK-SAME:   i16 1,
-// CHECK-native-SAME: i16 24,
-// CHECK-objc-SAME:   i16 208,
+// CHECK-native-SAME: i16 16,
+// CHECK-objc-SAME:   i16 200,
 // CHECK-SAME:   [{{[0-9]+}} x i8*] zeroinitializer,
 // CHECK-SAME:   void ([[A]]*)* @"$S13generic_types1ACfD",
 // CHECK-SAME:   i8** @"$SBoWV",
@@ -39,11 +39,11 @@
 
 // CHECK-LABEL: @"$S13generic_types1BCMP" = internal global
 // CHECK-SAME:   %swift.type* (%swift.type_pattern*, i8**)* @create_generic_metadata_B,
-// CHECK-native-SAME: i32 104,
-// CHECK-objc-SAME:   i32 288,
+// CHECK-native-SAME: i32 96,
+// CHECK-objc-SAME:   i32 280,
 // CHECK-SAME:   i16 1,
-// CHECK-native-SAME: i16 24,
-// CHECK-objc-SAME:   i16 208,
+// CHECK-native-SAME: i16 16,
+// CHECK-objc-SAME:   i16 200,
 // CHECK-SAME:   [{{[0-9]+}} x i8*] zeroinitializer,
 // CHECK-SAME:   void ([[B]]*)* @"$S13generic_types1BCfD",
 // CHECK-SAME:   i8** @"$SBoWV",