Commit Graph

1725 Commits

Author SHA1 Message Date
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
ec81d7fb04 Move the responsibility for adding the special direct continuation
arguments to the CallEmission.
2025-11-03 13:45:19 -08:00
John McCall
3cfda35b7c Remove the unused swift_asyncLet_{start,end,wait,wait_throwing} runtime
functions.

These were introduced in an early draft implementation of async let, but
never used by a released compiler. They are not used as symbols by any
app binaries. There's no reason to keep carrying them.

While I'm at it, dramatically improve the documentation of the remaining
async let API functions.
2025-11-03 13:45:18 -08:00
Doug Gregor
5d576470fd [IRGen] Detect duplicate definitions at the IR level 2025-10-31 10:32:54 -07:00
Nate Chandler
e0ead75622 [CoroutineAccessors] Use typed-malloc. 2025-10-30 03:59:18 -07:00
nate-chandler
9069d32078 Merge pull request #85055 from nate-chandler/general-coro/20251016/1
[CoroutineAccessors] Provide frame to de/allocation functions.
2025-10-23 20:17:52 -07:00
Meghana Gupta
1dc5c9611c Intoduce unchecked_ownership instruction in raw SIL
This instruction can be used to disable ownership verification on it's result and
will be allowed only in raw SIL.

Sometimes SILGen can produce invalid ownership SSA, that cannot be resolved until
mandatory passes run. We have a few ways to piecewise disable verification.
With unchecked_ownership instruction we can provide a uniform way to disable ownership
verification for a value.
2025-10-23 05:19:08 -07:00
Meghana Gupta
e116df3628 Introduce return_borrow instruction 2025-10-23 05:18:59 -07:00
Nate Chandler
76881b1d52 [CoroutineAccessors] Add frame de/alloc functions.
To enable ABIs which store extra info in the frame, add two new slots to
the coroutine allocator function table.  For example, a frame could have
a header containing a context pointer at a negative offset from the
address returned from `swift_coro_alloc_frame`.  The frame deallocation
function would then know to deallocate more space correspondingly.
2025-10-22 21:00:17 -07:00
Nate Chandler
a2a4d22042 [NFC] IRGen: Typed this flag. 2025-10-22 13:00:38 -07:00
Meghana Gupta
a0c939bd3b Use @inout result convention for mutate accessors 2025-10-20 09:05:32 -07:00
Michael Gottesman
390afe3e7d [concurrency] Implement bit masking for TBI when available or in tagged pointer bits otherwise.
Specifically, when TBI is available we use the bottom two bits of the top nibble
(bits 60,61). On platforms without TBI, we use the bottom two tagged pointer
bits (bits 0, 1).

rdar://156525771
2025-10-16 10:52:05 -07:00
Michael Gottesman
fe9c21fd87 [sil] Add a new instruction cast_implicit_actor_to_optional_actor.
This instruction converts Builtin.ImplicitActor to Optional<any Actor>. In the
process of doing so, it masks out the bits we may have stolen from the witness
table pointer of Builtin.ImplicitActor. The bits that we mask out are the bottom
two bits of the top nibble of the TBI space on platforms that support TBI (that
is bit 60,61 on arm64). On platforms that do not support TBI, we just use the
bottom two tagged pointer bits (0,1).

By using an instruction, we avoid having to represent the bitmasking that we are
performing at the SIL level and can instead just make the emission of the
bitmasking an IRGen detail. It also allows us to move detection if we are
compiling for AArch64 to be an IRGen flag instead of a LangOpts flag.

The instruction is a guaranteed forwarding instruction since we want to treat
its result as a borrowed projection from the Builtin.ImplicitActor.
2025-10-16 10:52:04 -07:00
Michael Gottesman
2fa3908e94 [concurrency] Add a new type Builtin.ImplicitActor.
This is currently not wired up to anything. I am going to wire it up in
subsequent commits.

