Commit Graph

2441 Commits

Author SHA1 Message Date
Michael Gottesman
e156289cea Merge pull request #72126 from gottesmm/async-let-fixes
[region-isolation] Make async let closures non-Sendable and require actor isolation crossing function into an async let use a transferring result.
2024-03-13 21:54:04 -07:00
Doug Gregor
685b493ac3 Merge pull request #72305 from DougGregor/silgen-thrown-error-closures
[SILGen] Correctly determine the thrown error type for closures
2024-03-13 18:28:29 -07:00
Rintaro Ishizaki
2abddcb260 [SourceKit] Use recored #if regions in "active regions" request
* Record each IfConfig clause location info in SourceFile
* Update SILProfiler to handle them
* Update SwiftLangSupport::findActiveRegionsInFile() to use the recorded
  regions instead of walking into AST to find #if regions

rdar://118082146
2024-03-14 08:52:57 +09:00
Meghana Gupta
a15d5fea09 Fix ownership of move-only structs in SIL
Not doing this for enums yet because it is tripping the ownership verifier

We dont have move-only tuples yet.
2024-03-13 16:24:57 -07:00
Nate Chandler
f43d4f0158 [NFC] Note how to disable validation. 2024-03-13 15:50:31 -07:00
Nate Chandler
ee1bc88481 [BitwiseCopyable] Loosen validation assertion.
Now that it's possible to be `BitwiseCopyable` and `~Escapable`, because
the latter implies non-trivial, verification must permit a type to be
non-trivial but conform to `BitwiseCopyable` when it contains a
`~Escapable` field.

rdar://124552608
2024-03-13 15:50:21 -07:00
Michael Gottesman
acca7353db [transferring] Make async let take a transferring result if its result is non-Sendable.
Some notes:

1. If the result is non-Sendable and we didn't infer something that is
transferring, we still emit the current sema error that says that one cannot
assign a non-Sendable value to an async let.

2. When region isolation is enabled, but transferring args and results are
disabled, we leave the async let semantics alone. This means that the async let
closure is still @Sendable and one cannot pass in non-Sendable values to it.
2024-03-13 15:30:54 -07:00
Doug Gregor
f54782eab5 [SILGen] Correctly determine the thrown error type for closures
When a closure throws a generic error type, we were retrieving the
substituted error type (involving archetypes) when we needed to be
working with the interface type.

Fixes rdar://124484012.
2024-03-13 12:51:48 -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
Arnold Schwaighofer
315a763c28 Merge pull request #72218 from aschwaighofer/fragile_resilient_protocols
IRGen: Add code to support building fragile resilient protocol witnesses
2024-03-13 08:40:44 -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
Erik Eckstein
4e61c5620c MandatoryInlining: look through sendable function conversions
Allows inlining of sendable transparent functions

