Skip to content

Commit 2572885

Browse files
committed
GenericSpecialization: change how new specialized witness tables are added to MandatoryPerformanceOptimization's worklist
Do it by passing a closure instead of returning the new witness table. This allows to add more than one new witness table to the worklist
1 parent f7aaf58 commit 2572885

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

SwiftCompilerSources/Sources/Optimizer/ModulePasses/MandatoryPerformanceOptimizations.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ private func specializeWitnessTables(for initExRef: InitExistentialRefInst, _ co
271271
let origWitnessTable = context.lookupWitnessTable(for: conformance)
272272
if conformance.isSpecialized {
273273
if origWitnessTable == nil {
274-
let wt = specializeWitnessTable(forConformance: conformance, errorLocation: initExRef.location, context)
275-
worklist.addWitnessMethods(of: wt)
274+
specializeWitnessTable(forConformance: conformance, errorLocation: initExRef.location, context) {
275+
worklist.addWitnessMethods(of: $0)
276+
}
276277
}
277278
} else if let origWitnessTable {
278279
checkForGenericMethods(in: origWitnessTable, errorLocation: initExRef.location, context)

SwiftCompilerSources/Sources/Optimizer/Utilities/GenericSpecialization.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ func specializeVTablesOfSuperclasses(_ moduleContext: ModulePassContext) {
7878

7979
func specializeWitnessTable(forConformance conformance: Conformance,
8080
errorLocation: Location,
81-
_ context: ModulePassContext) -> WitnessTable
81+
_ context: ModulePassContext,
82+
_ notifyNewWitnessTable: (WitnessTable) -> ())
8283
{
8384
let genericConformance = conformance.genericConformance
8485
guard let witnessTable = context.lookupWitnessTable(for: genericConformance) else {
@@ -107,5 +108,7 @@ func specializeWitnessTable(forConformance conformance: Conformance,
107108
}
108109
return origEntry
109110
}
110-
return context.createWitnessTable(entries: newEntries, conformance: conformance, linkage: .shared, serialized: false)
111+
let newWT = context.createWitnessTable(entries: newEntries,conformance: conformance,
112+
linkage: .shared, serialized: false)
113+
notifyNewWitnessTable(newWT)
111114
}

0 commit comments

Comments
 (0)