Commit Graph

1696 Commits

Author SHA1 Message Date
Pavel Yaskevich
1e06448da7 [IRGen] Distributed: Remove a requirement that accessible function should be backed by SILFunction
Distributed protocol requirements don't have associated SILFunction,
let's introduce a more flexible way to define it that collects only
the information necessary for the function to become accessible.
2024-03-04 15:59:57 -08:00
Adrian Prantl
23e6e54ca1 Merge pull request #71925 from Snowy1803/recursive-sroa
[DebugInfo] Add debug info support for recursive SIL SROA
2024-02-28 20:05:57 -08:00
Emil Pedersen
0faa055c11 [DebugInfo] Add debug info support for recursive SIL SROA
This removes the restriction that only one fragment is allowed at
the end of a SIL DIExpression.

rdar://100046900
2024-02-28 12:48:17 -08:00
Michael Gottesman
11f0ff6e32 [sil] Ensure that all SILValues have a parent function by making it so that SILUndef is uniqued at the function instead of module level.
For years, optimizer engineers have been hitting a common bug caused by passes
assuming all SILValues have a parent function only to be surprised by SILUndef.
Generally we see SILUndef not that often so we see this come up later in
testing. This patch eliminates that problem by making SILUndef uniqued at the
function level instead of the module level. This ensures that it makes sense for
SILUndef to have a parent function, eliminating this possibility since we can
define an API to get its parent function.

rdar://123484595
2024-02-27 13:14:47 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Akira Hatanaka
b3f302b96b [IRGen] Fix a bug where an argument wasn't annotated with sret (#71459)
Fix a bug in expandExternalSignatureTypes where it wasn't annotating a function call parameter type with sret when the result was being returned indirectly.

The bug was causing calls to ObjC methods that return their results indirectly to crash.

Additionally, fix the return type for C++ constructors computed in expandExternalSignatureTypes. Previously, the return type was always void even on targets that require constructors to return this (e.g., Apple arm64), which was causing C++ constructor thunks to be emitted needlessly.

