Commit Graph

13278 Commits

Author SHA1 Message Date
Dario Rexin
1f8e88d659 Merge pull request #85908 from drexin/wip-163631865
[IRGen] Use proper linkage for async function pointers to partial app…
2025-12-11 09:52:51 -08:00
Arnold Schwaighofer
be78127c23 Merge pull request #85923 from aschwaighofer/embedded_existentials_requires_embedded
[embedded] Feature::EmbeddedExistentials requires Feature::Embedded
2025-12-10 07:13:45 -08:00
Arnold Schwaighofer
4730181c7a Merge pull request #85914 from aschwaighofer/embedded_foreign_type_metadata
[embedded] Add support for some foreign metadata
2025-12-10 06:58:55 -08:00
Egor Zhdan
ad56e061af Merge pull request #85066 from egorzhdan/egorzhdan/std-function-context
[cxx-interop] Allow initializing `std::function` from Swift capturing closures
2025-12-10 13:35:34 +00:00
Arnold Schwaighofer
4d879967a7 [embedded] Feature::EmbeddedExistentials requires Feature::Embedded 2025-12-09 10:21:51 -08:00
Arnold Schwaighofer
d06929ccd2 [embedded] Add support for some foreign metadata 2025-12-08 15:35:43 -08:00
Dario Rexin
0fdca11e46 [IRGen] Use proper linkage for async function pointers to partial apply forwarders
rdar://163631865

