mirror of
https://github.com/apple/swift.git
synced 2026-10-04 11:58:22 +02:00
When ClosureSpecialization specializes a callee that is called with both, an escaping closure (`partial_apply`) and a non-escaping on-stack closure (`partial_apply [on_stack]`), the two specializations must have distinct mangled names because they have distinct parameter ownership conventions: the escaping version takes @owned captures, the non-escaping version takes @guaranteed captures. Previously, mangleClosureProp used 'c' for both cases, causing a name collision. The second specialization would look up and reuse the first specialized function, producing a call with mismatched ownership (e.g. passing a @guaranteed value to an @owned parameter). Fix: introduce a new ARG-SPEC-KIND token 'E' (`EscapingClosureProp`) for escaping `partial_apply` closures, keeping 'c' exclusively for `partial_apply [on-stack]` (non-escaping) closures. Each specialization now gets a unique name and the correct parameter conventions, preventing the collision regardless of processing order. Mangling schemes of function specializations which are produced by the optimizer are not part of the ABI, therefore this mangling change is not ABI breaking. Fixes a compiler crash https://github.com/swiftlang/swift/issues/90011 rdar://179906047