Skip to content

Commit 4e4e047

Browse files
authored
Merge pull request swiftlang#68150 from meg-gupta/fixinline
Don't inline non-ossa function into an ossa function in mandatory inlining
2 parents 47b728e + 9f93ba0 commit 4e4e047

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/ModulePasses/MandatoryPerformanceOptimizations.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,17 @@ private func shouldInline(apply: FullApplySite, callee: Function, alreadyInlined
123123
if callee.isTransparent {
124124
return true
125125
}
126+
127+
if apply.parentFunction.hasOwnership && !callee.hasOwnership {
128+
// Cannot inline a non-ossa function into an ossa function
129+
return false
130+
}
131+
126132
if apply is BeginApplyInst {
127133
// Avoid co-routines because they might allocate (their context).
128134
return true
129135
}
136+
130137
if apply.parentFunction.isGlobalInitOnceFunction && callee.inlineStrategy == .always {
131138
// Some arithmetic operations, like integer conversions, are not transparent but `inline(__always)`.
132139
// Force inlining them in global initializers so that it's possible to statically initialize the global.

0 commit comments

Comments
 (0)