Under certain circumstances the same symbol can be used for different implementations of the forwarders.
The forwarders themselves are already emitted with "internal" LLVM linkage, but some particularities in
the mapping from SILLinkage to LLVM linkage caused async function pointers to partial apply forwarders
to be emitted with linkonce_odr instead, which caused the wrong forwarder to be called at runtime, causing
unexpected behavior and crashes.
2025-12-08 11:30:22 -08:00
Arnold Schwaighofer
4764ad70e7 Fix typos/needless whitespace 2025-12-05 13:10:54 -08:00
Arnold Schwaighofer
81dfb754ba [embedded] Apply shared linkage to metadata of public types in embedded with existential mode
We generate public metadata lazily which implies it could be emitted into a
different module. If we emit metadata for a public type into a module
other than its "home module" apply "shared" linkage.
2025-12-05 13:03:34 -08:00
Arnold Schwaighofer
93ab16283b [embedded] Lazily emit class metadata in embedded mode 2025-12-05 09:03:16 -08:00
Arnold Schwaighofer
055f3e074d Merge pull request #85838 from aschwaighofer/embedded_exist_deferred_codegen
[embedded] When using existentials in embedded value witness tables can also have non unique definitions
2025-12-05 05:15:02 -08:00
Dan Blackwell
161d00f803 [Sanitizers] Add support for -sanitize=memtag-stack (#85515)
This sanitizer adds MTE (memory tagging extension) checks to stack
variable accesses. Enablement simply requires setting an attribute on
function definitions, and the instrumentation is added by LLVM.

The corresponding swift-driver change is at:
https://github.com/swiftlang/swift-driver/pull/2016.

rdar://161721201
2025-12-05 08:51:42 +00:00
Arnold Schwaighofer
729cc1e08f [embedded] When using existentials in embedded value witness tables can also have non unique definitions 2025-12-04 09:11:50 -08:00
Egor Zhdan
11d7c1ed12 Refactor: create SILFunctionType::getPointerAuthDiscriminator 2025-12-04 12:07:01 +00:00
Egor Zhdan
76c7be7cad Refactor: introduce SILModule::getMaximalTypeExpansionContext() 2025-12-04 12:06:58 +00:00
Becca Royal-Gordon
f0d4c7e4b7 [NFC] [IRGen] Move construction of CalleeInfo
rdar://149982943
2025-12-03 15:09:57 -08:00
Adrian Prantl
1cd15edcc9 Merge pull request #85796 from felipepiovezan/felipe/cherry_pick_dbgdeclarevalue_swift_main
[IRGenDebugInfo] Replace llvm.dbg.coroframe_entry with dbg.declare_value
2025-12-03 10:59:25 -08:00
Ryan Mansfield
0488a419e8 Merge pull request #84297 from rjmansfield/use-platform-unknown
Update getBaseMachOPlatformID to use llvm::MachO::PLATFORM_UNKNOWN.
2025-12-02 15:08:57 -05:00
Felipe de Azevedo Piovezan
0cff9c7b95 [IRGenDebugInfo] Replace llvm.dbg.coroframe_entry with dbg.declare_value
We had introduced coroframe_entry downstream while the upstream proposal
was discussed. It has since been merged upstream, so this commit changes
the code to use the upstream intrisic, avoiding a binary incompatibility
in the IR w.r.t. upstream.
2025-12-02 17:09:17 +00:00
Susana Monteiro
fd6e6b35a6 Merge pull request #85642 from susmonteiro/susmonteiro/reapply-implicit-constructors
[cxx-interop] Reapply implicitly defined copy and move constructors
2025-12-02 14:23:00 +00:00
Kavon Farvardin
1f696739ef Merge pull request #85450 from kavon/keypath-metadata-fix
IRGen/ABI: fix count of requirements in getAddrOfGenericEnvironment
2025-12-02 03:23:49 -08:00
susmonteiro
fbfcd4d241 [cxx-interop] Implicitly defined copy and move constructors 2025-12-02 09:15:37 +00:00
Arnold Schwaighofer
36a3c6e611 Merge pull request #85644 from aschwaighofer/wip_embedded_exits_with_eriks_changes_v1
[embedded] Fix associated type conformances for specialized witness tables
2025-12-01 16:40:31 -08:00
Kavon Farvardin
38af19b95a IRGen/ABI: fix count of requirements in getAddrOfGenericEnvironment
`irgen::addGenericRequirements` will later filter out Copyable
and Escapable requirements, so this field's count isn't accurate
if it's using the pre-filtered number.

This should in theory only affect the metadata emission for keypaths,
specifically, the caller `IRGenModule::getAddrOfKeyPathPattern`.
2025-12-01 15:07:34 -08:00
Michael Gottesman
24c69c674d Merge pull request #85604 from gottesmm/alloc_stack_non_nested
[irgen] Implement support for alloc_stack non_nested.
2025-12-01 09:38:06 -08:00
Adrian Prantl
80c8bf0591 Merge pull request #85655 from adrian-prantl/161134092
[Debug Info] Represent type alias existantials in debug info
2025-12-01 08:42:22 -08:00
Arnold Schwaighofer
a71e3d92cd [embedded] Use the type witness from the specialized conformance
rather then the specialized conformance's root conformance (which is the  variable's value)
2025-12-01 07:41:28 -08:00
Anthony Latsis
3e54e64b5d IRGen: Add fixed underlying type to enum to avoid UB
See https://github.com/llvm/llvm-project/pull/150308.
2025-11-24 08:30:12 +00:00
Anthony Latsis
4ed38554a0 IRGen: Address llvm::TargetRegistry::lookupTarget deprecation
See https://github.com/llvm/llvm-project/pull/162188.
2025-11-24 06:26:48 +00:00
Adrian Prantl
45547be3f8 [Debug Info] Represent type alias existantials in debug info
Previously debug info made not difference between an existential type and a
protocol type. This caused us to loose typealiases such as

typealias Alias = ProtocolType

in the debug info.

rdar://161134092
2025-11-21 15:17:47 -08:00
Arnold Schwaighofer
b9f6454386 [embedded] Add support for storing/casting function types 2025-11-21 14:55:32 -08:00
Michael Gottesman
b6dfb30f1e [irgen] Add support for alloc_stack [non_nested]. 2025-11-21 11:21:15 -08:00
Arnold Schwaighofer
1b6da50ed9 Merge pull request #85602 from aschwaighofer/wip_embedded_exit_cast
[embedded] Implement swift_dynamicCast suport for casts from existential to concrete type
2025-11-20 21:01:41 -05:00
Xi Ge
be5d4b3747 Merge pull request #85600 from nkcsgexi/159408187
OriginallyDefinedIn: always use 1.0 as the starting platform version for $ld$previous directives
2025-11-20 14:33:03 -08:00
Arnold Schwaighofer
ffca3b4623 [embedded] Fix associate type conformances involving specialized conformances 2025-11-20 13:10:44 -08:00
Xi Ge
db1b398ea0 OriginallyDefinedIn: always use 1.0 as the starting platform version for $ld$previous directives
Before this change, we were sometimes using introductory platform version as the starting version where
a symbol is considered belonging to the original binary. However, this is insufficient
because backdeploying to a platform version prior to a symbol's introductory version can happen. When it
happens, we should expect the moved symbol to be found in the moved-from library, not the moved-to one. Expecting
the symbol to be found in the moved-to library can lead to crasher.

