Commit Graph

2410 Commits

Author SHA1 Message Date
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
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
John McCall
7b3415aa23 Properly erase closure isolation to @isolated(any).
We do this by pushing the conversion down to the emission of the
closure expression, then teaching closure emission to apply the isolation
to the closure.  Ideally, we combine the isolation along with the rest of
the conversion peephole, but if necessary, we make sure we emit the
isolation.
2024-02-26 22:50:58 -05:00
Ben Barham
1306f2b32a Merge pull request #71863 from bnbarham/remove-makearrayref
Use the new template deduction guides rather than `makeArrayRef`
2024-02-25 21:06:51 -08:00
Slava Pestov
6ac91cde5d Merge pull request #71821 from slavapestov/inheritance-clause-fixes
Refactor protocol inheritance clauses and existential layout for non-copyable generics
2024-02-24 11:58:03 -05:00
Slava Pestov
0e31d41072 AST: Move GenericSignature::typeErased() to SIL
This is used by the specializer and belongs at the SIL level.
2024-02-24 07:25:59 -05: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
John McCall
b4a5ad2f4d Merge pull request #71833 from rjmccall/function-subtype-peephole-preparation
Propagate function subtype conversion information down to closure emission
2024-02-23 21:42:59 -05:00
Meghana Gupta
c901f97d8f Update visitRecursivelyLifetimeEndingUses for users with multiple results 2024-02-23 15:29:06 -08:00
John McCall
5c2cd18a5b Teach SILGen to try to peephole a function conversion into the emission of
a closure expression, then don't actually do it.  The long term plan is
to actually do this, which should just be a matter of taking some of the
code out of reabstraction thunk emission and using it in prolog/epilog/return
emission.  In the short term, the goal is just to get the conversion
information down to the closure emitter so that we can see that we're
erasing into an `@isolated(any)` type and then actually erase the
closure's isolation properly instead of relying on type-based erasure,
which can't handle parameter/capture isolation correctly.
2024-02-23 02:59:39 -05:00
Pavel Yaskevich
f9ec3b1d7e Merge pull request #71796 from xedin/make-dist-new-requirements-conditionally-available
[Distributed] Make new protocol requirements conditionally available
2024-02-22 15:18:52 -08:00
Joe Groff
161183cbc4 Merge pull request #71803 from jckarter/begin-borrow-fixed-switch-subject
SIL: Enclose switch subjects in a new begin_borrow [fixed] variant.
2024-02-22 14:45:17 -08:00
Erik Eckstein
3488cd364f SIL: remove instruction leaks checking
It's not thread safe and can cause false alarms in case multiple modules exist in different threads. E.g. when building swiftmodules from interfaces.
The leaking check is not important anymore because the builder APIs enforce that instructions are not leaking.
I.e. it's not possible to create an instruction without inserting it into a basic block. Also, it's not possible to remove an instruction from a block without deleting it.

rdar://122169263
2024-02-22 14:09:11 +01:00
Erik Eckstein
c996601f97 SIL: object instruction is not a forwarding instruction
Because it can only appear in the initializer list of a global variable.
2024-02-22 07:12:10 +01:00
Joe Groff
d75a62ce64 SIL: Enclose switch subjects in a new begin_borrow [fixed] variant.
We want to preserve the borrow scope during switch dispatch so that move-only
checking doesn't try to analyze destructures or consumes out of it. SILGen
should mark anywhere that's a potential possibility with its own marker so that
it gets borrow checked independently.
2024-02-21 20:41:20 -08:00
Pavel Yaskevich
39b81ac783 [AST] Handle generic actor system when trying to produce a ref to decodeNextArgument 2024-02-21 13:29:47 -08:00
Pavel Yaskevich
65d164a9c3 Revert "[SIL] Distributed: Remove logic related to ad-hoc requirements from SILFunction"
This reverts commit 1909b12370.
2024-02-21 13:29:47 -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
John McCall
868fc6ad46 Basic SILGen for @isolated(any).
The main piece that's still missing here is support for closures;
they actually mostly work, but they infer the wrong isolation for
actor-isolated closures (it's not expressed in the type, so obviously
they're non-isolated), so it's not really functional.  We also have
a significant problem where reabstraction thunks collide incorrectly
because we don't mangle (or represent!) formal isolation into
SILFunctionType; that's another follow-up.  Otherwise, I think SILGen
is working.
2024-02-19 21:21:03 -05:00
nate-chandler
21eaaaa00a Merge pull request #71632 from nate-chandler/bitwise-copyable/dont-infer-package
[BitwiseCopyable] Don't infer for packages types.
2024-02-15 06:39:45 -08:00
Michael Gottesman
23ab974574 Merge pull request #71567 from gottesmm/transferring-param
[transferring] Implement transferring result and clean up transferring param support by making transferring a bit on param instead of a ParamSpecifier.
2024-02-14 17:54:48 -08:00
Nate Chandler
b4323c8831 [TypeLowering] Loosen assertion. 2024-02-14 16:35:55 -08:00
Nate Chandler
50deb13747 [TypeLowering] Loosen assertion.
Types appearing in the context of variadic generics may be trivial but
not conform to BitwiseCopyable.
2024-02-14 16:35:55 -08:00
Nate Chandler
8621742fed [BitwiseCopyable] Don't infer for packages types.
Like public and @usableFromInline types, package types too are exported.
In the case of a module built with library evolution, they may cease to
conform in the future.  Apply the same rule regardless of that build
configuration.
2024-02-14 16:35:55 -08:00
Michael Gottesman
f3edb5730a [transferring] Add support for transferring results.
rdar://121324697
2024-02-14 14:39:02 -08:00
Nate Chandler
427d9cbcba [TypeLowering] Loosen assertion. 2024-02-14 09:57:43 -08:00
Nate Chandler
10dd58152b NFC: [TypeLowering] Add flag to skip verify.
To allow skipping it when verification has a false positive.
2024-02-14 09:57:43 -08:00
Nate Chandler
187f434798 [BitwiseCopyable] Uniform inference for non-frozen
Don't key inference behavior off of library evolution mode.
2024-02-14 09:57:43 -08:00
Nate Chandler
3b0a13a1fd [BitwiseCopyable] Don't verify for interfaces.
Modules built without the feature enabled will have swiftinterfaces
whose types don't conform to the protocol.
2024-02-14 08:20:16 -08:00
Erik Eckstein
6e8b80c791 SIL: add printing and parsing support for specialized vtables
If the vtable refers to a specialized class, a SIL type specifies the bound generic class type:
```
  sil_vtable $G<Int> {
    // ...
  }
```
2024-02-14 09:51:36 +01:00
John McCall
b23bc82cdb Merge pull request #71574 from rjmccall/isolation-any-sil-irgen
SIL and IRGen support for `@isolated(any)` function types
2024-02-13 11:57:16 -05:00
Doug Gregor
eeeb8c3f18 Merge pull request #71577 from DougGregor/silgen-no-peeping-typed-throws-closures
[SILGen] Don't peephole closures with abstraction differences in the thrown error
2024-02-13 08:53:45 -08:00