Skip to content

Commit ba6cd77

Browse files
Merge pull request #72210 from nate-chandler/rdar123577998
[IRGen] Collect metadata for empty types fields.
2 parents cf619e2 + 34dd4aa commit ba6cd77

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

lib/IRGen/GenArchetype.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,33 @@ llvm::Value *irgen::emitArchetypeWitnessTableRef(IRGenFunction &IGF,
274274
rootWTable = emitOpaqueTypeWitnessTableRef(IGF, opaqueRoot,
275275
rootProtocol);
276276
}
277+
#ifndef NDEBUG
278+
if (!rootWTable) {
279+
llvm::errs()
280+
<< "Root witness table not bound in function.\n"
281+
<< " The witness table could be missing entirely because it needs "
282+
"to be passed to the function.\n"
283+
<< " Or the witness table is present and not bound in which case "
284+
"setScopedLocalTypeData or similar must be called.\n";
285+
llvm::errs() << "Root archetype for conformance: " << rootArchetype
286+
<< "\n";
287+
rootArchetype->dump(llvm::errs());
288+
llvm::errs() << "Root protocol without wtable: " << rootProtocol << "\n";
289+
rootProtocol->dump(llvm::errs());
290+
llvm::errs() << "Archetype for conformance: " << archetype << "\n";
291+
archetype->dump(llvm::errs());
292+
llvm::errs() << "Protocol for conformance: " << protocol << "\n";
293+
protocol->dump(llvm::errs());
294+
llvm::errs() << "Function:\n";
295+
IGF.CurFn->print(llvm::errs());
296+
if (auto localTypeData = IGF.getLocalTypeData()) {
297+
llvm::errs() << "LocalTypeData:\n";
298+
localTypeData->dump();
299+
} else {
300+
llvm::errs() << "No LocalTypeDataCache for this function!\n";
301+
}
302+
}
303+
#endif
277304
assert(rootWTable && "root witness table not bound in local context!");
278305
}
279306

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)