mirror of
https://github.com/apple/swift.git
synced 2026-10-04 11:58:22 +02:00
SwiftMergeFunctions appends the differing constant as a new parameter at the position defined by the callee, and replaceDirectCallers rebuilds each direct call by forwarding the call site's own arguments and then appending the constant. This assumes the call site's function type matches the callee definition. That does not hold for a @_silgen_name declaration whose C prototype omits part of the Swift ABI -- for example the indirect error result of a function with a large typed throws. The call site then has fewer parameters than the definition, so the appended constant lands in the wrong argument slot and the merged callee reads it from a different register than the caller passes it in, crashing at runtime. Skip such call sites so a thunk is emitted instead. The thunk forwards the definition's own arguments and appends the constant in the correct position.