Conversation
A client using Clang function types can load serialized SIL from a module built without them. Deserializing a C function or block then reaches the SIL function type invariant without the Clang type required by the client. Reconstruct missing types from the serialized SIL signature before forming the function type. Keep this compatibility handling in deserialization so other callers still have to satisfy the invariant, and preserve stored Clang types carrying non-default calling conventions.
Microsoft COM function pointers use stdcall on 32-bit Windows. Without stored Clang function types, SIL lowering erases the imported convention and indirect calls use the platform C convention. Enable Clang function types for Microsoft COM on x86 Windows so imported calling conventions survive SIL lowering and module serialization.
compnerd
requested review from
artemcm,
rjmccall and
tshortli
as code owners
September 21, 2026 20:23
Member
Author
|
@swift-ci please smoke test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the handling and preservation of C calling conventions, particularly the stdcall convention, in Swift's function type system and serialization/deserialization logic. The changes ensure that calling conventions from imported Win32 COM function types are correctly maintained across module boundaries, even when modules are built with different settings. Several new and updated tests are included to verify this behavior, especially on Windows x86 targets.
Language and Compiler Logic Improvements
CompilerInvocation.cppto automatically enable Clang function types for imported Win32 COM functions using the Microsoft COM interop model on Windows x86, ensuring the stdcall convention is preserved.Deserialization.cppto reconstruct Clang function types from SIL signatures when required, while preserving non-default calling conventions during deserialization.Testing and Verification
clang-function-types-stdcall.sil).com-clang-function-types-x86.swift).clang-function-type-skew-sil.swiftandclang-function-type-skew-block.swift). [1] [2]c-function-calling-convention.sil).These changes collectively improve ABI stability and interop correctness when dealing with C function pointers and calling conventions in Swift, especially for Windows COM scenarios.