Skip to content

Commit 75f8041

Browse files
authored
Run closure specialization only if ownership info is present in callee (#84956)
Calling `cloneRecursively` from `SpecializationInfo.cloneClosures` requires the callee having ownership info. Otherwise, the cloner uses `recordFoldedValue` instead of `recordClonedInstruction`, and `postProcess` hook is not called, which leads to an assertion failure in `BridgedClonerImpl::cloneInst`.
1 parent 3c1f3d5 commit 75f8041

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ClosureSpecialization.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ private func isCalleeSpecializable(of apply: ApplySite) -> Bool {
224224
if let callee = apply.referencedFunction,
225225
callee.isDefinition,
226226

227+
// Calling `cloneRecursively` from `SpecializationInfo.cloneClosures`
228+
// requires the callee having ownership info. Otherwise, the cloner
229+
// uses `recordFoldedValue` instead of `recordClonedInstruction`, and
230+
// `postProcess` hook is not called, which leads to an assertion
231+
// failure in `BridgedClonerImpl::cloneInst`.
232+
callee.hasOwnership,
233+
227234
// We don't support generic functions (yet)
228235
!apply.hasSubstitutions,
229236

0 commit comments

Comments
 (0)