Skip to content

Commit a76ee5e

Browse files
authored
Merge pull request #83391 from eeckstein/fix-wt-specialization
embedded: don't try to specialize witness tables for abstract conformances
2 parents cda069f + 8ac25d9 commit a76ee5e

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/GenericSpecialization.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ func specializeWitnessTable(for conformance: Conformance,
116116
return
117117
}
118118

119+
guard conformance.isConcrete else {
120+
// If the conformance is abstract the witness table is specialized elsewhere - at the
121+
// place where the concrete conformance is referenced.
122+
return
123+
}
124+
119125
let baseConf = conformance.isInherited ? conformance.inheritedConformance: conformance
120126
if !baseConf.isSpecialized {
121127
var visited = Set<Conformance>()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -disable-availability-checking -module-name test -parse-as-library %s -emit-ir | %FileCheck %s
2+
3+
// REQUIRES: OS=macosx
4+
// REQUIRES: swift_feature_Embedded
5+
6+
import _Concurrency
7+
8+
public var e: (any TaskExecutor)? = nil
9+
10+
// CHECK-LABEL: define {{.*}}@"$e4test6testits19UnownedTaskExecutorVyF"()
11+
// CHECK: [[EXISTENTIAL_ADDR:%.*]] = call {{.*}}"$e4test1eSch_pSgvau"
12+
// CHECK: [[INSTANCE_ADDR:%.*]] = getelementptr {{.*}}[[EXISTENTIAL_ADDR]]{{, i[0-9]+ 0, i[0-9]+ 0}}
13+
// CHECK: [[INSTANCE:%.*]] = load {{.*}}ptr [[INSTANCE_ADDR]]
14+
// CHECK: [[CONFORMANCE_ADDR:%.*]] = getelementptr {{.*}}[[EXISTENTIAL_ADDR]]{{, i[0-9]+ 0, i[0-9]+ 1}}
15+
// CHECK: [[CONFORMANCE:%.*]] = load {{.*}}ptr [[CONFORMANCE_ADDR]]
16+
// CHECK: {{^[0-9a-z]+:}}
17+
// CHECK: [[INSTANCE_PTR:%.*]] = inttoptr {{i[0-9]+}} [[INSTANCE]]
18+
// CHECK: [[CONFORMANCE_PTR:%.*]] = inttoptr {{i[0-9]+}} [[CONFORMANCE]]
19+
// CHECK: [[INSTANCE_PHI:%.*]] = phi ptr [ [[INSTANCE_PTR]]
20+
// CHECK: [[CONFORMANCE_PHI:%.*]] = phi ptr [ [[CONFORMANCE_PTR]]
21+
// CHECK: [[INSTANCE_ISA:%.*]] = load ptr, ptr [[INSTANCE_PHI]]
22+
// CHECK: call {{.*}}@"$es19UnownedTaskExecutorVyABxhcSchRzlufC"(ptr [[INSTANCE_PHI]], ptr [[INSTANCE_ISA]], ptr [[CONFORMANCE_PHI]])
23+
// CHECK-LABEL: {{^}}}
24+
public func testit() -> UnownedTaskExecutor {
25+
return unsafe UnownedTaskExecutor(e!)
26+
}
27+

0 commit comments

Comments
 (0)