Skip to content

IRGen: Force emission of lazy witness table when conformance descriptor is referenced [5.0] #20761

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
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
2 changes: 2 additions & 0 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3539,6 +3539,8 @@ llvm::GlobalValue *IRGenModule::defineAssociatedConformanceDescriptor(
llvm::Constant *IRGenModule::getAddrOfProtocolConformanceDescriptor(
const RootProtocolConformance *conformance,
ConstantInit definition) {
IRGen.addLazyWitnessTable(conformance);

auto entity = LinkEntity::forProtocolConformanceDescriptor(conformance);
return getAddrOfLLVMVariable(entity, definition,
DebugTypeInfo());
Expand Down
41 changes: 41 additions & 0 deletions test/IRGen/lazy_conformances.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// RUN: %target-swift-frontend -parse-as-library -O %s -emit-ir | %FileCheck %s

// CHECK: @"$s17lazy_conformances12MyCollectionVyxGSKAASKRzrlMc" = hidden constant {
// CHECK: @"$s17lazy_conformances12MyCollectionVyxGSTAAMc" = hidden constant {

struct MyCollection<Base : Collection> : Collection {
typealias Index = Base.Index
typealias Element = Base.Element

var startIndex: Index {
fatalError()
}

var endIndex: Index {
fatalError()
}

func index(after i: Index) -> Index {
fatalError()
}

func formIndex(after i: inout Index) {
fatalError()
}

subscript(position: Index) -> Element {
fatalError()
}
}

extension MyCollection : BidirectionalCollection
where Base : BidirectionalCollection
{
func index(before i: Index) -> Index {
fatalError()
}

func formIndex(before i: inout Index) {
fatalError()
}
}