Commit Graph

473 Commits

Author SHA1 Message Date
Konrad `ktoso` Malawski
2ec717b115 [Concurrency] TaskExecutor ownership fixes (#74000) 2024-06-14 22:56:33 +09:00
Nate Chandler
b5b637c72e [NFC] SIL: Renamed helper.
removing...To -> removing...From
2024-06-11 16:25:11 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Nate Chandler
b2d7247cdf [SIL] Verify extend_lifetime instruction. 2024-06-05 16:28:28 -07:00
Ellie Shin
6216ec648f Merge pull request #73902 from apple/elsh/pkg-cmo-inline
[SIL][PackageCMO] Allow optimizing [serialized_for_pkg] functions
2024-06-04 11:39:19 -07:00
Michael Gottesman
c7124e431a [sending] Fix recent alloc_stack as indirect result isolation inference to infer disconnected if the alloc stack is used as a sending indirect result.
I also fixed an issue that I found where we were not substituting SILResultInfo
flags which was causing us to drop when substituting sil_sending. I added a
SILVerifier check to make sure that we do not break this again.
2024-06-01 23:25:16 -07:00
Holly Borla
135e3f2ee9 Merge pull request #73889 from hborla/deprecate-anyactor
[Concurrency] Deprecate `AnyActor`.
2024-05-30 09:36:35 -07:00
Holly Borla
c20b0e0956 [Concurrency] Obsolete AnyActor in Swift 6 using a typealias. 2024-05-29 22:59:19 -07:00
Ellie Shin
4ecfc96578 [SIL][PackageCMO] Allow optimizing [serialized_for_pkg] functions during SIL
inlining, generic/closure specialization, and devirtualization optimization passes.

SILFunction::canBeInlinedIntoCaller now exlicitly requires a caller's SerializedKind_t arg.
isAnySerialized() is added as a convenience function that checks if [serialized] or [serialized_for_pkg].

Resolves rdar://128704752
2024-05-27 23:05:56 -07:00
Ellie Shin
5ccc4cd394 SIL function can be serialized with different kinds: [serialized] or
[serialized_for_package] if Package CMO is enabled. The latter kind
allows a function to be serialized even if it contains loadable types,
if Package CMO is enabled. Renamed IsSerialized_t as SerializedKind_t.

The tri-state serialization kind requires validating inlinability
depending on the serialization kinds of callee vs caller; e.g. if the
callee is [serialized_for_package], the caller must be _not_ [serialized].
Renamed `hasValidLinkageForFragileInline` as `canBeInlinedIntoCaller`
that takes in its caller's SerializedKind as an argument. Another argument
`assumeFragileCaller` is also added to ensure that the calle sites of
this function know the caller is serialized unless it's called for SIL
inlining optimization passes.

The [serialized_for_package] attribute is allowed for SIL function, global var,
v-table, and witness-table.

Resolves rdar://128406520
2024-05-23 15:53:02 -07:00
Michael Gottesman
d759ec97ea Merge pull request #73696 from gottesmm/rdar128216574
[sending] Add support for 'sending'
2024-05-18 05:42:41 -04:00
Adrian Prantl
c7644cd06c Merge pull request #73674 from Snowy1803/rdar128091794
[SILVerifier] Disable debug info type assertion for boxes
2024-05-16 16:59:58 -07:00
Michael Gottesman
e3e78ad6bb [sending] Change the internals of sending to be based around 'sending' instead of 'transferring'.
We still only parse transferring... but this sets us up for adding the new
'sending' syntax by first validating that this internal change does not mess up
the current transferring impl since we want both to keep working for now.

rdar://128216574
2024-05-16 12:20:45 -07:00
Ellie Shin
1257db7342 Merge pull request #73566 from apple/elsh/sil-new-attr
[SIL] Add [serialized_for_package] to control package-wide resilience domain in Package-CMO.
2024-05-16 10:17:35 -07:00
Emil Pedersen
f704a0cb09 [SILVerifier] Disable debug info type assertion for boxes
rdar://128091794
2024-05-16 09:58:22 -07:00
Ellie Shin
e632c5ec96 -Add package-cmo check to bypassResilienceInPackage method.
-Fix SILDeclRef getLinkageLimit() for GlobalAccessor to return
Limit::None if bypassResilienceInPackage is enabled.
2024-05-15 16:25:16 -07:00
Ellie Shin
2d81d0f2c7 [SIL] Add a new attribute [serialized_for_package] to support
package-wide resilience domain if Package CMO is enabled.

The purpose of the attribute includes:
- Indicates that certain types such as loadable types are
allowed in serialized functions in resiliently built module
if the optimization is enabled, which are otherwise disallowed.
- Used during SIL deserialization to determine whether such
functions are allowed.
- Used to determine if a callee can be inlined into a caller
that's serialized without package-cmo, e.g. with an explicit
annotation like @inlinable, where the callee was serialized
due to package-cmo.

Resolves rdar://127870822
2024-05-15 12:43:15 -07:00
Michael Gottesman
4412fff99d [region-isolation] Fix verifier check.
After following up with @slavapestov and @xedin, I was right to be suspicious of
my changes here.

Instead of attempting to hard code this, I do the right thing and I map the
relevant type into the function's generic context and then do the check. This
ensures that when isAnyActorType() performs the conformance check,
ModuleDecl::lookupConformance() has a generic signature to work with.
2024-05-13 13:43:51 -07:00
Michael Gottesman
4789cc7e55 Merge pull request #73556 from gottesmm/rdar127295657_127844737
[region-isolation] When inferring isolation for an argument, handle non-self isolated parameters as well as self parameters that are actor isolated.
2024-05-13 11:18:51 -07:00
Emil Pedersen
15cab3a19f Merge pull request #73555 from Snowy1803/complete-getvarinfo
[DebugInfo] Return complete variable info from getVarInfo by default
2024-05-13 10:32:43 -07:00
Michael Gottesman
f51a050af4 [sil] Restrict sil_isolated to only being able to be applied to any actor types.
I also added some docs to SIL.rst about sil_isolated as well.
2024-05-11 17:14:49 -07:00
Michael Gottesman
c1d0c8cd2d [region-isolation] Avoid using the function isolation when determining isolation of a sil_isolated parameter.
It is unnecessary and seems to be slightly out of sync sometimes around
closures.
2024-05-11 16:34:50 -07:00
Emil Pedersen
ac865eb2f9 [SILVerifier] Verify that debug variable types match the SSA type 2024-05-10 16:12:56 -07:00
Ellie Shin
9b28969e2d To support serializing functions containing loadable types in a resiliently built
module when package serialization is enabled, return maximal resilience expansion
in SILFunction::getResilienceExpansion(). This allows aggregate types to be generated
as loadable SIL types which otherwise are address-only in a serialized function.
During type lowering, opaque flag setting is also skipped if package serialization
is enabled.

Resolves rdar://127400743
2024-05-08 05:01:25 -07:00
Erik Eckstein
b636da1716 SILVerifier: be more tolerant if errors were detected in diagnostic passes
SIL cannot be assumed to be 100% valid if errors were detected in diagnostic passes. For example in DefiniteInitialization.

Fixes some false verifier errors in case -sil-verify-all is used.

rdar://127519229
rdar://127518886
2024-05-06 16:06:36 +02:00
Nate Chandler
06921cfe84 [SIL] Hollow out Builtin.copy, deprecate _copy.
The copy operator has been implemented and doesn't use it.  Remove
`Builtin.copy` and `_copy` as much as currently possible.

Source compatibility requires that `_copy` remain in the stdlib.  It is
deprecated here and just uses the copy operator.

Handling old swiftinterfaces requires that `Builtin.copy` be defined.
Redefine it here as a passthrough--SILGen machinery will produce the
necessary copy_addr.

rdar://127502242
2024-05-03 15:56:25 -07:00
Ellie Shin
fbb3382e21 During Package CMO, SIL cloning happens during which
SILOptions::EnableSerializePackage info is lost.

SILVerifier needs this info to determine whether resilience
can be bypassed for decls serialized in a resiliently
built module when Package CMO optimization enabled.

This PR adds SerializePackageEnabled bit to Module format
and uses that in SILVerifier.

Resolves rdar://126157356
2024-04-17 22:37:48 -07:00
Meghana Gupta
0cddd69415 Merge pull request #72780 from meg-gupta/enablesilcombineossa
Enable inject_enum_addr silcombine in ossa
2024-04-03 15:59:22 -07:00
Meghana Gupta
c30eea156f Verify switch_value has int operands only 2024-04-03 10:30:55 -07:00
Kuba (Brecka) Mracek
7553c41705 Merge pull request #72690 from kubamracek/embedded-subclassing-across-modules
[embedded] Relax verifier check on hidden-external functions in embedded mode
2024-04-02 10:47:49 -07:00
Andrew Trick
a1bb9f401a Fix SILVerifier and AddressUtils handling of addr casts.
These core utils did not handle UnconditionalCheckedCastAddrInst or
UncheckedRefCastAddrInst correctly.
2024-04-01 21:46:10 -07:00
Alejandro Alonso
36bf2ae3bf Merge pull request #72592 from Azoy/raw-layout-inst
[IRGen] Add Builtin.addressOfRawLayout
2024-03-29 07:38:37 -07:00
Kuba Mracek
a54dfe8b8e [embedded] Relax verifier check on hidden-external functions in embedded mode 2024-03-28 17:57:54 -07:00
Anton Korobeynikov
d84847ac9d Reland Allow normal function results of @yield_once coroutines (#71645)
* Allow normal function results of @yield_once coroutines

* Address review comments

* Workaround LLVM coroutine codegen problem: it assumes that unwind path never returns.
This is not true to Swift coroutines as unwind path should end with error result.
2024-03-27 13:09:02 -07:00
Alejandro Alonso
f5e10e2c0b Get rid of sil instruction and use a builtin for addressOfRawLayout 2024-03-27 11:36:29 -07:00
Andrew Trick
f809d72507 Merge pull request #72504 from atrick/complete-ossa-flags
Options for complete OSSA lifetimes.
2024-03-22 16:53:42 -07:00
Adrian Prantl
9b0c4104ef Merge pull request #72397 from Snowy1803/verifier-conflicting-debug-value-types
[SILVerifier] Add detection of conflicting debug variables
2024-03-22 11:31:05 -07:00
Andrew Trick
38d9557481 Options for complete OSSA lifetimes.
Adds
-disable-ossa-complete-lifetimes,
-enable-ossa-verify-complete,
-disable-ossa-verify-complete
2024-03-21 16:32:10 -07:00
Emil Pedersen
fed03ccc2b [SILVerifier] Add detection of conflicting debug variables 2024-03-20 15:55:52 -07:00
Ellie Shin
6fc909837f Set EnableSerializePackage to false and update call sites.
Update doc comments.

rdar://124651962
2024-03-15 14:11:36 -07:00
eeckstein
a24539171c Merge pull request #72265 from eeckstein/fix-mandatory-inlining
MandatoryInlining and ConstExpr: look through sendable function conversions
2024-03-13 18:52:43 +01:00
Ellie Shin
56d337d322 Merge pull request #72249 from apple/es/pkg-cmo 2024-03-13 09:26:35 -07:00
Erik Eckstein
3c76464c1c rename withConcurrent -> withSendable
That was missed when "concurrent" was renamed to "sendable"
2024-03-13 09:58:31 +01:00
Ellie Shin
a3250e426d Support Package CMO
* Add a new flag -experimental-package-cmo that requires -experimental-allow-non-resilient-access.
* Support serializing package decls for CMO in package if enabled.
* Only applies to default mode CMO.
* Unlike the existing CMO, package CMO can be built with -enable-library-evolution as package
modules are required to be built together in the same project.
* Create hasPublicOrPackageVisibility to opt in for package decls; needed for CMO, SILVerifier,
and other call sites that verify or determine codegen.

Resolves rdar://121976014
2024-03-12 15:00:24 -07:00
John McCall
0901b2b0b3 Add builtin support for starting a task on a specific executor.
This should be close enough to the creation of this builtin that we don't
need a new feature for it specifically.
2024-03-11 19:44:50 -04:00
Michael Gottesman
622afad384 [transferring] Represent transferring at the SIL level on SILResultInfo rather than a bit on SILFunctionType.
We preserve the current semantics that we have today by requiring that either all SILResultInfo are transferring or none are transferring. This also let me swap to @sil_transferring representation.

I did both of these things to fix SIL issues around transferring.

It also ensures that we now properly emit
2024-03-07 19:44:39 -08:00
John McCall
0a282c044f Unify all of the task-creation builtins coming out of SILGen.
We've been building up this exponential explosion of task-creation
builtins because it's not currently possible to overload builtins.
As long as all of the operands are scalar, though, it's pretty easy
to peephole optional injections in IRGen, which means we can at
least just use a single builtin in SIL and then break it apart in
IRGen to decide which options to set.

I also eliminated the metadata argument, which can easily be recreated
from the substitutions.  I also added proper verification for the builtin,
which required (1) getting `@Sendable` right more consistently and (2)
updating a bunch of tests checking for things that are not actually
valid, like passing a function that returns an Int directly.
2024-03-06 22:21:12 -05:00
Emil Pedersen
35e346fd8d Add support for op_tuple_fragment in SIL DIExpression and SIL SROA
rdar://124034536
2024-03-04 15:46:02 -08:00
Erik Eckstein
4413a169e4 SIL: fix: SILCloner doesn't create SILUndefs correctly and add verification for that
cloned SILUndefs ended up with the wrong parent function
2024-03-01 08:51:35 +01: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