Skip to content

Commit 34dd4aa

Browse files
committed
[IRGen] Collect metadata for empty types fields.
Previously, when the metadata collector only collected for layout, it was wasteful to visit the empty fields of records. Now that the field may require a deinit call, it's necessary to visit it. rdar://123577998
1 parent 571a673 commit 34dd4aa

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lib/IRGen/GenRecord.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,6 @@ class RecordTypeInfoImpl : public Base,
487487
void collectMetadataForOutlining(OutliningMetadataCollector &collector,
488488
SILType T) const override {
489489
for (auto &field : getFields()) {
490-
if (field.isEmpty())
491-
continue;
492490
auto fType = field.getType(collector.IGF.IGM, T);
493491
field.getTypeInfo().collectMetadataForOutlining(collector, fType);
494492
}

test/IRGen/moveonly_value_functions.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,26 @@ public func takeOuterMultiPayloadNC_3<T>(_ e: consuming OuterMultiPayloadNC_3<T>
440440
// CHECK-SAME: ptr noalias swiftself %0)
441441
// CHECK: }
442442
public func takeOuterMultiPayloadNC_4<T>(_ e: consuming OuterMultiPayloadNC_4<T>) {}
443+
444+
public struct EmptyDeinitingNC_1<Wrapped: ~Copyable>: ~Copyable {
445+
deinit {}
446+
}
447+
448+
public enum SinglePayloadNC_1<Element: Equatable>: ~Copyable {
449+
case empty
450+
case node(EmptyDeinitingNC_1<Self>, Element)
451+
}
452+
// CHECK-LABEL: define{{.*}} @"$s24moveonly_value_functions18EmptyDeinitingNC_1VyAA013SinglePayloadF2_1OyxGG_xtSQRzlWOh"(
453+
// CHECK-SAME: ptr %0,
454+
// CHECK-SAME: ptr %Element,
455+
// CHECK-SAME: ptr %Element.Equatable)
456+
// CHECK-SAME: {
457+
// CHECK: [[RESPONSE:%[^,]+]] = call swiftcc %swift.metadata_response @"$s24moveonly_value_functions17SinglePayloadNC_1OMa"(
458+
// : i64 0,
459+
// CHECK-SAME: ptr %Element,
460+
// CHECK-SAME: ptr %Element.Equatable)
461+
// CHECK: [[METADATA:%[^,]+]] = extractvalue %swift.metadata_response [[RESPONSE]], 0
462+
// CHECK: call swiftcc void @"$s24moveonly_value_functions18EmptyDeinitingNC_1VAARiczrlEfD"(
463+
// CHECK-SAME: ptr [[METADATA]])
464+
// CHECK: }
465+

0 commit comments

Comments
 (0)