The reason why we are introducing this new Builtin type is to represent that we
are going to start stealing bits from the protocol witness table pointer of the
Optional<any Actor> that this type is bitwise compatible with. The type will
ensure that this value is only used in places where we know that it will be
properly masked out giving us certainty that this value will not be used in any
manner without it first being bit cleared and transformed back to Optional<any
Actor>.
2025-10-16 10:51:13 -07:00
Meghana Gupta
ea0e0173b4 Merge pull request #84595 from meg-gupta/moreborrowaccessors
Extend borrow accessor support
2025-10-03 11:14:49 -07:00
Meghana Gupta
36f2955d39 IRGen support for GuaranteedAddress result convention 2025-10-02 07:18:27 -07:00
swift-ci
7f8473a16c Merge remote-tracking branch 'origin/main' into rebranch 2025-09-10 02:51:07 -07:00
Anton Korobeynikov
7668666ad2 Support differentiation of wrapped value modify accessors (#78794)
Some fixes for coroutines with normal results and `partial_apply` of coroutines were required.

Fixes #55084
2025-09-10 02:30:26 -07:00
swift-ci
255ee32c29 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-03 13:48:19 -07:00
Janat Baig
798c0f51a4 Merge branch 'main' into temp-branch 2025-08-23 11:11:04 -04:00
JanBaig
52895fefc3 [SIL] Remove AssignByWrapper references from SIL passes 2025-08-22 23:20:53 -04:00
swift-ci
367f0082fc Merge remote-tracking branch 'origin/main' into rebranch 2025-07-22 22:17:45 -07:00
Anthony Latsis
b04d6085f3 IRGen: Address llvm::InsertPosition ctor deprecation
See https://github.com/llvm/llvm-project/pull/102608.
2025-07-21 12:50:39 +01:00
Anthony Latsis
3ba8ab4094 IRGen: Address llvm::Instruction::{move,insert}Before deprecations
See 79499f010d.
2025-07-21 12:41:18 +01:00
Anthony Latsis
f8577a2731 IRGen: Address llvm::Type::getPointerTo deprecation
See https://github.com/llvm/llvm-project/pull/113331.
2025-07-21 12:37:15 +01:00
Augusto Noronha
0c20222aea Merge pull request #81700 from augusto2112/revert-debug-info-witness-table
Revert "Merge pull request #79171 from augusto2112/debug-info-witness…
2025-06-30 15:28:15 -07:00
Doug Gregor
bc4cf1236b [SIL] Generalize CastingIsolatedConformances to CheckedCastInstOptions
We are going to need to add more flags to the various checked cast
instructions. Generalize the CastingIsolatedConformances bit in all of
these SIL instructions to an "options" struct that's easier to extend.

Precursor to rdar://152335805.
2025-06-04 17:12:28 -07:00
Augusto Noronha
680fbc566f Revert "Merge pull request #79171 from augusto2112/debug-info-witness-table"
This reverts commit c8eba86c3e, reversing
changes made to 98c3993503.
2025-05-22 11:45:37 +09:00
Augusto Noronha
c8eba86c3e Merge pull request #79171 from augusto2112/debug-info-witness-table
[DebugInfo] Emit debug info for witness tables
2025-05-21 09:23:04 +09:00
Erik Eckstein
371e4ebd88 IRGen: extract generating a cond_fail into a utility function emitConditionalTrap
NFC
2025-05-19 16:56:47 +02:00
Erik Eckstein
078e479231 IRGen: move FailBBs from IRGenSILFunction to its base class IRGenFunction
NFC
2025-05-19 16:56:46 +02:00
Slava Pestov
b2e2b02a71 IRGen: Fix out-of-order task_dealloc with parameter pack metadata
We deallocate an instruction's packs at points where no further
control flow path uses the value. In the case of an alloc_stack,
this will be right after the dealloc_stack. Thus, if alloc_stack
allocates some packs to build type metadata for a tuple type
that contains a pack, and then proceeds to allocate a value
large enough to hold the tuple, we will free the second allocation
first, before we free the pack, as expected.

However, after stack allocating the value, alloc_stack does
some further work to emit debug info. This could result in
emission of additional metadata packs.

Split up the debug info emission into two parts; the first we do
before we perform the stack allocation, the rest we do after.

- Fixes https://github.com/swiftlang/swift/issues/67702.
- Fixes rdar://problem/141363236.
2025-05-15 12:22:21 -04:00
Erik Eckstein
a38db6439a SIL: add the vector_base_addr instruction
It derives the address of the first element of a vector, i.e. a `Builtin.FixedArray`, from the address of the vector itself.
Addresses of other vector elements can then be derived with `index_addr`.
2025-05-12 19:24:31 +02:00
Meghana Gupta
35d62a4a36 Introduce end_cow_mutation_addr instruction 2025-04-30 13:39:45 -07:00
Augusto Noronha
66748f71eb [DebugInfo] Emit debug info for witness tables
This change emits debug info for witness tables passed into generic
functions when a generic type is constrained to a protocol. This
information is required for LLDB's generic expression evaluator
to work in such functions.

rdar://104446865
2025-04-30 11:18:19 -07:00
Dario Rexin
e9062b257f [IRGen] Set generic context before getting call emission in visitFullApplySite
rdar://149007227

Without the generic context, the result type can't be mapped into the current context, causing the compiler to crash.
2025-04-10 15:13:00 -07:00
Adrian Prantl
c4f073d39a [IRGenSIL] Factor out shouldUseDispatchThunk() (NFC) 2025-04-09 12:32:15 -07:00
Adrian Prantl
5a36f3baac [IRGen] Improve legibility of conditional (NFC) 2025-04-09 12:32:06 -07:00
Adrian Prantl
f4a0f4b339 [LLDB] Fix conditional to also support AccessLevel::Open
This fixes crashes in LLDB expression evaluation when calling virtual
Open functions.

rdar://147797657
2025-04-09 11:28:56 -07:00
Doug Gregor
43df05a89c [SE-0470] Prohibit isolated conformances in dynamic casts marked as such
Certain dynamic casts cannot work safely with isolated conformances,
regardless of what executor the code runs on. For such cases, reject
all attempts to conform to the type.
2025-03-26 22:31:52 -07:00
Andrew Trick
e7000e4668 SIL: Add mark_dependence_addr 2025-03-25 23:02:42 -07:00
Slava Pestov
ad181b9eb1 IRGen: Fix assertion failure with typed throws
The mapTypeIntoContext() call in visitFullApplySite() was not
necessary.

The type in question is already fully substituted and should
no longer contain type parameters.

However, it can contain archetypes, which is what caused
mapTypeIntoContext() to assert.

Indeed, this case where the return type is generic but still
loadable wasn't covered by our test suite.

- Fixes https://github.com/swiftlang/swift/issues/80020.
- Fixes rdar://147051717.
2025-03-25 12:34:24 -04:00
Doug Gregor
731f58443c Address review feedback on AbstractConformance in ProtocolConformanceRef 2025-03-23 20:54:39 -07:00
Arnold Schwaighofer
ee57eed78d IRGen: Annotate LLVM IR of condfail with the condfail's message
`-Xfrontend -enable-cond-fail-message-annotation`
LLVM IR produced by the Swift compiler will add the `annotation`
metadata attribute to the branch instruction generated for cond_fail
builtins.
2025-03-20 08:17:18 -07:00
nate-chandler
c0ba520fac Merge pull request #79781 from nate-chandler/general-coro/20250227/1
[CoroutineAccessors] Dispatch and PtrAuth.
2025-03-07 20:08:42 -08:00
Konrad `ktoso` Malawski
fda7f539fb Reapply "Task names" (#79562) (#79600) 2025-03-08 10:58:49 +09:00
Nate Chandler
6581fec9e1 [CoroutineAccessors] PtrAuth. 2025-03-07 11:46:51 -08:00
Nate Chandler
35d06c325d [CoroutineAccessors] Witness and vtable dispatch.
And thunking.
2025-03-07 11:46:50 -08:00
Nate Chandler
f5d03a6d11 [CoroutineAccessor] Remove old ABI support.
This was useful during bringup.  Now that retcon.once.dynamic coroutine
splitting is available, it's no longer needed.
2025-03-07 11:40:38 -08:00