Skip to content

Commit 252a204

Browse files
authored
Merge pull request #20761 from slavapestov/overly-lazy-witness-table-emission-5.0
IRGen: Force emission of lazy witness table when conformance descriptor is referenced [5.0]
2 parents 692a0d4 + b9c89ec commit 252a204

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3539,6 +3539,8 @@ llvm::GlobalValue *IRGenModule::defineAssociatedConformanceDescriptor(
35393539
llvm::Constant *IRGenModule::getAddrOfProtocolConformanceDescriptor(
35403540
const RootProtocolConformance *conformance,
35413541
ConstantInit definition) {
3542+
IRGen.addLazyWitnessTable(conformance);
3543+
35423544
auto entity = LinkEntity::forProtocolConformanceDescriptor(conformance);
35433545
return getAddrOfLLVMVariable(entity, definition,
35443546
DebugTypeInfo());

test/IRGen/lazy_conformances.swift

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %target-swift-frontend -parse-as-library -O %s -emit-ir | %FileCheck %s
2+
3+
// CHECK: @"$s17lazy_conformances12MyCollectionVyxGSKAASKRzrlMc" = hidden constant {
4+
// CHECK: @"$s17lazy_conformances12MyCollectionVyxGSTAAMc" = hidden constant {
5+
6+
struct MyCollection<Base : Collection> : Collection {
7+
typealias Index = Base.Index
8+
typealias Element = Base.Element
9+
10+
var startIndex: Index {
11+
fatalError()
12+
}
13+
14+
var endIndex: Index {
15+
fatalError()
16+
}
17+
18+
func index(after i: Index) -> Index {
19+
fatalError()
20+
}
21+
22+
func formIndex(after i: inout Index) {
23+
fatalError()
24+
}
25+
26+
subscript(position: Index) -> Element {
27+
fatalError()
28+
}
29+
}
30+
31+
extension MyCollection : BidirectionalCollection
32+
where Base : BidirectionalCollection
33+
{
34+
func index(before i: Index) -> Index {
35+
fatalError()
36+
}
37+
38+
func formIndex(before i: inout Index) {
39+
fatalError()
40+
}
41+
}

0 commit comments

Comments
 (0)