Commit Graph

2441 Commits

Author SHA1 Message Date
swift_jenkins
20836fd582 Merge remote-tracking branch 'origin/main' into next 2020-12-14 14:33:29 -08:00
Richard Wei
8d8614058b [AudoDiff] NFC: Replace 'SILAutoDiffIndices' with 'AutoDiffConfig'. (#35079)
Resolve rdar://71678394 / SR-13889.
2020-12-14 14:32:40 -08:00
swift_jenkins
1cdb072141 Merge remote-tracking branch 'origin/main' into next 2020-12-10 21:06:38 -08:00
John McCall
d874479290 Add builtins to initialize and destroy a default-actor member.
It would be more abstractly correct if this got DI support so
that we destroy the member if the constructor terminates
abnormally, but we can get to that later.
2020-12-10 19:18:53 -05:00
John McCall
b22407ef0c Add a builtin to convert a Task* to a Job*. 2020-12-10 17:06:14 -05:00
swift_jenkins
54c8a97456 Merge remote-tracking branch 'origin/main' into next 2020-12-09 17:12:34 -08:00
Joe Groff
291b75fcc4 Merge pull request #34953 from jckarter/async-native-to-foreign-thunk
[WIP] SILGen: Implement native-to-foreign thunks for async methods.
2020-12-09 17:00:36 -08:00
swift_jenkins
31d3748af7 Merge remote-tracking branch 'origin/main' into next 2020-12-08 20:35:04 -08:00
Andrew Trick
f92009da98 Remove SILArgumentConvention::Direct_Deallocating 2020-12-08 13:41:47 -08:00
Joe Groff
5087e411c2 SILGen: Implement native-to-foreign thunks for async methods.
Bridging an async Swift method back to an ObjC completion-handler-based API requires
that the ObjC thunk spawn a task on which to execute the Swift async API and pass
its results back on to the completion handler.
2020-12-08 10:04:40 -08:00
swift_jenkins
b9cce30f96 Merge remote-tracking branch 'origin/main' into next 2020-12-04 16:19:11 -08:00
Doug Gregor
06a712bff6 Merge pull request #34957 from rjmccall/partial-async-task-is-a-job
Freeze PartialAsyncTask as a Job*
2020-12-04 15:43:44 -08:00
John McCall
ee0bb0a2d5 Freeze PartialAsyncTask as a Job*.
Also fix the extra inhabitants of Builtin.RawUnsafeContinuation
and try to make adding types like this a little less boiler-plate
in the future.
2020-12-04 01:06:29 -05:00
swift_jenkins
e770b42d69 Merge remote-tracking branch 'origin/main' into next 2020-12-03 20:25:45 -08:00
Doug Gregor
41f74e48d5 Merge pull request #34952 from DougGregor/convert-sync-to-async
[Concurrency] Allow synchronous functions to be a subtype of 'async' functions
2020-12-03 20:18:53 -08:00
Doug Gregor
f46ad6c28f [Concurrency] Emit thunk for synchronous -> async function conversion. 2020-12-03 13:47:39 -08:00
swift_jenkins
68b6a7a7a6 Merge remote-tracking branch 'origin/main' into next 2020-12-03 08:30:25 -08:00
Slava Pestov
c133e13efd Merge pull request #34916 from slavapestov/with-unsafe-continuation
Concurrency: Implement withUnsafe[Throwing]Continuation
2020-12-03 11:18:49 -05:00
swift_jenkins
144cc9c1a4 Merge remote-tracking branch 'origin/main' into next 2020-12-01 21:41:10 -08:00
Michael Gottesman
b13a8e9ba3 Merge pull request #34915 from gottesmm/forwarding-silinstruction
[ownership] Centralize all info about SILInstruction forwarding in the SILInstruction class hierarchy itself.
2020-12-01 21:33:27 -08:00
Michael Gottesman
09ae2ef071 [ownership] Centralize all info about SILInstruction forwarding in the SILInstruction class hierarchy itself.
This commit is doing a few things:

1. It is centralizing all decisions about whether an operand's owner instruction
or a value's parent instruction is forwarding in each SILInstruction
itself. This will prevent this information from getting out of sync.

2. This allowed me to hide the low level queries in OwnershipUtils.h that
determined if a SILNodeKind was "forwarding". I tried to minimize the amount of
churn in this PR and thus didn't remove the
is{Owned,Ownership,Guaranteed}Forwarding{Use,Value} checks. Instead I left them
alone but added in asserts to make sure that if the old impl ever returns true,
the neew impl does as well. In a subsequent commit, I am going to remove the old
impl in favor of isa queries.

3. I also in the process discovered that there were some instructions that were
being inconsistently marked as forwarding. All of the asserts in the PR caught
these and I fixed these inconsistencies.
2020-12-01 17:36:19 -08:00
Michael Gottesman
33aec98fff [ownership] Assume values/operands in SILGlobalVariable blocks are not in OSSA.
Operationally it just means that in SILGlobalVariable blocks, all operands have
ownership constraint:

  {OwnershipKind::Any, UseLifetimeConstraint::NonLifetimeEnding}

and all values yield an ownership kind of: OwnershipKind::None.
2020-12-01 17:36:19 -08:00
Slava Pestov
a2dbdecdab SIL: Refactor get_async_continuation[_addr] to return a RawUnsafeContinuation 2020-12-01 20:04:09 -05:00
Slava Pestov
1a89813bf5 AST: Introduce Builtin.RawUnsafeContinuation type
This is otherwise identical to Builtin.RawPointer, but has the spare
bits of a heap object pointer.
2020-12-01 20:03:22 -05:00
swift_jenkins
75f48eccde Merge remote-tracking branch 'origin/main' into next 2020-12-01 12:48:21 -08:00
Michael Gottesman
3fd4aaeb37 Merge pull request #34898 from gottesmm/pr-d3b6d903b097410b535d20940005a1fa67d3a1bf
[auto-diff] Fix a bunch of places in the *Cloners where we were not closing borrow scopes.
2020-12-01 12:42:10 -08:00
swift_jenkins
be2a192a27 Merge remote-tracking branch 'origin/main' into next 2020-12-01 03:56:12 -08:00
Erik Eckstein
6f5cffbcb9 Mangling: add support for mangling the body-function of asyncHandlers
We don't introduce a new mangling here.
To distinguish the names of the original asyncHandler function and it's generated "body-function", we just mangle the body-function with an async attribute, i.e. as if it was declared as async.
This change is mostly to pass information to the ASTMangler to mangle a not async function as "async".
2020-12-01 08:42:56 +01:00
swift_jenkins
8b28c896dd Merge remote-tracking branch 'origin/main' into next 2020-11-30 18:06:27 -08:00
Michael Gottesman
affeba98f9 [auto-diff] Fix a bunch of places in the *Cloners where we were not closing borrow scopes.
These were all just trying to open a borrow scope, so I changed them to use the
API SILBuilder::emitScopedBorrowOperation(SILLocation, SIL).
2020-11-30 16:05:37 -08:00
Richard Wei
de2dbe57ed [AutoDiff] Bump-pointer allocate pullback structs in loops. (#34886)
In derivatives of loops, no longer allocate boxes for indirect case payloads. Instead, use a custom pullback context in the runtime which contains a bump-pointer allocator.

When a function contains a differentiated loop, the closure context is a `Builtin.NativeObject`, which contains a `swift::AutoDiffLinearMapContext` and a tail-allocated top-level linear map struct (which represents the linear map struct that was previously directly partial-applied into the pullback). In branching trace enums, the payloads of previously indirect cases will be allocated by `swift::AutoDiffLinearMapContext::allocate` and stored as a `Builtin.RawPointer`.
2020-11-30 15:49:38 -08:00
swift_jenkins
3bfd2a4bc7 Merge remote-tracking branch 'origin/main' into next 2020-11-30 11:31:01 -08:00
Arnold Schwaighofer
b0be562ded Merge pull request #34829 from aschwaighofer/irgen_get_await_async_continuation
IRGen: get/await_async_continuation support
2020-11-30 11:22:55 -08:00
Michael Gottesman
333737bc7a [sil] Remove usage from TypeLowering of SILBuilder::create*AndFold().
These create*AndFold APIs are actively harmful when used in TypeLowering since:

1. In general they are a problem since it is weird for a builder API to remove
   an instruction.

2. These APIs do not take an erase callback that must be used in passes that
   need to update state before erasing the instruction.

3. The typelowering APIs that use this are emitDestroyValue/etc which are the
   main APIs that we are using to write code that works with OSSA/non-OSSA
   SIL. So we are going to use these APIs in many more places, introducing this
   bug in many places.

With that in mind, I have been committing small cheap ARC optimizations to
GuaranteedARCOpts (SemanticARCOpts with expensive optimizations turned off) so
that we can eliminate this without massively churning the code. We are at this
stage now, so it makes sense to turn this off.
2020-11-30 04:51:39 -08:00
swift_jenkins
2b93e41a77 Merge remote-tracking branch 'origin/main' into next 2020-11-20 03:30:20 -08:00
Doug Gregor
c42add92ec [SIL] Fix ownership of GetCurrentAsyncTask builtin 2020-11-19 23:26:30 -08:00
swift_jenkins
30b10e6c2c Merge remote-tracking branch 'origin/main' into next 2020-11-19 13:54:33 -08:00
Michael Gottesman
84360d9d4c Merge pull request #34811 from gottesmm/pr-81ab56860285486f13f9c56ac738e128e170a9c7
[sil] Add a non-const version of SILPhiArgument *BranchInst::getArgForOperand(Operand *)
2020-11-19 13:22:56 -08:00
Arnold Schwaighofer
b49a882ea1 Add some SIL properties for get/await_async_continuation 2020-11-19 12:38:51 -08:00
swift_jenkins
95faeb155a Merge remote-tracking branch 'origin/main' into next 2020-11-18 22:56:45 -08:00
Michael Gottesman
0f29b67109 [sil] Add a non-const version of SILPhiArgument *BranchInst::getArgForOperand(Operand *) 2020-11-18 13:30:24 -08:00
Michael Gottesman
c35ff33a1f [ownership] Add a subclass for all OwnershipForwarding instructions and fix the classof to the various ownership abstract classes so isa/dyn_cast work.
I think what was happening here was that we were using one of the superclass
classofs and were getting lucky since in the place I was using this I was
guaranteed to have single value instructions and that is what I wrote as my
first case X ).

I also added more robust checks tieing the older isGuaranteed...* APIs to the
ForwardingOperand API. I also eliminated the notion of Branch being an owned
forwarding instruction. We only used this in one place in the compiler (when
finding owned value introducers), yet we treat a phi as an introducer, so we
would never hit a branch in our search since we would stop at the phi argument.
The bigger picture here is that this means that all "forwarding instructions"
either forward ownership for everything or for everything but owned/unowned.

And for those listening in, I did find one instruction that was from an
ownership forwarding subclass but was not marked as forwarding:
DifferentiableFunctionInst. With this change, we can no longer by mistake have
such errors enter the code base.
2020-11-18 12:34:18 -08:00
swift_jenkins
43b2fe020b Merge remote-tracking branch 'origin/main' into next 2020-11-18 11:49:18 -08:00
Michael Gottesman
611284fcc2 [sil] Element shadowing of SILInstruction::getKind() by renaming MarkUninitializedInst::get{,MarkUninitialized}Kind().
Interestingly this problem can only occur if one invokes
MarkUninitializedInst::getKind() directly. Once our instruction is just a
SILInstruction, we call the appropriate method so we didn't notice it.

I used Xcode's refactoring functionality to find all of the invocation
locations.
2020-11-17 21:25:57 -08:00
swift_jenkins
4b89f765a7 Merge remote-tracking branch 'origin/main' into next 2020-11-16 13:52:10 -08:00
Doug Gregor
069dfad638 [Concurrency] Add Builtin.createAsyncTaskFuture.
This new builtin allows the creation of a "future" task, which calls
down to swift_task_create_future to actually form the task.
2020-11-15 22:37:13 -08:00
swift_jenkins
de3fb8bd01 Merge remote-tracking branch 'origin/main' into next 2020-11-15 20:46:34 -08:00
Michael Gottesman
9e0b1d127b [ownership] Make SILUndef always have ValueOwnershipKind::None.
This simplifies the representation and if one wants to truly get an owned value
from an undef, just copy the undef value.
2020-11-15 18:21:32 -08:00
swift_jenkins
65b33806e9 Merge remote-tracking branch 'origin/main' into next 2020-11-13 15:18:50 -08:00
Joe Groff
c7f4f07515 Merge pull request #34713 from jckarter/foreign-async-multi-return-abstraction-pattern
SIL: Abstraction pattern support for multiple foreign async returns.
2020-11-13 15:05:55 -08:00