Skip to content

[IRGen] Collect metadata for empty fields. #72210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lib/IRGen/GenArchetype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,33 @@ llvm::Value *irgen::emitArchetypeWitnessTableRef(IRGenFunction &IGF,
rootWTable = emitOpaqueTypeWitnessTableRef(IGF, opaqueRoot,
rootProtocol);
}
#ifndef NDEBUG
if (!rootWTable) {
llvm::errs()
<< "Root witness table not bound in function.\n"
<< " The witness table could be missing entirely because it needs "
"to be passed to the function.\n"
<< " Or the witness table is present and not bound in which case "
"setScopedLocalTypeData or similar must be called.\n";
llvm::errs() << "Root archetype for conformance: " << rootArchetype
<< "\n";
rootArchetype->dump(llvm::errs());
llvm::errs() << "Root protocol without wtable: " << rootProtocol << "\n";
rootProtocol->dump(llvm::errs());
llvm::errs() << "Archetype for conformance: " << archetype << "\n";
archetype->dump(llvm::errs());
llvm::errs() << "Protocol for conformance: " << protocol << "\n";
protocol->dump(llvm::errs());
llvm::errs() << "Function:\n";
IGF.CurFn->print(llvm::errs());
if (auto localTypeData = IGF.getLocalTypeData()) {
llvm::errs() << "LocalTypeData:\n";
localTypeData->dump();
} else {
llvm::errs() << "No LocalTypeDataCache for this function!\n";
}
}
#endif
assert(rootWTable && "root witness table not bound in local context!");
}

Expand Down
2 changes: 0 additions & 2 deletions lib/IRGen/GenRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,6 @@ class RecordTypeInfoImpl : public Base,
void collectMetadataForOutlining(OutliningMetadataCollector &collector,
SILType T) const override {
for (auto &field : getFields()) {
if (field.isEmpty())
continue;
auto fType = field.getType(collector.IGF.IGM, T);
field.getTypeInfo().collectMetadataForOutlining(collector, fType);
}
Expand Down
23 changes: 23 additions & 0 deletions test/IRGen/moveonly_value_functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,26 @@ public func takeOuterMultiPayloadNC_3<T>(_ e: consuming OuterMultiPayloadNC_3<T>
// CHECK-SAME: ptr noalias swiftself %0)
// CHECK: }
public func takeOuterMultiPayloadNC_4<T>(_ e: consuming OuterMultiPayloadNC_4<T>) {}

public struct EmptyDeinitingNC_1<Wrapped: ~Copyable>: ~Copyable {
deinit {}
}

public enum SinglePayloadNC_1<Element: Equatable>: ~Copyable {
case empty
case node(EmptyDeinitingNC_1<Self>, Element)
}
// CHECK-LABEL: define{{.*}} @"$s24moveonly_value_functions18EmptyDeinitingNC_1VyAA013SinglePayloadF2_1OyxGG_xtSQRzlWOh"(
// CHECK-SAME: ptr %0,
// CHECK-SAME: ptr %Element,
// CHECK-SAME: ptr %Element.Equatable)
// CHECK-SAME: {
// CHECK: [[RESPONSE:%[^,]+]] = call swiftcc %swift.metadata_response @"$s24moveonly_value_functions17SinglePayloadNC_1OMa"(
// : i64 0,
// CHECK-SAME: ptr %Element,
// CHECK-SAME: ptr %Element.Equatable)
// CHECK: [[METADATA:%[^,]+]] = extractvalue %swift.metadata_response [[RESPONSE]], 0
// CHECK: call swiftcc void @"$s24moveonly_value_functions18EmptyDeinitingNC_1VAARiczrlEfD"(
// CHECK-SAME: ptr [[METADATA]])
// CHECK: }