Commit Graph

321 Commits

Author SHA1 Message Date
Pavel Yaskevich 5b6a29fd8a [Frontend] Use @caller_isolated to represent nonisolated(nonsending) isolation of SIL function type
`nonisolated(nonsending)` is a modifier and it's really hard to
work with in SIL because most of the things are represented as
attributes there.
2026-04-13 14:18:53 -07:00
Pavel Yaskevich aa59c1aaf3 [Mangling/SIL] Mangling support for nonisolated(nonsending) isolation in SIL function types 2026-04-10 09:35:30 -07:00
Mike Ash 2abf087e71 [Concurrency] Emit a distinct mangling for checked ObjC async completion handlers.
This avoids coalescing checked and unchecked handlers with the same types, which results in runtime crashes as they are not compatible.

We have a separate mangling for predefined handlers, TZ, which is unused. Repurpose this for checked handlers. Unchecked handlers keep their existing mangling with Tz.

rdar://152263818
2026-02-06 17:45:43 -05:00
Joe Groff bc166d5a8c Add a Builtin.Borrow type.
This will represent the layout of a borrow of a value.
2026-01-23 07:46:50 -08:00
Tim Kientzle 8eabeeb8ca [SE-0474] Read2/Modify2 => YieldingBorrow/YieldingMutate
This updates a large number of internal symbols, function names,
and types to match the final approved terminology.  Matching the
surface language terminology and the compiler internals should
make the code easier for people to understand into the future.
2026-01-03 16:05:12 -08:00
Erik Eckstein 4c09fa6805 Mangling: add a specialization mangling for changing the function type representation of a function 2025-11-26 16:23:47 +01:00
Erik Eckstein 89bba668e2 Mangling: add a closure specialization mangling for arguments which specialize for the same closure as a previous argument
For example:
```
  %1 = partial_apply %closure
  apply %f(%1, %1)    // first argument: `.closure(%1)`
                      // second argument: `.previousArgumentIndex(0)`
```
2025-10-06 09:47:41 +02:00
swift-ci 0d2c4ca9be Merge remote-tracking branch 'origin/main' into rebranch 2025-09-15 10:29:21 -07:00
Meghana Gupta 28c4595735 Add mangling support for borrow/mutate accessors 2025-09-09 14:30:34 -07:00
Anthony Latsis e1450e011e Manually merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
*	utils/build_swift/build_swift/defaults.py
2025-09-04 14:07:50 +01:00
Erik Eckstein 1a4bd76f95 Mangling: add specialization mangling for more complex constant propagated function arguments
So far, constant propagated arguments could only be builtin literals.
Now we support arbitrary structs (with constant arguments), e.g. `Int`.
This requires a small addition in the mangling scheme for function specializations.
Also, the de-mangling tree now looks a bit different to support a "tree" of structs and literals.
2025-09-04 08:15:44 +02:00
swift-ci 255ee32c29 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-03 13:48:19 -07:00
Adrian Prantl 75bee892be Add LLDB and swift-reflection-dump support for WebAssembly
This patch adds parsing and extracting of the Swift reflection
metadata data segments from within the WebAssembly DATA section and
tests it using swift-reflection-dump. This is needed to allow LLDB to
acces Swift reflection metadata when attached to WebAssembly
processes.

rdar://159217213
2025-08-27 17:14:17 -07:00
JanBaig ff894c4d01 [Format] Apply clang-format to recent changes 2025-08-09 12:46:18 -04:00
JanBaig 988a3dcf25 [SIL] Introduce new SILDeclRef 2025-07-29 21:16:11 -04:00
Charles Zablit 0fc436fa9d [NFC][demangling] switch to using NodePrinter::printFunctionName 2025-07-02 19:15:34 +01:00
Slava Pestov 9033198674 ASTDemangler: Round-trip @isolated @sil_implicit_leading_param parameter attributes
We sometimes mangle SILFunctionTypes when generating debug info
for reabstraction thunks, and these can have various exotic
parameter and result attributes. Two recent additions were
never plumbed through the mangler, causing assertion failures
when emitting debug info.

Fixes rdar://153730847.
2025-06-27 10:56:12 -04:00
Charles Zablit e8ea37b681 remove unused API 2025-06-24 13:03:32 +01:00
Charles Zablit 479e664a04 add new methods to the NodePrinter to enable range tracking possibilities when demangling a name 2025-06-20 15:30:19 +02:00
Charles Zablit fdde2a395d move NodePrinter declarations to a header 2025-06-18 12:21:59 +01:00
Pavel Yaskevich 8e49860349 [Demangle] Implement missing Node::Kind::OutlinedInitializeWithTakeNoValueWitness
Implements de/remangler support for `WOB` manglings.
2025-06-05 14:07:05 -07:00
Hamish Knight 5d1f219acb Change InlineArray sugar separator x -> of 2025-05-30 13:50:22 +01:00
Slava Pestov 5e23a4c2c0 Demangle: Implement missing Node::Kind::DependentProtocolConformanceOpaque
If a retroactive conformance is conditional and the subject type of a
conditional requirement is an opaque archetype, the mangler would
emit a mangling using the "HO" operator which the demangler did not
understand.

Implement de/remangler support for the "HO" operator.

