Skip to content

Commit b9c89ec

Browse files
committed
IRGen: Force emission of lazy witness table when conformance descriptor is referenced
Otherwise with the new resilient witness table emission pattern, we might miss conformances for refined protocols, since the witness table itself is never referenced, only the conformance descriptor is. Fixes <rdar://problem/46133018>.
1 parent d9a0c3f commit b9c89ec

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)