Skip to content

Commit a8ea69e

Browse files
authored
Merge pull request #25467 from linux-on-ibm-z/s390x-keypath-tuple-fix
Fix KeyPath failure on s390x
2 parents 84a6103 + e08359c commit a8ea69e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

include/swift/ABI/Metadata.h

+7
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,11 @@ struct TargetTupleTypeMetadata : public TargetMetadata<Runtime> {
14951495
ConstTargetMetadataPointer<Runtime, swift::TargetMetadata> Type;
14961496

14971497
/// The offset of the tuple element within the tuple.
1498+
#if __APPLE__
14981499
StoredSize Offset;
1500+
#else
1501+
uint32_t Offset;
1502+
#endif
14991503

15001504
OpaqueValue *findIn(OpaqueValue *tuple) const {
15011505
return (OpaqueValue*) (((char*) tuple) + Offset);
@@ -1506,6 +1510,9 @@ struct TargetTupleTypeMetadata : public TargetMetadata<Runtime> {
15061510
}
15071511
};
15081512

1513+
static_assert(sizeof(Element) == sizeof(StoredSize) * 2,
1514+
"element size should be two words");
1515+
15091516
Element *getElements() {
15101517
return reinterpret_cast<Element*>(this + 1);
15111518
}

lib/IRGen/IRGenModule.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ IRGenModule::IRGenModule(IRGenerator &irgen,
266266
// A tuple type metadata record has a couple extra fields.
267267
auto tupleElementTy = createStructType(*this, "swift.tuple_element_type", {
268268
TypeMetadataPtrTy, // Metadata *Type;
269-
SizeTy // size_t Offset;
269+
Int32Ty // int32_t Offset;
270270
});
271271
TupleTypeMetadataPtrTy = createStructPointerType(*this, "swift.tuple_type", {
272272
TypeMetadataStructTy, // (base)

test/IRGen/generic_tuples.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// CHECK: [[TYPE:%swift.type]] = type {
1010
// CHECK: [[OPAQUE:%swift.opaque]] = type opaque
1111
// CHECK: [[TUPLE_TYPE:%swift.tuple_type]] = type { [[TYPE]], i64, i8*, [0 x %swift.tuple_element_type] }
12-
// CHECK: %swift.tuple_element_type = type { [[TYPE]]*, i64 }
12+
// CHECK: %swift.tuple_element_type = type { [[TYPE]]*, i32 }
1313

1414
func dup<T>(_ x: T) -> (T, T) { var x = x; return (x,x) }
1515
// CHECK: define hidden swiftcc void @"$s14generic_tuples3dupyx_xtxlF"(%swift.opaque* noalias nocapture, %swift.opaque* noalias nocapture, %swift.opaque* noalias nocapture, %swift.type* %T)

0 commit comments

Comments
 (0)