Fixes rdar://149801864.
2025-04-23 16:39:16 -04:00
Pavel Yaskevich 07ff063ae3 [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-11 15:59:25 -07:00
Erik Eckstein aec1046895 swift-demangle: fix a crash for invalid input
When fed with invalid input, the swift-demangle tool crashed.

rdar://148754959
2025-04-09 08:51:30 +02:00
Artem Chikin 281f84da0f [Compile Time Values] Rewrite the 'Diagnose Unknown Compile Time Values' diagnostic pass in Swift 2025-03-28 10:30:07 -07:00
Nate Chandler 5eacbfd9d9 [DefaultOverrides] Mangling. 2025-03-25 07:22:14 -07:00
Hamish Knight f8ab391737 Introduce type sugar for InlineArray (#80087)
* [CS] Decline to handle InlineArray in shrink

Previously we would try the contextual type `(<int>, <element>)`,
which is wrong. Given we want to eliminate shrink, let's just bail.

* [Sema] Sink `ValueMatchVisitor` into `applyUnboundGenericArguments`

Make sure it's called for sugar code paths too. Also let's just always
run it since it should be a pretty cheap check.

* [Sema] Diagnose passing integer to non-integer type parameter

This was previously missed, though would have been diagnosed later
as a requirement failure.

* [Parse] Split up `canParseType` 

While here, address the FIXME in `canParseTypeSimpleOrComposition`
and only check to see if we can parse a type-simple, including
`each`, `some`, and `any` for better recovery.

* Introduce type sugar for InlineArray

Parse e.g `[3 x Int]` as type sugar for InlineArray. Gated behind
an experimental feature flag for now.
2025-03-23 15:31:37 -07:00
Amritpan Kaur 555a486cda [Mangler] Add new mangling schemes. 2025-03-19 10:54:06 -07:00
Konrad `ktoso` Malawski 8c4dea9802 Revert "[concurrency] Add support for HopToMainActorIfNeededThunk." (#79938)
* Revert "[concurrency] Add support for HopToMainActorIfNeededThunk."

This reverts commit 0e0665bfbd.

* remove some last bits of 0e0665b
2025-03-13 06:48:03 +09:00
Nate Chandler 35d06c325d [CoroutineAccessors] Witness and vtable dispatch.
And thunking.
2025-03-07 11:46:50 -08:00
Artem Chikin de26e960e2 Rename '_const' attribute to 'CompileTimeLiteral'
To pave the way for the new experimental feature which will operate on '@const' attribute and expand the scope of what's currently handled by '_const' without breaking compatibility, for now.
2025-03-04 07:30:02 -08:00
Pavel Yaskevich 1067ead82c [Mangling] Mangle presence of @execution(caller) in a function type
If `@execution(caller)` attribute is present on a function type,
mark its presence in the mangling with `YC` suffix.
2025-02-19 16:48:41 -08:00
John McCall fa932e736c Fix the demangling of sending result types when combined with isolation
Fixes the immediate problem, but the presence of demangling code in the
runtime means that we'll need a follow-up to fix the compiler so that it
doesn't try to use the demangler to materialize metadata for function types
that have both isolation and a sending result.

rdar://142443925
2025-01-10 21:11:45 -05:00
Alejandro Alonso 32259c18e2 Mangle value parameter markers and fix demangling value params 2024-10-28 16:54:16 -07:00
Joe Groff 8242110bbe Merge pull request #76831 from jckarter/builtin-vector
Builtin.FixedArray
2024-10-23 05:20:21 -10:00
Joe Groff a184782a38 Introduce a Builtin.FixedArray type.
`Builtin.FixedArray<let N: Int, T: ~Copyable & ~Escapable>` has the layout of `N` elements of type `T` laid out
sequentially in memory (with the tail padding of every element occupied by the array). This provides a primitive
on which the standard library `Vector` type can be built.
2024-10-22 16:21:45 -07:00
Michael Gottesman 0e0665bfbd [concurrency] Add support for HopToMainActorIfNeededThunk.
It is behind the experimental flag GenerateForceToMainActorThunks.
2024-10-17 13:31:39 -07:00
Michael Gottesman f0f5ad54fd [thunk-lowering] Add support for mangling identity thunks.
This is just again using identity thunks to show that the behavior works before
I add in hop to main actor.
2024-10-17 11:17:38 -07:00
Konrad `ktoso` Malawski dea3b59331 Merge pull request #76250 from ktoso/wip-experimental-isolated-deinit 2024-10-03 17:19:10 +09:00
Nate Chandler 091368ba21 [CoroutineAccessors] Added read.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Nate Chandler 98a2e6a7df [CoroutineAccessors] Added modify.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Konrad `ktoso` Malawski 7d1ce789ad Revert "Revert "Isolated synchronous deinit"" 2024-09-17 17:35:38 +09:00
Meghana Gupta 10057523ec Delete lifetime dependence mangling
Mangling this information for future directions like component lifetimes
becomes complex and the current mangling scheme isn't scalable anyway.

Deleting this support for now.
2024-09-05 22:03:58 -07:00
Alejandro Alonso c1dd957c75 Use intptr_t more consistently 2024-09-04 15:13:50 -07:00
Alejandro Alonso 4a7fb6f5fe Some test fixes 2024-09-04 15:13:48 -07:00
Alejandro Alonso f4f60f4344 Remove Value requirement Add GenericTypeParamKind 2024-09-04 15:13:43 -07:00
Alejandro Alonso 7c85261a77 Add runtime support 2024-09-04 15:13:27 -07:00
Alejandro Alonso 75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Alex Hoppen c5aa49ba64 Revert "Isolated synchronous deinit" 2024-09-03 18:11:26 -07:00