Resolves: rdar://159408187
2025-11-20 09:19:28 -08:00
Arnold Schwaighofer
d0df11069f Merge pull request #85595 from aschwaighofer/irgen_specialized_metadata_vw_nested_types
IRGen: Detect nested generic types during generation of the vwt of specialized metadata
2025-11-20 08:24:26 -05:00
Slava Pestov
bfb6c826c4 Merge pull request #85560 from slavapestov/fix-ridiculous-irgen-thing
IRGen: Remove unsafe usage of static variable
2025-11-20 02:54:38 -05:00
Arnold Schwaighofer
3cff05d540 [embedded] Implement swift_dynamicCast suport for casts from existential to concrete type 2025-11-19 14:41:37 -08:00
Zixu Wang
5221e7bd0c [APIGen] Mark symbols from non-API level library as private (#85553)
All symbols are private (as in the API descriptor) if the library level
is more restricted than `LibraryLevel::API`.

Resolves rdar://164901718

<!--
If this pull request is targeting a release branch, please fill out the
following form:

https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1

Otherwise, replace this comment with a description of your changes and
rationale. Provide links to external references/discussions if
appropriate.
If this pull request resolves any GitHub issues, link them like so:

  Resolves <link to issue>, resolves <link to another issue>.

For more information about linking a pull request to an issue, see:

https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->

<!--
Before merging this pull request, you must run the Swift continuous
integration tests.
For information about triggering CI builds via @swift-ci, see:

https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci

Thank you for your contribution to Swift!
-->
2025-11-19 13:38:40 -08:00
Arnold Schwaighofer
3292aaa618 IRGen: Detect nested generic types during generation of the vwt of specialized metadata
The previous code would not detect Container<T>.NonFixed but only NonFixed<T>.
For code size reasons we want to use the generic value witness functions rather than specialized ones in specialized metadata.
2025-11-19 11:30:09 -08:00
Slava Pestov
ca0f310242 IRGen: Remove unsafe usage of static variable
We cannot use 'static' linkage for something that points into the
ASTContext, because there might be more than one ASTContext in a
single process.

Also, fix the spelling mistake in a related function name.
2025-11-19 10:19:18 -05:00
Arnold Schwaighofer
17447a3378 Merge pull request #85551 from aschwaighofer/wip_embedded_exit
Preliminary support for existential in embedded Swift
2025-11-18 15:10:40 -05:00
Steven Wu
b56f541732 Merge pull request #85499 from cachemeifyoucan/eng/PR-164409895
[Caching] Fix multi-threaded WMO with MCCAS
2025-11-18 09:22:13 -08:00
Arnold Schwaighofer
a725de5ba6 Address review comments 2025-11-17 15:52:00 -08:00
Arnold Schwaighofer
62ac48a17e Complete support for outline existential storage
... or so I believe
2025-11-17 12:48:45 -08:00
Arnold Schwaighofer
93bc84e8e0 Start support for associated conformances
We need to add a version of swift_allocBox to the embedded runtime implementation for outline storage
2025-11-17 12:46:35 -08:00
Arnold Schwaighofer
f38ad4b09f Start support for protocol witness tables 2025-11-17 12:46:35 -08:00
Arnold Schwaighofer
4285a2169d IRGen: Start support for embedded existentials
Allow storing struct, enum, and tuple types in an any.
2025-11-17 12:46:35 -08:00
Anthony Latsis
dd5ac838e5 AST: Properly disallow isa/cast/dyn_cast on Type
We currently disallow these by deleting them in the `swift` namespace.
This approach has several loopholes, all of which ultimately work
because we happen to define specializations of `simplify_type` for
`swift::Type`:
* `llvm::isa/cast/dyn_cast`. The deleted partial specializations will
  not be selected because they are not defined in the `llvm` namespace.
* The argument is a non-const `Type`. The deleted function templates
  will not be selected because they all accept a `const Type &`, and
  there is a better `Y &Val` partial specialization in LLVM.
* Other casting function templates such as `isa_and_nonull` and
  `cast_if_present` are not deleted.

Eliminate these loopholes by instead triggering a static assertion
failure with a helpful message upon instantiation of `CastInfo` for
`swift::Type`.
2025-11-14 19:02:41 +00:00