Commit Graph

7449 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
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
Ben Cohen
58f661cfba Allow Equatable: ~Escapable (#85854)
Adds `~Escapable` to #85746
2025-12-08 09:50:50 -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
Michael Gottesman
e1cc41a372 [irgen] Add test for b6dfb30f1e.
This is a new file I added and while cleaning up my commit tree, it got dropped.
Just committing it separately now.
2025-12-03 12:42:39 -08:00
Ben Cohen
fbb420f38d Allow Equatable: ~Copyable (#85746)
Under review
[here](https://forums.swift.org/t/se-0499-support-copyable-escapable-in-simple-standard-library-protocols/83297).
Multi-part version of #85079.
2025-12-03 05:45:38 -08: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
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
Ryan Mansfield
625458d5d7 [Test] Add missing .ptrauth patterns to test/IRGen/builtins.swift
Add optional .ptrauth suffix patterns for arm64e pointer authentication.
2025-11-22 14:11:56 -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
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
Arnold Schwaighofer
9b7dafbcb1 Test case 2025-11-19 11:26:49 -08:00
Dario Rexin
7b02395192 Merge pull request #85566 from drexin/wip-163794474
[Test] Make IRGen/coroutine_accessors.swift more resilient against co…
2025-11-19 08:27:02 -08:00
Dario Rexin
c7aa2df73e [Test] Fix test/IRGen/builtins.swift for arm64e
rdar://164236484

Added optional .ptrauth suffix to make the test pass on arm64e
2025-11-18 11:56:06 -08:00
Dario Rexin
a8bddeedb8 [Test] Make IRGen/coroutine_accessors.swift more resilient against code gen changes
rdar://163794474

The sequence number in duplicate symbol names is not relevant for the test, so we should not check for the specific number
2025-11-18 11:41:57 -08:00
Yuta Saito
8748213d52 Merge pull request #85524 from kateinoigakukun/yt/fix-non-reg2mem-rle-crash 2025-11-16 23:10:20 +09:00
Yuta Saito
fba5c9d1a3 test: Skip test/IRGen/moveonly_value_functions.swift for Wasm archs 2025-11-15 19:29:56 +00:00
Doug Gregor
a1ce6e66df Merge pull request #85498 from DougGregor/retain-calling-convention-from-c
Retain the Swift calling convention when it's on an imported C declaration
2025-11-13 21:40:03 -08:00
Doug Gregor
7517425398 Update test for Windows 2025-11-13 16:35:02 -08:00
Doug Gregor
e0139bcc0c Retain the Swift calling convention when it's on an imported C declaration
Fixes #69264.
2025-11-13 11:34:01 -08:00
Doug Gregor
669f6dc83f Merge pull request #85463 from DougGregor/autolink-multithreaded-ir
[Multi-threaded IRGen] Ensure that autolink info gets into each object file
2025-11-12 16:43:37 -08:00
Doug Gregor
cc78bb5ebf [Multi-threaded IRGen] Ensure that autolink info gets into each object file
When performing multi-threaded IRGen, all of the link libraries used
for autolinking went (only) into the first object file. If the object
files were then placed in a static archive, the autolinking would only
kick in if clients that link the static library reference something in
the first object file. This causes link failures.

Make sure that we put the autolink information into each of the object
files we create when doing multi-threaded IRGen.

Fixes the rest of rdar://162400654.
2025-11-12 11:37:19 -08:00
Doug Gregor
2002b90531 Merge pull request #85425 from DougGregor/irgen-multithreaded-lazy-global-var
[IRGen] Correctly assign lazily-emitted global variables in multi-threaded IRGen
2025-11-11 13:10:00 -08:00
Doug Gregor
bce3fa000b [IRGen] Correctly assign lazily-emitted global variables in multi-threaded IRGen
With multi-threaded IRGen, the global variables associated with "once"
initialization tokens were not getting colocated with their actual
global variables, which caused the initialization code to get split
across different files. This issue manifest as autolinking errors in
some projects.

Fixes rdar://162400654.
2025-11-10 23:08:57 -08:00
Slava Pestov
29202436ca Try to fix test/IRGen/fulfillment_map_key_equality.swift for 32-bit targets 2025-11-10 13:45:36 -05:00
Michael Gottesman
4d48b9ac78 Disable a test on 32 bit to unblock CI. 2025-11-10 10:24:03 -08:00
Doug Gregor
087aee833f Merge pull request #85396 from DougGregor/se-0497-export
[SE-0497] Implement @export attribute syntax
2025-11-08 23:46:06 -08:00
Mike Ash
cc8e6fd877 Merge pull request #85260 from mikeash/client-rr-library-rename
[Runtime] Rename ClientRetainRelease library to SwiftDirectRuntime.
2025-11-08 12:40:27 -05:00
Slava Pestov
e5e79486e0 Merge pull request #85357 from slavapestov/workaround-rdar160649141
IRGen: Terrible workaround for problem in searchNominalTypeMetadata()
2025-11-08 05:10:53 -05:00
Doug Gregor
020b69d4b6 [SE-0497] Implement @export attribute syntax
Implement the @export(implementation) and @export(interface) attributes
to replace @_alwaysEmitIntoClient and @_neverEmitIntoClient. Provide a
warning + Fix-It to start staging out the very-new
@_neverEmitIntoClient. We'll hold off on pushing folks toward
@_alwaysEmitIntoClient for a little longer.
2025-11-07 22:00:40 -08:00
Slava Pestov
1adfad0df2 IRGen: Terrible workaround for problem in searchNominalTypeMetadata()
This fixes a regression introduced by e3c8f423bc,
but the root cause was actually a subtle invariant violation
in IRGen.

FulfillmentMap's use of canonical types as keys assumes that
canonical type equality is sufficient for checking if two types
"are the same". However, this is not true when those types
contain type parameters, because two distinct type parameters
might belong to the same equivalence class.

Thus, when we take the type's context substitution map, and
apply it to each type parameter in our given list of
requirements, the substitution operation could output a
different but equivalent type parameter.

As a workaround for this problem, try to preserve the old
behavior of subst() in this specific case.

Fixes rdar://160649141.
2025-11-07 18:26:30 -05:00
Mike Ash
1898b01ce6 [Runtime] Rename ClientRetainRelease library to SwiftDirectRuntime.
This library will likely become home to other fast-path-in-client functions, so give it a more general name.
2025-11-07 16:36:29 -05:00
eeckstein
552b665a9e Merge pull request #85334 from eeckstein/mandatory-destroy-hoisting
Optimizer: make destroy hoisting a mandatory pass
2025-11-07 06:45:03 +01:00
Doug Gregor
66e7a783a6 Merge pull request #85370 from DougGregor/extern-global-variables 2025-11-06 21:40:24 -08:00
Michael Gottesman
a302d4e627 Merge pull request #85224 from gottesmm/pr-6cb303a9f5f15489fa44c26d00c70155a6d7cc97
[concurrency] Create builtins for invoking specific concurrency runtime functions.
2025-11-06 20:33:16 -08:00
Erik Eckstein
62786b01e2 Optimizer: add the mandatory destroy hoisting pass
It hoists `destroy_value` instructions for non-lexical values.

```
  %1 = some_ownedValue
  ...
  last_use(%1)
  ... // other instructions
  destroy_value %1
```
->
```
  %1 = some_ownedValue
  ...
  last_use(%1)
  destroy_value %1    // <- moved after the last use
  ... // other instructions
```

In contrast to non-mandatory optimization passes, this is the only pass which hoists destroys over deinit-barriers.
This ensures consistent behavior in -Onone and optimized builds.
2025-11-06 21:00:44 +01:00
Doug Gregor
5b642f548f Extend @_extern to global and static variables
Allow external declaration of global variables via `@_extern(c)`. Such
variables need to have types represented in C (of course), have only
storage (no accessors), and cannot have initializers. At the SIL
level, we use the SIL asmname attribute to get the appropriate C name.

While here, slightly shore up the `@_extern(c)` checking, which should
fix issue #70776 / rdar://153515764.
2025-11-06 11:09:31 -08:00
Arnold Schwaighofer
05a32161de Merge pull request #85220 from nate-chandler/test/20251030/1
[Test] Fix these arm64e check lines.
2025-11-05 16:28:13 -08:00
Michael Gottesman
97b0e2ebae [concurrency] Create builtins for invoking specific concurrency runtime functions.
Specifically:

1. swift_task_addCancellationHandler
2. swift_task_removeCancellationHandler
3. swift_task_addPriorityEscalationHandler
4. swift_task_removePriorityEscalationHandler
5. swift_task_localValuePush
6. swift_task_localValuePop

rdar://109850951
2025-11-05 11:03:44 -08:00
John McCall
13937fdb4e Merge pull request #84528 from rjmccall/async-let-runtime-realism
Model async let begin/finish as builtins in SIL
2025-11-05 10:24:46 -08:00
Arnold Schwaighofer
a38adb3a20 Merge pull request #85207 from nate-chandler/general-coro/20251023/1
[CoroutineAccessors] Use typed-malloc.
2025-11-04 09:41:01 -08:00
John McCall
a7d7970e29 Turn finishAsyncLet into a builtin.
This is necessary because we need to model its stack-allocation
behavior, although I'm not yet doing that in this patch because
StackNesting first needs to be taught to not try to move the
deallocation.

I'm not convinced that `async let` *should* be doing a stack allocation,
but it undoubtedly *is* doing a stack allocation, and until we have an
alternative to that, we will need to model it properly.
2025-11-03 16:33:40 -08:00
Anthony Latsis
b0548203e2 [test] Clean up a few more nocapture in tests 2025-11-02 08:28:54 +00:00
Alexis Laferrière
048c9276a9 Merge pull request #85122 from xymus/official-c-attr
SE-495: Make `@c` an official feature
2025-10-30 16:06:25 -07:00
Nate Chandler
b594b82c62 [Test] Fix these arm64e check lines. 2025-10-30 11:49:13 -07:00
Nate Chandler
e0ead75622 [CoroutineAccessors] Use typed-malloc. 2025-10-30 03:59:18 -07:00
Alexis Laferrière
94113f4a83 SE-496: Remove references to features CDecl and CImplementation 2025-10-29 17:31:20 -07:00
Anthony Latsis
e0ca132af2 Merge pull request #85102 from swiftlang/jepa-main2
[test] Remove pre-rebranch `nocapture` matches
2025-10-29 22:21:38 +00:00
Yuta Saito
3e834ccf9f Merge pull request #85106 from kateinoigakukun/yt/fix-dead-stub-comdat-wasm
[wasm][IRGen] Stop attaching COMDATs to dead stub methods
2025-10-29 15:29:48 +09:00