Commit Graph

6754 Commits

Author SHA1 Message Date
Yuta Saito
1a75b08188 [SILGen] Fix swift_once initializer signature for lazy global var
`Builtin.once` has type `(Builtin.RawPointer, (Builtin.RawPointer) -> ())`
at Swift level, but lazy global init passes its initializer as `() -> ()`,
so their callee and caller signatures doesn't match.
2022-04-03 17:27:43 +00:00
Anthony Latsis
62a2c9e265 Merge pull request #42137 from AnthonyLatsis/objc-optional-keypath
SILGen: Handle key paths with `@objc optional` property and subscript components
2022-04-02 13:53:25 +03:00
Anthony Latsis
075db56329 SILGen: Handle key paths with @objc optional subscript components 2022-04-01 17:15:32 +03:00
Anthony Latsis
8462493fc9 SILGen: Avoid passing an expression to emitDynamicSubscriptExpr 2022-04-01 17:15:32 +03:00
Anthony Latsis
c23b9a49ae SILGen: Handle key paths with @objc optional property components 2022-04-01 17:15:32 +03:00
Anthony Latsis
b68457b6aa [NFC] Gardening: Clean up a redundant computation 2022-04-01 17:15:32 +03:00
Anthony Latsis
9666ea635d SILGenApply: Avoid passing an expression to emitDynamicMemberRefExpr 2022-04-01 17:15:12 +03:00
Joe Groff
d451203b7f SILGen: Emit async let entry points at correct abstraction level.
Avoid a reabstraction thunk every time an async let entry point is emitted,
by setting the context abstraction level while we emit the implicit closure.
Adjust some surrounding logic that breaks when we do this:

- When lowering a non-throwing function type against a throwing abstraction
  pattern, include the error type in the lowered substituted type. Async
  throwing and nonthrowing functions would require another thunk to convert
  away the throwingness of the async context, which would defeat the purpose.
- Adjust the code in IRGen that pads the initial context size for `async let`
  entry points so that it works when the entry point has not yet emitted, by
  marking the async function pointer to be padded later if it isn't defined
  yet.
