diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ClosureSpecialization.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ClosureSpecialization.swift index e0c1a4928a042..19f41dac5c0c3 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ClosureSpecialization.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ClosureSpecialization.swift @@ -503,6 +503,12 @@ private func handleApplies(for rootClosure: SingleValueInstruction, callSiteMap: continue } + // Workaround for a problem with OSSA: https://github.com/swiftlang/swift/issues/78847 + // TODO: remove this if-statement once the underlying problem is fixed. + if callee.hasOwnership { + continue + } + if callee.isDefinedExternally { continue } diff --git a/lib/SILOptimizer/SILCombiner/SILCombinerCastVisitors.cpp b/lib/SILOptimizer/SILCombiner/SILCombinerCastVisitors.cpp index fd0c76e6985bf..fe92106003fa8 100644 --- a/lib/SILOptimizer/SILCombiner/SILCombinerCastVisitors.cpp +++ b/lib/SILOptimizer/SILCombiner/SILCombinerCastVisitors.cpp @@ -1020,6 +1020,11 @@ SILCombiner::visitConvertFunctionInst(ConvertFunctionInst *cfi) { // %vjp' = convert_function %vjp // %y = differentiable_function(%orig', %jvp', %vjp') if (auto *DFI = dyn_cast(cfi->getOperand())) { + // Workaround for a problem with OSSA: https://github.com/swiftlang/swift/issues/78848 + // TODO: remove this if-statement once the underlying problem is fixed. + if (cfi->getFunction()->hasOwnership()) + return nullptr; + auto createConvertFunctionOfComponent = [&](NormalDifferentiableFunctionTypeComponent extractee) { if (!DFI->hasExtractee(extractee))