Skip to content

Commit 171e461

Browse files
committed
Fix sizes in linux tests
1 parent 42202af commit 171e461

File tree

27 files changed

+50
-35
lines changed

27 files changed

+50
-35
lines changed

include/swift/ABI/Metadata.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ struct MetadataDependency {
118118

119119
/// Prefix of a metadata header, containing a pointer to the
120120
/// type layout string.
121+
template <typename Runtime>
121122
struct TargetTypeMetadataLayoutPrefix {
122-
const uint8_t *layoutString;
123+
TargetSignedPointer<Runtime, const uint8_t *
124+
__ptrauth_swift_type_layout_string>
125+
layoutString;
123126
};
124127

125128
/// The header before a metadata object which appears on all type
@@ -138,14 +141,14 @@ struct TargetTypeMetadataHeaderBase {
138141

139142
template <typename Runtime>
140143
struct TargetTypeMetadataHeader
141-
: TargetTypeMetadataLayoutPrefix,
144+
: TargetTypeMetadataLayoutPrefix<Runtime>,
142145
TargetTypeMetadataHeaderBase<Runtime> {
143146

144147
TargetTypeMetadataHeader() = default;
145148
constexpr TargetTypeMetadataHeader(
146-
const TargetTypeMetadataLayoutPrefix &layout,
149+
const TargetTypeMetadataLayoutPrefix<Runtime> &layout,
147150
const TargetTypeMetadataHeaderBase<Runtime> &header)
148-
: TargetTypeMetadataLayoutPrefix(layout),
151+
: TargetTypeMetadataLayoutPrefix<Runtime>(layout),
149152
TargetTypeMetadataHeaderBase<Runtime>(header) {}
150153
};
151154

@@ -305,6 +308,7 @@ struct TargetMetadata {
305308
}
306309

307310
const uint8_t *getLayoutString() const {
311+
assert(hasLayoutString());
308312
if (isAnyClass()) {
309313
return asFullMetadata(
310314
reinterpret_cast<const TargetAnyClassMetadata<Runtime> *>(
@@ -334,6 +338,10 @@ struct TargetMetadata {
334338
asFullMetadata(this)->layoutString = layoutString;
335339
}
336340
}
341+
342+
bool hasLayoutString() const {
343+
return getTypeContextDescriptor()->hasLayoutString();
344+
}
337345

338346
// Define forwarders for value witnesses. These invoke this metadata's value
339347
// witness table with itself as the 'self' parameter.
@@ -508,14 +516,14 @@ using HeapMetadataHeaderPrefix =
508516
/// The header present on all heap metadata.
509517
template <typename Runtime>
510518
struct TargetHeapMetadataHeader
511-
: TargetTypeMetadataLayoutPrefix,
519+
: TargetTypeMetadataLayoutPrefix<Runtime>,
512520
TargetHeapMetadataHeaderPrefix<Runtime>,
513521
TargetTypeMetadataHeaderBase<Runtime> {
514522
constexpr TargetHeapMetadataHeader(
515-
const TargetTypeMetadataLayoutPrefix &typeLayoutPrefix,
523+
const TargetTypeMetadataLayoutPrefix<Runtime> &typeLayoutPrefix,
516524
const TargetHeapMetadataHeaderPrefix<Runtime> &heapPrefix,
517525
const TargetTypeMetadataHeaderBase<Runtime> &typePrefix)
518-
: TargetTypeMetadataLayoutPrefix(typeLayoutPrefix),
526+
: TargetTypeMetadataLayoutPrefix<Runtime>(typeLayoutPrefix),
519527
TargetHeapMetadataHeaderPrefix<Runtime>(heapPrefix),
520528
TargetTypeMetadataHeaderBase<Runtime>(typePrefix) {}
521529
};

include/swift/ABI/MetadataValues.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,8 @@ namespace SpecialPointerAuthDiscriminators {
14451445

14461446
// Relative protocol witness table descriminator
14471447
const uint16_t RelativeProtocolWitnessTable = 0xb830; // = 47152
1448+
1449+
const uint16_t TypeLayoutString = 0x8b65; // = 35685
14481450
}
14491451

14501452
/// The number of arguments that will be passed directly to a generic

include/swift/Runtime/Config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ extern uintptr_t __COMPATIBILITY_LIBRARIES_CANNOT_CHECK_THE_IS_SWIFT_BIT_DIRECTL
323323
ptrauth_key_process_independent_code, \
324324
ptrauth_blend_discriminator(__buffer, \
325325
SpecialPointerAuthDiscriminators::OpaqueModifyResumeFunction))
326+
#define __ptrauth_swift_type_layout_string \
327+
__ptrauth(ptrauth_key_process_independent_data, 1, \
328+
SpecialPointerAuthDiscriminators::TypeLayoutString)
326329
#else
327330
#define SWIFT_PTRAUTH 0
328331
#define __ptrauth_swift_function_pointer(__typekey)
@@ -350,6 +353,7 @@ extern uintptr_t __COMPATIBILITY_LIBRARIES_CANNOT_CHECK_THE_IS_SWIFT_BIT_DIRECTL
350353
#define __ptrauth_swift_dynamic_replacement_key
351354
#define swift_ptrauth_sign_opaque_read_resume_function(__fn, __buffer) (__fn)
352355
#define swift_ptrauth_sign_opaque_modify_resume_function(__fn, __buffer) (__fn)
356+
#define __ptrauth_swift_type_layout_string
353357
#endif
354358

355359
#ifdef __cplusplus

include/swift/SIL/SILType.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,7 @@ class SILType {
638638
/// Canonical way to check if a SILType is move only. Using is/getAs/castTo
639639
/// will look through moveonly-ness.
640640
bool isMoveOnlyWrapped() const {
641-
// TODO: Is this correct?
642-
if (auto rawTy = getRawASTType())
643-
return rawTy->is<SILMoveOnlyWrappedType>();
644-
return false;
641+
return getRawASTType()->is<SILMoveOnlyWrappedType>();
645642
}
646643

647644
/// If this is already a move only wrapped type, return *this. Otherwise, wrap

lib/IRGen/GenDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4942,7 +4942,7 @@ llvm::GlobalValue *IRGenModule::defineTypeMetadata(
49424942
}
49434943

49444944
if (concreteType->is<TupleType>()) {
4945-
adjustmentIndex = 1;
4945+
adjustmentIndex = MetadataAdjustmentIndex::NoTypeLayoutString;
49464946
}
49474947
}
49484948

@@ -4988,7 +4988,7 @@ IRGenModule::getAddrOfTypeMetadata(CanType concreteType,
49884988
unsigned adjustmentIndex;
49894989
if (concreteType->isAny() || concreteType->isAnyObject() || concreteType->isVoid() || concreteType->is<TupleType>() || concreteType->is<BuiltinType>()) {
49904990
defaultVarTy = FullExistentialTypeMetadataStructTy;
4991-
adjustmentIndex = 1;
4991+
adjustmentIndex = MetadataAdjustmentIndex::NoTypeLayoutString;
49924992
} else if (fullMetadata) {
49934993
defaultVarTy = FullTypeMetadataStructTy;
49944994
if (concreteType->getClassOrBoundGenericClass() && !foreign) {

lib/IRGen/GenMeta.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ namespace irgen {
152152
// Struct and enum metadata have one word of head-allocated data:
153153
// the value witness table.
154154
ValueType = 2,
155+
156+
// Some builtin and well-known types don't have a layout string
157+
// for binary compatibility reasons.
158+
NoTypeLayoutString = 1,
155159

156160
// Other metadata objects have no head allocation.
157161
None = 0,

test/IRGen/prespecialized-metadata/class-fileprivate-2argument-1_distinct_use-1st_argument_generic_class-2nd_argument_distinct_generic_class.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
// CHECK-SAME: i16 {{(7|3)}},
8282
// CHECK-SAME: i16 0,
8383
// CHECK-apple-SAME: i32 {{(144|84)}},
84-
// CHECK-unknown-SAME: i32 112,
84+
// CHECK-unknown-SAME: i32 120,
8585
// CHECK-SAME: i32 {{(24|12)}},
8686
// : %swift.type_descriptor* bitcast (
8787
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-2argument-1_distinct_use-1st_argument_generic_class-2nd_argument_same_generic_class_different_value.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
// CHECK-SAME: i16 {{(7|3)}},
8080
// CHECK-SAME: i16 0,
8181
// CHECK-apple-SAME: i32 {{(144|84)}},
82-
// CHECK-unknown-SAME: i32 112,
82+
// CHECK-unknown-SAME: i32 120,
8383
// CHECK-SAME: i32 {{(24|12)}},
8484
// : %swift.type_descriptor* bitcast (
8585
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-2argument-1_distinct_use-1st_argument_generic_class-2nd_argument_same_generic_class_same_value.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
// CHECK-SAME: i16 {{(7|3)}},
8080
// CHECK-SAME: i16 0,
8181
// CHECK-apple-SAME: i32 {{(144|84)}},
82-
// CHECK-unknown-SAME: i32 112,
82+
// CHECK-unknown-SAME: i32 120,
8383
// CHECK-SAME: i32 {{(24|12)}},
8484
// : %swift.type_descriptor* bitcast (
8585
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1arg-2ancs-1distinct_use-1st_anc_gen-1arg-1st_arg_con_int-2nd_anc_gen-1st-arg_con_double.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
// CHECK-SAME: i16 {{(7|3)}},
137137
// CHECK-SAME: i16 0,
138138
// CHECK-apple-SAME: i32 {{(176|100)}},
139-
// CHECK-unknown-SAME: i32 144,
139+
// CHECK-unknown-SAME: i32 152,
140140
// CHECK-SAME: i32 {{(24|12)}},
141141
// : %swift.type_descriptor* bitcast (
142142
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1arg-2ancs-1distinct_use-1st_anc_gen-1arg-1st_arg_con_int-2nd_anc_gen-1st-arg_subclass_arg.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
// CHECK-SAME: i16 {{(7|3)}},
129129
// CHECK-SAME: i16 0,
130130
// CHECK-apple-SAME: i32 {{(168|100)}},
131-
// CHECK-unknown-SAME: i32 136,
131+
// CHECK-unknown-SAME: i32 144,
132132
// CHECK-SAME: i32 {{(24|12)}},
133133
// : %swift.type_descriptor* bitcast (
134134
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1arg-2ancs-1distinct_use-1st_anc_gen-1arg-1st_arg_subclass_arg-2nd_anc_gen-1st-arg_con_int.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
// CHECK-SAME: i16 {{(7|3)}},
133133
// CHECK-SAME: i16 0,
134134
// CHECK-apple-SAME: i32 {{(168|100)}},
135-
// CHECK-unknown-SAME: i32 136,
135+
// CHECK-unknown-SAME: i32 144,
136136
// CHECK-SAME: i32 {{(24|12)}},
137137
// : %swift.type_descriptor* bitcast (
138138
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1arg-2ancs-1distinct_use-1st_anc_gen-1arg-1st_arg_subcls_arg-2nd_anc_gen-1st-arg_subcls_arg.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
// CHECK-SAME: i16 {{(7|3)}},
125125
// CHECK-SAME: i16 0,
126126
// CHECK-apple-SAME: i32 {{(160|92)}},
127-
// CHECK-unknown-SAME: i32 128,
127+
// CHECK-unknown-SAME: i32 136,
128128
// CHECK-SAME: i32 {{(24|12)}},
129129
// : %swift.type_descriptor* bitcast (
130130
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-1ancestor-1distinct_use-1st_ancestor_generic-1argument-1st_argument_constant_int.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
// CHECK-SAME: i16 {{(7|3)}},
123123
// CHECK-SAME: i16 0,
124124
// CHECK-apple-SAME: i32 {{(152|88)}},
125-
// CHECK-unknown-SAME: i32 120,
125+
// CHECK-unknown-SAME: i32 128,
126126
// CHECK-SAME: i32 {{(24|12)}},
127127
// : %swift.type_descriptor* bitcast (
128128
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-1ancestor-1distinct_use-1st_ancestor_generic-1argument-1st_argument_subclass_argument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
// CHECK-SAME: i16 {{(7|3)}},
195195
// CHECK-SAME: i16 0,
196196
// CHECK-apple-SAME: i32 {{(144|84)}},
197-
// CHECK-unknown-SAME: i32 112,
197+
// CHECK-unknown-SAME: i32 120,
198198
// CHECK-SAME: i32 {{(24|12)}},
199199
// : %swift.type_descriptor* bitcast (
200200
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-1ancestor-1distinct_use-1st_ancestor_generic-1argument-1st_argument_superclass.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
// CHECK-SAME: i16 {{(7|3)}},
119119
// CHECK-SAME: i16 0,
120120
// CHECK-apple-SAME: i32 {{(144|84)}},
121-
// CHECK-unknown-SAME: i32 112,
121+
// CHECK-unknown-SAME: i32 120,
122122
// CHECK-apple-SAME: i32 {{(24|12)}},
123123
// : %swift.type_descriptor* bitcast (
124124
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-1ancestor-1distinct_use-1st_ancestor_nongeneric-external-nonresilient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ import TestModule
9191
// CHECK-SAME: i16 {{(7|3)}},
9292
// CHECK-SAME: i16 0,
9393
// CHECK-apple-SAME: i32 {{(144|84)}},
94-
// CHECK-unknown-SAME: i32 112,
94+
// CHECK-unknown-SAME: i32 120,
9595
// CHECK-SAME: i32 {{(24|12)}},
9696
// CHECK-SAME: %swift.type_descriptor* bitcast (
9797
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-1ancestor-1distinct_use-1st_ancestor_nongeneric-fileprivate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
// CHECK-SAME: i16 {{(7|3)}},
171171
// CHECK-SAME: i16 0,
172172
// CHECK-apple-SAME: i32 {{(144|84)}},
173-
// CHECK-unknown-SAME: i32 112,
173+
// CHECK-unknown-SAME: i32 120,
174174
// CHECK-SAME: i32 {{(24|12)}},
175175
// : %swift.type_descriptor* bitcast (
176176
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-1distinct_use-1st_argument_generic_class-1argument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
// CHECK-SAME: i16 {{(7|3)}},
159159
// CHECK-SAME: i16 0,
160160
// CHECK-apple-SAME: i32 {{(128|76)}},
161-
// CHECK-unknown-SAME: i32 96,
161+
// CHECK-unknown-SAME: i32 104,
162162
// CHECK-SAME: i32 {{(24|12)}},
163163
// : %swift.type_descriptor* bitcast (
164164
// : <{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
// CHECK-SAME: i16 {{(7|3)}},
6363
// CHECK-SAME: i16 0,
6464
// CHECK-apple-SAME: i32 {{(128|76)}},
65-
// CHECK-unknown-SAME: i32 96,
65+
// CHECK-unknown-SAME: i32 104,
6666
// CHECK-SAME: i32 {{(24|12)}},
6767
// : %swift.type_descriptor* bitcast (<{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i8, i8, i8, i8, i32, i32, %swift.method_descriptor }>* @"$s4main5Value[[UNIQUE_ID_1]]CMn" to %swift.type_descriptor*),
6868
// CHECK-SAME: i8* null,

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-1distinct_use_generic_class.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
// CHECK-SAME: i16 {{(7|3)}},
8484
// CHECK-SAME: i16 0,
8585
// CHECK-apple-SAME: i32 {{(128|76)}},
86-
// CHECK-unknown-SAME: i32 96,
86+
// CHECK-unknown-SAME: i32 104,
8787
// CHECK-SAME: i32 {{(24|12)}},
8888
// : %swift.type_descriptor* bitcast (
8989
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-1distinct_use_generic_class_specialized_at_generic_class.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
// CHECK-SAME: i16 {{(7|3)}},
8383
// CHECK-SAME: i16 0,
8484
// CHECK-apple-SAME: i32 {{(128|76)}},
85-
// CHECK-unknown-SAME: i32 96,
85+
// CHECK-unknown-SAME: i32 104,
8686
// CHECK-SAME: i32 {{(24|12)}},
8787
// : %swift.type_descriptor* bitcast (
8888
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-1distinct_use_generic_enum.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
// CHECK-SAME: i16 {{(7|3)}},
8282
// CHECK-SAME: i16 0,
8383
// CHECK-apple-SAME: i32 {{(128|76)}},
84-
// CHECK-unknown-SAME: i32 96,
84+
// CHECK-unknown-SAME: i32 104,
8585
// CHECK-SAME: i32 {{(24|12)}},
8686
// : %swift.type_descriptor* bitcast (
8787
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-1distinct_use_generic_struct.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
// CHECK-SAME: i16 {{(7|3)}},
8282
// CHECK-SAME: i16 0,
8383
// CHECK-apple-SAME: i32 {{(128|76)}},
84-
// CHECK-unknown-SAME: i32 96,
84+
// CHECK-unknown-SAME: i32 104,
8585
// CHECK-SAME: i32 {{(24|12)}},
8686
// : %swift.type_descriptor* bitcast (
8787
// : <{

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1argument-2ancestor-1du-1st_ancestor_generic-fileprivate-2nd_ancestor_nongeneric.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
// CHECK-SAME: i16 {{(7|3)}},
131131
// CHECK-SAME: i16 0,
132132
// CHECK-apple-SAME: i32 {{(160|92)}},
133-
// CHECK-unknown-SAME: i32 128,
133+
// CHECK-unknown-SAME: i32 136,
134134
// CHECK-SAME: i32 {{(24|12)}},
135135
// : %swift.type_descriptor* bitcast (
136136
// : <{

test/Interpreter/Inputs/layout_string_witnesses_types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Foundation
2-
31
public class SimpleClass {
42
public let x: Int
53

@@ -137,6 +135,8 @@ public struct ExistentialRefWrapper {
137135
}
138136

139137
#if os(macOS)
138+
import Foundation
139+
140140
@objc
141141
public class ObjcClass: NSObject {
142142
public let x: Int

unittests/runtime/Array.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extern "C" void swift_arrayInitWithCopy(OpaqueValue *dest,
4747
initialize_pod_witness_table_size_uint32_t_stride_uint64_t(pod_witnesses); \
4848
uint64_t srcArray[3] = {0, 1, 2}; \
4949
uint64_t destArray[3] = {0x5A5A5A5AU, 0x5A5A5A5AU, 0x5A5A5A5AU}; \
50-
FullOpaqueMetadata testMetadata = {{&pod_witnesses}, \
50+
FullOpaqueMetadata testMetadata = {{&pod_witnesses}, \
5151
{{MetadataKind::Opaque}}}; \
5252
Metadata *metadata = &testMetadata.base; \
5353
swift_array##kind((OpaqueValue *)destArray, (OpaqueValue *)srcArray, 3, \

0 commit comments

Comments
 (0)