2022-03-30 14:51:46 -07:00
Allan Shortlidge
0c2719369c Merge pull request #42014 from tshortli/allow-back-deploy-attr-on-coroutines
SILGen: Handle coroutines with the @_backDeploy attribute
2022-03-25 15:01:16 -07:00
Kavon Farvardin
ba9f627700 minor clean-ups 2022-03-25 20:07:45 +09:00
Konrad `ktoso` Malawski
466c6338d7 [Distributed] Also cover remote distributed call in test 2022-03-25 17:07:43 +09:00
Konrad `ktoso` Malawski
ef10cd016a [Distributed] Fix generic returning distributed funcs 2022-03-25 16:19:08 +09:00
Kavon Farvardin
af683dc271 basic implementation of performing an init of the id after an assign of the actorSystem.
The resignID call within the initializer moved into DI, because an assignment to
the actorSystem, and thus initialization of the id, is no longer guaranteed to happen.
Thus, while we previously could model the resignation as a clean-up emitted on all
unwind paths in an initializer, now it's conditional, based on whether the id was
initialized. This is exactly what DI is designed to do, so we inject the resignation
call just before we call the identity's deinit.
2022-03-24 16:20:01 -07:00
Kavon Farvardin
6c0cfac69a remove dependence on system parameter in SILGen/DefiniteInit 2022-03-24 16:18:49 -07:00
Allan Shortlidge
019a345932 SILGen: Generate appropriate SIL for @_backDeploy thunks that wrap coroutine functions (such as the _read and _modify accessors). Remove the temporary diagnostics that rejected use of @_backDeploy on decls that would result in coroutines. 2022-03-24 15:42:14 -07:00
Doug Gregor
f1dde51f96 Merge pull request #42007 from DougGregor/std-next-ub-silgen-bridging
Eliminate undefined behavior where we call `next` on a past-the-end iterator
2022-03-24 13:17:22 -07:00
Doug Gregor
9343446312 Eliminate undefined behavior where we call next on a past-the-end iterator.
Speculative fix for rdar://90735823.
2022-03-24 10:29:03 -07:00
nate-chandler
9e0af175ea Merge pull request #41983 from nate-chandler/opv-silgen-pr/bb-arg-value-category-override
[SIL-opaque] Don't override arg value category.
2022-03-24 09:58:37 -07:00
nate-chandler
abb6f52911 Merge pull request #41982 from nate-chandler/opv-silgen-pr/forward-capture-let
[SIL-opaque] Handled forward captures.
2022-03-24 09:51:09 -07:00
Konrad `ktoso` Malawski
8d3e7d91c0 [Distributed] ResultHandler.onReturn must be ad-hoc because SerializationRequirement (#41916)
* [Distributed] Invoke handler.onReturn ad hoc via ast synthesized func

* reformat and cleanup

* remove unused var
2022-03-24 21:44:37 +09:00
Nate Chandler
a532c53cc5 [SIL-opaque] Don't override arg value category.
Previously, when emitting block arguments, the value category of the
SILType was overridden to be address for indirect arguments.  With
opaque types, that distinction is made later during AddressLowering.  So
only do that when opaque types are disabled.
2022-03-23 12:36:14 -07:00
Nate Chandler
6acfad653f [SIL-opaque] Handled forward captures.
A let that isn't defined yet can be captured by a local function to
which a closure is formed.  Don't use an address type unless we're using
lowered addresses.
2022-03-23 12:34:08 -07:00
Andrew Trick
caaad424d8 [SIL-opaque] Various SILGen fixes 2022-03-22 17:04:13 -07:00
Andrew Trick
2fd4de411e [SIL-opaque] Removed [Unconditional]CheckedCastValue 2022-03-22 17:04:13 -07:00
Andrew Trick
406aa86d2e Merge pull request #41557 from atrick/addrlower-update
Update and reimplement AddressLowering pass (for SIL opaque values).
2022-03-21 22:15:06 -07:00
Konrad `ktoso` Malawski
8c13370242 [Distributed] rename _Distributed to underscoreless module 2022-03-16 08:35:35 +09:00
Konrad `ktoso` Malawski
14bbd27e83 [Distributed] remove a few warnings 2022-03-15 17:13:41 +09:00
Dario Rexin
6d55ecd37d Merge pull request #41459 from drexin/wip-dealloc-recur
[SILGen] Optimize generated dealloc for linearly recursive data struc…
2022-03-14 08:12:48 -07:00
Doug Gregor
4d5d9e3d56 Merge pull request #41792 from DougGregor/collapse-thunk-types 2022-03-11 19:15:43 -08:00
Doug Gregor
3cb7af086d Move SILGenFunction::buildThunkType out to a utility function 2022-03-11 15:09:24 -08:00
swift-ci
94de12b022 Merge pull request #41788 from tshortli/back-deploy-accessors
SILGen: Fix accessor functions with `@_backDeploy`
2022-03-11 14:51:33 -08:00
Allan Shortlidge
c1e326cbb0 SILGen: Fix SILGen for accessor functions with @_backDeploy. Previously, the @_backDeploy attribute was ignored when generating SIL for accessors on declarations with the attribute since the accessor decls themselves were not directly annotated.
Also, emit an error when `@_backDeploy` is applied to coroutine accessors since they are not supported yet.

Resolves rdar://90112441
2022-03-11 11:07:04 -08:00
Konrad `ktoso` Malawski
6d502fc042 [Distributed] Implicit Codable conformance for Dist Actors
[Witness] implement dump() on witness
2022-03-11 18:07:14 +09:00
Doug Gregor
459fb371f9 Merge pull request #41768 from DougGregor/emit-unnamed-isolated-params 2022-03-10 20:07:07 -08:00
Doug Gregor
1466afcf44 Ensure that emit unnamed isolated parameters
... because we need to be able to hop to their actors.
Fixes rdar://86753732.
2022-03-10 09:45:03 -08:00
Konrad `ktoso` Malawski
5ab8e0834d [Distributed] Reimplement distributed call thunks completely in AST (#41616)
* [Distributed] dist actor always has default executor (currently)

* [Distributed] extra test for missing makeEncoder

* [DistributedDecl] Add DistributedActorSystem to known SDK types

* [DistributedActor] ok progress on getting the system via witness

* [Distributed] allow hop-to `let any: any X` where X is DistActor

* [Distributed] AST: Add an accessor to determine whether type is distributed actor

- Classes have specialized method on their declarations
- Archetypes and existentials check their conformances for
  presence of `DistributedActor` protocol.

* [Distributed] AST: Account for distributed members declared in class extensions

`getConcreteReplacementForProtocolActorSystemType` should use `getSelfClassDecl`
otherwise it wouldn't be able to find actor if the member is declared in an extension.

* [Distributed] fix ad-hoc requirement checks for 'mutating'

[PreChecker] LookupDC might be null, so account for that

* [Distributed] Completed AST synthesis for dist thunk

* [Distributed][ASTDumper] print pretty distributed in right color in AST dumps

* wip on making the local/remote calls

* using the _local to mark the localCall as known local

* [Distributed] fix passing Never when not throwing

* fix lifetime of mangled string

* [Distributed] Implement recordGenericSubstitution

* [Distributed] Dont add .

* [Distributed] dont emit thunk when func broken

* [Distributed] fix tests; cleanups

* [Distributed] cleanup, move is... funcs to DistributedDecl

* [Distributed] Remove SILGen for distributed thunks, it is in Sema now!

* [Distributed]  no need to check stored props in protocols

* remote not used flag

* fix mangling test

* [Distributed] Synthesis: Don't re-use AST nodes for `decodeArgument` references

* [Distributed] Synthesis: Make sure that each thunk parameter has an internal name

* [Distributed/Synthesis] NFC: Add a comment regarding empty internal parameter names

* [Distributed] NFC: Adjust distributed thunk manglings in the accessor section test-cases

* cleanup

* [Distributed] NFC: Adjust distributed thunk manglings in the accessor thunk test-cases

* review follow ups

* xfail some linux tests for now so we can land the AST thunk

* Update distributed_actor_remote_functions.swift

Co-authored-by: Pavel Yaskevich <xedin@apache.org>
2022-03-10 23:58:23 +09:00
Andrew Trick
2907c61203 SILModule::hasLoweredAddress 2022-03-09 17:18:15 -08:00
Dario Rexin
ba0de89a52 Addressed more review feedback 2022-03-09 13:56:47 -08:00
Erik Eckstein
6a020f8f15 Stabilize and simplify SIL linkage and serialization
The main point of this change is to make sure that a shared function always has a body: both, in the optimizer pipeline and in the swiftmodule file.
This is important because the compiler always needs to emit code for a shared function. Shared functions cannot be referenced from outside the module.
In several corner cases we missed to maintain this invariant which resulted in unresolved-symbol linker errors.

As side-effect of this change we can drop the shared_external SIL linkage and the IsSerializable flag, which simplifies the serialization and linkage concept.
2022-03-09 15:28:05 +01:00
Robert Widmann
ab44a07045 Convert DeclContext Parameters to their Associated Generic Signatures Instead 2022-03-07 22:54:23 -08:00
Robert Widmann
d6186c9cfb Add a DeclContext Parameter to Opened Archetype Construction
This ensures that opened archetypes always inherit any outer generic parameters from the context in which they reside. This matters because class bounds may bind generic parameters from these outer contexts, and without the outer context you can wind up with ill-formed generic environments like

<τ_0_0, where τ_0_0 : C<T>, τ_0_0 : P>

Where T is otherwise unbound because there is no entry for it among the generic parameters of the environment's associated generic signature.
2022-03-07 22:54:22 -08:00
Dario Rexin
06aa3349dc Address review feedback 2022-03-03 09:24:46 -08:00
Allan Shortlidge
f6ab0ae7a3 Merge pull request #41612 from tshortli/back-deploy-diagnose-decls
Update @_backDeploy ABI semantics and diagnose invalid declarations
2022-03-02 12:52:47 -08:00
Allan Shortlidge
0f890b86fa Sema: Diagnose use of the @_backDeploy attribute on non-final and @objc decls. 2022-03-01 16:37:32 -08:00
Joe Groff
fb178c6c65 Merge pull request #41549 from jckarter/disable-reabstraction-opt-for-foreign-convention
SILGen: Add missing processing to reabstraction fast-path.
2022-02-28 10:32:25 -08:00
swift-ci
e16b126f09 Merge pull request #41571 from kavon/SR-15703
[SR-15703] Fix missing hop in error path of foreign async throws call
2022-02-25 21:31:18 -08:00
Allan Shortlidge
d203876d36 SILGen: Use the OS version specified in the @_backDeploy attribute instead of the version specified in the @available attribute when emitting the if #available condition in back deployment thunks. 2022-02-25 17:51:12 -08:00
Allan Shortlidge
9e4ba442a2 Merge pull request #41416 from tshortli/back-deploy-thunk
Emit and call thunks for back deployed functions
2022-02-25 17:49:08 -08:00
Kavon Farvardin
afd26d3974 [SR-15703] Fix missing hop in error path of foreign async throws call
resolves rdar://89479707
2022-02-25 18:32:43 -07:00
Kavon Farvardin
01d470ce32 Simplify lifetime extension for async ObjC calls.
Since the clean-up is not unwind only, we can rely on the
clean-ups to be emitted on both result and throw paths.

This does slightly change when the hop_to_executor is emitted,
in those paths, but that shouldn't matter.

refactors solution for rdar://78982371
2022-02-25 18:32:13 -07:00