rdar://124401627
2024-03-13 09:58:30 +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
Arnold Schwaighofer
9639e007d8 Teach TBD that in fragile resilient protocol mode the protocol table is visible 2024-03-11 09:49:38 -07:00
Erik Eckstein
4017501a4c re-instate: embedded: allow dead function elimination for de-serialized functions
This re-instates commit cc9e53bb08 with a fix for LLDB (rdar://124228107)

rdar://123772098
2024-03-11 15:38:00 +01:00
Nate Chandler
3dbeebaa9b [SIL] Add var_decl flag to alloc_stack. 2024-03-08 22:28:22 -08:00
Nate Chandler
401440748f [NFC] SIL: Typed alloc_box's hasPointerEscape. 2024-03-08 22:27:52 -08:00
Nate Chandler
c6eb3112b5 [NFC] SIL: Typed alloc_stack's isLexical. 2024-03-08 21:24:39 -08:00
Nate Chandler
ec6b447b68 [NFC] SIL: Typed alloc_box's hasDynamicLifetime. 2024-03-08 21:24:39 -08:00
Nate Chandler
dfa5c9814b [NFC] SIL: Typed alloc_stack's hasDynamicLifetime. 2024-03-08 21:24:39 -08:00
Nate Chandler
11dd0e4aa6 [NFC] SIL: Typed debug_value's wasMoved.
Help avoid errors with boolean flags by using the new
UsesMoveableValueDebugInfo_t.
2024-03-08 21:24:39 -08:00
Nate Chandler
e10d595328 [NFC] SIL: Typed alloc_box's wasMoved.
Help avoid errors with boolean flags by using the new
UsesMoveableValueDebugInfo_t.
2024-03-08 21:24:39 -08:00
Nate Chandler
611511a71f [NFC] SIL: Typed alloc_stack's wasMoved.
Help avoid errors with boolean flags by introducing
UsesMoveableValueDebugInfo_t.
2024-03-08 21:24:39 -08:00
Nate Chandler
5ccec0e31c [NFC] SIL: Shortened member name.
Renamed "getUsesMoveableValueDebugInfo" to "usesMoveableValueDebugInfo".
Clarifies the predicate from "does the receiver have the
usesMoveableValueDebugInfo field set?" to "does the receiver use moveable
value debug info?".
2024-03-08 21:24:38 -08:00
Michael Gottesman
76e71e788d Merge pull request #72196 from gottesmm/rest-of-rdar123488540
[region-isolation] Make fields of global actor guarded types that are non-Sendable be considered as actor isolated.
2024-03-08 17:01:39 -08:00
Meghana Gupta
73c424ea08 Merge pull request #72160 from meg-gupta/motest
Add test to show ~Copyable struct has OwnershipKind::None in SIL
2024-03-08 12:58:54 -08: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
8499640224 Merge pull request #72143 from rjmccall/builtin-create-task
Unify and simplify the task-creation builtins
2024-03-07 21:45:06 -05:00
Meghana Gupta
ab3265ddeb Add test utilities to print ownership and sil-triviality 2024-03-07 14:08:35 -08:00
Andrew Trick
df7326d790 Fix SILType::isEscapable for box types.
SILBoxTypes have their own generic signature and substitution
map. This means that every time we query isEscapable or mayEscape, we
need to extract the type of the box's field and perform type
substitution so that the AST query only sees types from the function's
generic environment.

Fixes rdar://124179106 (Assertion failed in SIL:
(!type->hasTypeParameter() && "caller forgot to mapTypeIntoContext!"))
2024-03-07 13:34:46 -08:00
Michael Buch
8957f8186a Revert "embedded: allow dead function elimination for de-serialized functions" 2024-03-07 16:48:04 +00:00
eeckstein
d70ce6bb34 Merge pull request #72124 from eeckstein/fix-embedded-dead-code-elim
embedded: allow dead function elimination for de-serialized functions
2024-03-07 07:39:17 +01:00
Michael Gottesman
77e30d2242 Merge pull request #72132 from gottesmm/pr-1d086e18712f1d43d68363cb6ccc1856d0c76528
[transferring] When transforming an AST function type into its lowered form, make sure transferring result is propagated.
2024-03-06 20:43:47 -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
Michael Gottesman
61422edf55 [transferring] When transforming an AST function type into its lowered form, make sure transferring result is propagated.
rdar://123488540
2024-03-06 16:52:07 -08:00
Emil Pedersen
7c9a8769a1 Merge pull request #72072 from Snowy1803/tuple-fragments
Add support for op_tuple_fragment in SIL DIExpression and SIL SROA
2024-03-06 15:20:08 -08:00
Erik Eckstein
cc9e53bb08 embedded: allow dead function elimination for de-serialized functions
In embedded swift all de-serialized get public linkage because all the code is generated in the top-level module.
This change moves the point where we make de-serialized functions public to the end of the pipeline.
This allows dead function elimination to remove unused de-serialized functions.
For some stdlib functions (actually one: the Double initializer for a builtin integer) is essential, because codegen for embedded produces an unresolved symbol.

rdar://123772098
2024-03-06 20:51:09 +01: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
Michael Gottesman
c24889ce81 Merge pull request #72004 from gottesmm/main-rdar123881277
[region-isolation] Only make partial_apply actor derived if we capture an isolated parameter... not just any actor.
2024-03-02 18:24:42 -08:00
Michael Gottesman
a86d3387f0 [ast] After determining that the AST has an isolated capture, make sure that we actually process it via an assert.
A little paranoia never hurts.
2024-03-01 12:54:06 -08:00
Michael Gottesman
2e4fad37a1 [concurrency] Make captured self in a closure show up as an @sil_isolated parameter in the closure's function signature.
This ensures that when region isolation is enabled, we can begin properly
modeling when a closure should not be allowed to be isolated. In the next
commit, I am going to loosen this and we should be able to pass in actors
outside of methods without the closure being afflicted with "actor
derived-ness".
2024-03-01 11:54:16 -08:00
Erik Eckstein
58188fcee2 SIL: let the function entry block be the parent block of SILUndefs in the function. 2024-03-01 09:07:12 +01:00
Konrad `ktoso` Malawski
c56a1e8be7 [Distributed] Handle mangling thunks in extensions with generic AS and $Stubs (#71914) 2024-02-29 04:22:00 -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
Joe Groff
64be3978c7 Merge pull request #71933 from jckarter/conditional-copyable-trivial-type-lowering
SIL: More accurate for type lowering whether a type is trivial based on conditional Copyable requirements.
2024-02-28 07:31:06 -08:00
Michael Gottesman
e4f365516d [sil] Also give Placeholder a parent SILFunction. 2024-02-27 17:15:49 -08:00
Joe Groff
fe7049ed13 SIL: More accurate for type lowering whether a type is trivial based on conditional Copyable requirements.
We want a conditionally-copyable type to still be classified as trivial in cases
where it's bitwise-copyable, has a trivial deinit, and is Copyable. The previous
implementation here only checked at the declaration level whether a type was
Copyable or not; get a more accurate answer by consulting the combination
of information in the substituted type and abstraction pattern we have
available during type lowering so that we classify definitely-copyable substitutions
of a conditionally-copyable type as trivial. Should fix rdar://123654553 and
rdar://123658878.
2024-02-27 15:01:20 -08:00
Michael Gottesman
34f87eb477 [sil] Make notifyMovedInstruction rewire the undef of values. 2024-02-27 13:14:48 -08:00