Resolves rdar://121618707
2024-02-22 14:14:47 -08:00
nate-chandler
4154cdb475 Merge pull request #71799 from nate-chandler/noncopyable-bugs/20240221/2
[IRGen] Outlined value functions that destroy move-only-with-deinit types take and forward those types' metadata.
2024-02-22 06:53:05 -08:00
Konrad `ktoso` Malawski
1d44e2e8e0 [Distributed] Undo new record and mangling scheme for dist.p.witnesses (#71801) 2024-02-22 23:02:29 +09:00
Nate Chandler
f0f9351421 [NFC] IRGen: Extracted callOutlinedRelease.
In preparation to sometimes use a metadata collector.
2024-02-21 17:53:34 -08:00
nate-chandler
94b06b4111 Merge pull request #71787 from nate-chandler/noncopyable-bugs/20240221/1
[IRGen] Lower release_value_addr of noncopyable to deinit call.
2024-02-21 17:52:34 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Nate Chandler
274e7c90fe [IRGen] Lower RVA(mo) to direct deinit call.
When lowering a release_value_addr instruction whose operand is a
value type with a deinit, directly emit a call to the deinit.
2024-02-21 10:56:56 -08:00
Konrad `ktoso` Malawski
e9c7f3c382 [Distributed] Target identifiers for protocol calls (#70928) 2024-02-16 07:19:20 -08:00
John McCall
d5142668f4 SIL and IRGen support for @isolated(any). SILGen to come. 2024-02-13 03:04:13 -05:00
Nate Cook
e317febc9d Revert "Allow normal function results of @yield_once coroutines (#69843)"
This reverts commit aa5b505014.
2024-02-07 14:57:31 -06:00
Anton Korobeynikov
aa5b505014 Allow normal function results of @yield_once coroutines (#69843)
This adds SIL-level support and LLVM codegen for normal results of a coroutine.

The main user of this will be autodiff as VJP of a coroutine must be a coroutine itself (in order to produce the yielded result) and return a pullback closure as a normal result.

For now only direct results are supported, but this seems to be enough for autodiff purposes.
2024-02-06 22:13:15 -08:00
nate-chandler
01bce39100 Merge pull request #71418 from nate-chandler/nfc/20240206/1/rename-inst-class
[NFC] SIL: Renamed SpecifyTestInst.
2024-02-06 22:02:05 -08:00
Nate Chandler
b535725647 [NFC] SIL: Renamed SpecifyTestInst.
The instruction's spelling was changed to `specify_test` but the class
name wasn't updated from `TestSpecificationInst`.  Update it here.
2024-02-06 16:29:09 -08:00
Ellie Shin
72a7760027 Support package SIL linkage.
Decls with a package access level are currently set to public SIL
linkages. This limits the ability to have more fine-grained control
and optimize around resilience and serialization.
This PR introduces a separate SIL linkage and FormalLinkage for
package decls, pipes them down to IRGen, and updates linkage checks
at call sites to include package linkage.

Resolves rdar://121409846
2024-02-06 01:23:14 -08:00
Erik Eckstein
4c3722352e IRGen: don't use value witness functions in outlined value operations for functions with performance constraints 2024-02-05 12:37:08 +01:00
Arnold Schwaighofer
49e8ffb735 IRGen: Outline by-address SIL enum instructions
Use a heuristic to decide when to outline indirect enum operations.
2024-01-23 15:01:24 -08:00
Erik Eckstein
eaabcfd933 IRGen: restrict generation of read-only static objects to Array buffers
Currently only arrays can be put into a read-only data section.
"Regular" classes have dynamically initialized metadata, which needs to be stored into the isa field at runtime.
2024-01-10 09:33:17 +01:00
Slava Pestov
9e2123bb2a IRGen: Fix some formatting in an assertion regarding on-stack pack cleanups 2024-01-02 15:41:13 -05:00
Kuba (Brecka) Mracek
ec87fbcaca Merge pull request #70344 from kubamracek/embedded-nounwind
[embedded] Mark all functions as 'nounwind' in embedded Swift, add dependency tests
2023-12-12 10:37:54 -08:00
Kuba Mracek
fdc69fb6a1 [embedded] Actually, use 'nounwind' even with C++ interop on, add comment 2023-12-11 13:37:41 -08:00
Kuba Mracek
9e8db64f45 [embedded] Don't apply 'nounwind' if C++ interop is enabled 2023-12-11 09:08:06 -08:00
Erik Eckstein
e652f2c92e SIL: add the alloc_vector and vector instructions
* `alloc_vector`: allocates an uninitialized vector of elements on the stack or in a statically initialized global
* `vector`: creates an initialized vector in a statically initialized global
2023-12-09 18:49:55 +01:00
Kuba Mracek
4e56d810fa [embedded] Mark all functions as 'nounwind' in embedded Swift, add dependency tests 2023-12-09 08:46:00 -08:00
Pavel Yaskevich
229e580174 [SIL] Add a way to retrieve key path type from KeyPathInst
Since the type of the instruction could be existential it's
better to keep retrival logic in one place.
2023-11-28 13:02:17 -08:00
nate-chandler
b944ab877a Merge pull request #69857 from nate-chandler/nfc/20231114/1/delete-dead-lowered-value-kind
[IRGen] NFC: Deleted dead LoweredValue kind.
2023-11-15 07:38:26 -08:00
Nate Chandler
e673344060 [IRGen] NFC: Deleted dead LoweredValue kind.
Follow-up to https://github.com/apple/swift/pull/10077 .
2023-11-14 10:49:02 -08:00
Doug Gregor
d2e0582a92 Move workaround for swifterror miscompile earlier
Thank you, Arnold for noting this miscompile on x86!
2023-11-13 11:44:25 -08:00
Michael Gottesman
6a65c7829e [sil] Add tuple_addr_constructor an instruction that can be used to initial a tuple in memory from individual address and object components.
This commit just introduces the instruction. In a subsequent commit, I am going
to add support to SILGen to emit this. This ensures that when we assign into a
tuple var we initialize it with one instruction instead of doing it in pieces.
The problem with doing it in pieces is that when one is emitting diagnostics it
looks semantically like SILGen actually is emitting code for initializing in
pieces which could be an error.
2023-11-06 15:32:05 -08:00
Slava Pestov
05ccd9734c SIL: Introduce ThrowAddrInst 2023-10-31 16:58:54 -04:00
Mishal Shah
3594f8ecaf Merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
	test/IRGen/opaque-pointer-llvm.swift
2023-10-15 23:49:40 -07:00
Arnold Schwaighofer
9482b0c86b Preliminary SIL and IRGen support for error_indirect
IRGen lowering of non-fixed-sized typed errors and the SIL support necessary to
spell out IRGen test cases.
2023-10-12 18:09:52 -07:00
swift-ci
6e01afa811 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-08 12:54:13 -07:00
Kuba Mracek
b254a2a2c0 [Typed throws] Workaround for LLVM miscompile of unused swifterror, add executable test 2023-10-07 22:03:32 -07:00
swift-ci
00db9cadd6 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-02 08:55:02 -07:00
Arnold Schwaighofer
6b74f511d0 Preliminary IRGen support for typed throws
Typed errors are returned indirectly in this version.
No support for non-loadable typed errors
2023-09-29 08:54:49 -07:00
swift-ci
1b6470ca9c Merge remote-tracking branch 'origin/main' into rebranch 2023-09-20 15:07:15 -07:00
Yuta Saito
c5314bd3af Centralize KeyPath accessor calling convention logic to IRGen
KeyPath's getter/setter/hash/equals functions have their own calling
convention, which receives generic arguments and embedded indices from a
given KeyPath argument buffer.
The convention was previously implemented by:
1. Accepting an argument buffer as an UnsafeRawPointer and casting it to
   indices tuple pointer in SIL.
2. Bind generic arguments info from the given argument buffer while emitting
   prologue in IRGen by creating a new forwarding thunk.

This 2-phase lowering approach was not ideal, as it blocked KeyPath
projection optimization [^1], and also required having a target arch
specific signature lowering logic in SIL-level [^2].

This patch centralizes the KeyPath accessor calling convention logic to
IRGen, by introducing `@convention(keypath_accessor_XXX)` convention in
SIL and lowering it in IRGen. This change unblocks the KeyPath projection
optimization while capturing subscript indices, and also makes it easier
to support WebAssembly target.

[^1]: https://github.com/apple/swift/pull/28799
[^2]: https://forums.swift.org/t/wasm-support/16087/21
2023-09-20 11:25:39 -07:00
swift-ci
c2d0ed607a Merge remote-tracking branch 'origin/main' into rebranch 2023-09-19 11:33:34 -07:00
Erik Eckstein
f0b811c45f SIL: add the end_init_let_ref instruction
This instructions marks the point where all let-fields of a class are initialized.
This is important to ensure the correctness of ``ref_element_addr [immutable]`` for let-fields,
because in the initializer of a class, its let-fields are not immutable, yet.
2023-09-19 15:10:30 +02:00
Erik Eckstein
e5eb15dcbe Swift SIL: replace the set_deallocating instruction with begin_dealloc_ref
Codegen is the same, but `begin_dealloc_ref` consumes the operand and produces a new SSA value.
This cleanly splits the liferange to the region before and within the destructor of a class.
2023-09-19 15:10:30 +02:00
swift-ci
ae30cba296 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-13 10:20:48 -07:00
Kuba Mracek
d0c2a4ccf8 [embedded] Initial support for generic classes in embedded Swift
- VTableSpecializer, a new pass that synthesizes a new vtable per each observed concrete type used
- Don't use full type metadata refs in embedded Swift
- Lazily emit specialized class metadata (LazySpecializedClassMetadata) in IRGen
- Don't emit regular class metadata for a class decl if it's generic (only emit the specialized metadata)
2023-09-12 09:44:54 -07:00
Sophia Poirier
86d368f364 Merge remote-tracking branch 'upstream/main' into fix-rebranch-automerger 2023-08-31 14:10:52 -07:00
Michael Gottesman
37d60a08bb [move-only] Rename mark_must_check -> mark_unresolved_non_copyable_value.
I was originally hoping to reuse mark_must_check for multiple types of checkers.
In practice, this is not what happened... so giving it a name specifically to do
with non copyable types makes more sense and makes the code clearer.

Just a pure rename.
2023-08-30 22:29:30 -07:00
swift-ci
6cd0624165 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-18 07:14:28 -07:00