Commit Graph

1696 Commits

Author SHA1 Message Date
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
Nate Chandler
dd8cbe3e0a [CoroutineAccessors] Use retcon.once variant.
Allocate a coroutine frame in the caller based on the size in the
corresponding "function pointer" and pass it along with an allocator to
the callee.
2025-02-27 07:53:58 -08:00
Nate Chandler
9e6089459a [NFC] IRGen: Deduplicated function implementation.
The same explosion is used for every object regardless of whether the
call is sync or async.
2025-02-27 07:53:12 -08:00
Usama Hameed
500187cf1e Add support for serializing debug_value instructions (#78056)
This patch adds support for serialization of debug value instructions. Enablement is currently gated behind the -experimental-serialize-debug-info flag.

Previously, debug_value instructions were lost during serialization. This made it harder to debug cross module inlined functions.
2025-02-24 20:21:15 -08:00
Konrad `ktoso` Malawski
09003d6f11 Revert "Merge pull request #77609 from ktoso/wip-task-names" (#79562)
This reverts commit 4ab5d2604f.
2025-02-23 22:59:21 -08:00
Konrad `ktoso` Malawski
4ab5d2604f Merge pull request #77609 from ktoso/wip-task-names
[Concurrency] Task names
2025-02-21 22:28:33 +09:00
Erik Eckstein
e0b4f71af6 SIL: remove the alloc_vector instruction
It's not needed anymore, because the "FixedArray" experimental feature is replaced by inline-arrays.
2025-02-12 10:51:14 +01:00
Arnold Schwaighofer
9e218fc465 Merge pull request #79201 from aschwaighofer/pr143456806
IRGen: Replace retail_value_addr implementation by destroy_addr's
2025-02-10 16:56:42 -08:00
Arnold Schwaighofer
79784a8f81 IRGen: Replace retail_value_addr implementation by destroy_addr's
We can't always use an outlined function, destroy_addr's implementation
already handles cases where this is true (such as opened archetypes).

rdar://143456806
2025-02-06 14:11:36 -08:00
Joe Groff
3d779cd789 IRGen: Fix DenseMap interior pointer invalidation bug in IRGenSILFunction::visitEndApply.
Fixes rdar://144216380.
2025-02-05 15:50:09 -08:00
Anthony Latsis
a84dfc8387 [Gardening] Fix some set but not used variables 2025-01-30 21:34:38 +00:00
Erik Eckstein
3ec5d7de24 SIL: replace the is_escaping_closure instruction with destroy_not_escaped_closure
The problem with `is_escaping_closure` was that it didn't consume its operand and therefore reference count checks were unreliable.
For example, copy-propagation could break it.
As this instruction was always used together with an immediately following `destroy_value` of the closure, it makes sense to combine both into a `destroy_not_escaped_closure`.
It
1. checks the reference count and returns true if it is 1
2. consumes and destroys the operand
2025-01-24 19:23:27 +01:00
Michael Gottesman
d060f01527 Merge pull request #78837 from gottesmm/rdar-142661388
[rbi] Change Region Based Isolation for closures to not use the AST and instead just use SIL.
2025-01-23 15:48:34 -08:00
Augusto Noronha
683c02cf9d Merge pull request #78728 from augusto2112/fix-resilience-lldb
Fix miscompilations for debugger because of resilience
2025-01-22 22:27:17 -08:00
Michael Gottesman
7ae56aab2e [sil] Add a new instruction ignored_use.
This is used for synthetic uses like _ = x that do not act as a true use but
instead only suppress unused variable warnings. This patch just adds the
instruction.

Eventually, we can use it to move the unused variable warning from Sema to SIL
slimmming the type checker down a little bit... but for now I am using it so
that other diagnostic passes can have a SIL instruction (with SIL location) so
that we can emit diagnostics on code like _ = x. Today we just do not emit
anything at all for that case so a diagnostic SIL pass would not see any
instruction that it could emit a diagnostic upon. In the next patch of this
series, I am going to add SILGen support to do that.
2025-01-22 21:12:36 -08:00
Becca Royal-Gordon
0ce403d680 [NFC] Add some pretty stack traces
These would have helped us to debug rdar://142693093 more quickly.
2025-01-21 17:33:09 -08:00
Augusto Noronha
bceb8176dd Fix miscompilations for debugger because of resilience
This patch fixes two instances of the compiler embedded in LLDB
miscompiling code for expression evaluation, because of a combination of
the debugger's access to private types and resilience, which would cause
the generated code to access fields indirectly through resilience functions
that were never emitted.

rdar://137876089
2025-01-17 15:50:09 -08:00
Saleem Abdulrasool
e37ffad1a6 IRGen: adjust code for MSVC warning C4468 (NFCI)
```
The [[fallthrough]] attribute must be followed by a `case` label or a
`default` label.
```

Restructure the code so that the `[[fallthrough]]` attribute is followed
by the subsequent `case` label for the `switch` statement.
2025-01-11 10:55:21 -08:00
Kuba Mracek
af6b24b542 [embedded] Don't emit metadata references from C++ interop 2024-12-10 15:56:37 -08:00
Arnold Schwaighofer
08b3c95883 Merge pull request #77452 from aschwaighofer/enable_async_metadata
IRGen: Enable EmitAsyncFramePushPopMetadata per default
2024-11-08 15:21:58 -08:00
Arnold Schwaighofer
1c1d95a814 EmitAsyncFramePushPopMetadata is currently only supported on MachO
The LLVM pass that emits the sections is hard code for MachOS sections
2024-11-08 09:21:56 -08:00
Dario Rexin
f6e7c16a8a [IRGen] Map types into context in typed throws code gen
Some types that should have been were not mapped into context.
2024-11-07 11:51:58 -08:00
Dario Rexin
ffd9f205b3 [IRGen] Re-introduce typed throws ABI
rdar://135954459
2024-11-07 10:22:49 -08:00
Slava Pestov
3efa770c86 Merge pull request #77371 from slavapestov/fix-issue-77297
IRGen: Make sure loadable error types are mapped into the generic environment too
2024-11-05 03:31:45 -05:00
Slava Pestov
505c950db8 IRGen: Make sure loadable error types are mapped into the generic environment too
Fixes https://github.com/swiftlang/swift/issues/77297
Fixes rdar://problem/139000360
2024-11-04 14:26:45 -05:00
Kavon Farvardin
86601fcbbf Merge pull request #76532 from kavon/samplepgo
Add support for SamplePGO
2024-11-01 17:52:52 -07:00
Kavon Farvardin
2b01714fba PGO: new -profile-sample-use= frontend flag
This is meant to match clang's `-fprofile-sample-use=` and accepts a
file with the same format.

rdar://135443278
2024-11-01 11:59:54 -07:00
Michael Gottesman
3c38c79f7a [region-isolation] Implement MergeIsolationRegionInst.
I am adding this instruction to express artificially that two non-Sendable
values should be part of the same region. It is meant to be used in cases where
due to unsafe code using Sendable, we stop propagating a non-Sendable dependency
that needs to be made in the same region of a use of said Sendable value. I
included an example in ./docs/SIL.rst of where this comes up with @out results
of continuations.
2024-11-01 11:25:53 -07:00
Arnold Schwaighofer
5f396cd13c IRGen: Add indirect peepholes for arguments and return value coercion
Large tuples of values (e.g char[32]) can be passed directly at the abi
boundry but expand to a big explosion of values.

Peephole this explosion at argument passing and return value passing
points to avoid code size growth associated with the explosion.
2024-10-31 13:02:07 -07:00
swift-ci
9dcd39a254 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-22 00:42:50 -07:00