Commit Graph

576 Commits

Author SHA1 Message Date
swift-ci
51d5b9ecb3 Merge remote-tracking branch 'origin/main' into rebranch 2022-01-06 18:12:04 -08:00
zoecarver
036361d1e4 [cxx-interop] Add SIL function representation cxx_method; Support extending C++ types.
There are three major changes here:
    1. The addition of "SILFunctionTypeRepresentation::CXXMethod".
    2. C++ methods are imported with their members *last*. Then the arguments are switched when emitting the IR for an application of the function.
    3. Clang decls are now marked as foreign witnesses.

These are all steps towards being able to have C++ protocol conformance.
2022-01-06 14:26:47 -08:00
swift-ci
5de9378216 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-18 17:33:54 -08:00
Arnold Schwaighofer
17c899ab18 NFC: Trigger a rebuild 2021-12-18 17:17:48 -08:00
swift-ci
103ce0b560 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-08 11:38:04 -08:00
Zoe Carver
a46a3c525a Merge pull request #39605 from zoecarver/cxx-interop-import-as-class
[cxx-interop] Implement foreign reference types.
2021-12-08 19:33:50 +00:00
zoecarver
fc3b3a1d71 [cxx-interop] Implement foreign reference types.
This is an expiremental feature to allow an attribute, `import_as_ref`, to import a C++ record as a non-reference-counted reference type in Swift.
2021-12-08 15:35:18 +00:00
swift-ci
c3a6c673e2 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-06 16:34:02 -08:00
Doug Gregor
0398252600 Merge pull request #39680 from kateinoigakukun/katei/fix-ill-unreachable-coro-end
[IRGen] Put 'ret void' instead of unreachable for non swiftasync cc
2021-12-06 16:22:13 -08:00
Ben Barham
4ad43d0770 [rebranch] Handle new BuiltinType::Ibm128 2021-11-13 17:04:29 +10:00
Ben Barham
30be5117d2 [rebranch][IRGen] Update uses of AttributeList functions
The functions in llvm-project `AttributeList` have been
renamed/refactored to help remove uses of `AttributeList::*Index`.

Update to use these new functions where possible. There's one use of
`AttrIndex` remaining as `replaceAttributeTypeAtIndex` still takes the
index and there is no `param` equivalent. We could add one locally, but
presumably that will be added eventually.
2021-11-13 17:04:29 +10:00
Saleem Abdulrasool
68bc33fed3 IRGen: initial pass to support async inheritance on Windows
With PE/COFF, one cannot reference a data symbol directly across the
binary module boundary.  Instead, the reference must be indirected
through the Import Address Table (IAT) to allow for position
independence.

When generating a reference to a AsyncFunctionPointer ({i8*, i32}), we
tag the pointer as being indirected by tagging bit 1 (with the
assumption that native alignment will ensure 4/8 byte alignment, freeing
the bottom 2 bits at least for bit-packing).  We tweak the
v-table/witness table emission such that all references to the
AsyncFunctionPointer are replaced with the linker synthetic import
symbol with the bit packing:

~~~
.quad __imp_$s1L1CC1yyYaKFTu+1
~~~

rather than

~~~
.quad $s1L1CC1yyYaKFTu
~~~

Upon access of the async function pointer reference, we open-code the
check for the following:

~~~
pointer = (pointer & 1) ? *(void **)(pointer & ~1) : pointer;
~~~

Thanks to @DougGregor for the discussion and the suggestion for the
pointer tagging.  Thanks to @aschwaighofer for pointers to the code that
I had missed.  Also, thanks to @SeanROlszewski for the original code
sample that led to the reduced test case.

Fixes: SR-15399
2021-11-01 11:23:51 -07:00
Arnold Schwaighofer
8f159cfb88 Fix some deprecated uses of IRBuilder API
rdar://84034998
2021-10-11 11:01:22 -07:00
Yuta Saito
671ce74e97 [IRGen] Put 'ret void' instead of unreachable for non swiftasync cc
If target doesn't support musttail (e.g. WebAssembly), the function
passed to coro.end.async can return control back to the caller.
So the frontend should emit 'ret void' instead of unreachable after the
coro.end.async intrinsic call to allow such situation.
2021-10-11 09:09:41 -07:00
swift-ci
5b4cd0af88 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-09 10:13:47 -07:00
Arnold Schwaighofer
8cdde7a618 IRGen: Define and use an earliest insertion point
This is to deal with the fact that LLVM's coroutine can't handle instructions
with side-effects well that are inserted before the coro.begin.

rdar://81113950
2021-07-29 09:53:46 -07:00
swift_jenkins
1bd446a6cb Merge remote-tracking branch 'origin/main' into next 2021-06-24 16:21:41 -07:00
Doug Gregor
7def279cdb Drop task options from the createAsyncTask SIL builtin.
We'll keep the task options entirely as a contract between IRGen and
the concurrency runtime, so Swift code need not deal with them.
2021-06-24 07:53:18 -07:00
Doug Gregor
e7e922ea77 Introduce a createAsyncTaskInGroup SIL builtin.
Rather than using group task options constructed from the Swift parts
of the _Concurrency library and passed through `createAsyncTask`'s
options, introduce a separate builtin that always takes a group. Move
the responsibility for creating the options structure into IRGen, so
we don't need to expose the TaskGroupTaskOptionRecord type in Swift.
2021-06-24 07:53:18 -07:00
Doug Gregor
76959b1d4f Remove CreateAsyncTaskGroupFuture and swift_task_create_group_future.
We've moved everything over to `CreateAsyncTask` now.
2021-06-24 07:53:18 -07:00
Doug Gregor
a61adace85 Remove CreateAsyncTaskFuture and swift_task_create_future.
We no longer need these entry points.
2021-06-24 07:53:18 -07:00
Doug Gregor
c7edfa3ba9 Centralize non-group task creation on swift_task_create[_f].
Introduce a builtin `createAsyncTask` that maps to `swift_task_create`,
and use that for the non-group task creation operations based on the
task-creation flags. `swift_task_create` and the thin function version
`swift_task_create_f` go through the dynamically-replaceable
`swift_task_create_common`, where all of the task creation logic is
present.

While here, move copying of task locals and the initial scheduling of
the task into `swift_task_create_common`, enabling by separate flags.
2021-06-24 07:53:17 -07:00
swift_jenkins
62eb8bc454 Merge remote-tracking branch 'origin/main' into next 2021-06-23 11:02:21 -07:00
Mishal Shah
a23e169a93 Merge pull request #37984 from aschwaighofer/fix_task_wait_arm64e
Fix taskWait function family calls on arm64e
2021-06-23 10:51:24 -07:00
swift_jenkins
48d2491743 Merge remote-tracking branch 'origin/main' into next 2021-06-21 16:43:04 -07:00
Konrad `ktoso` Malawski
8536100354 [Concurrency] introduce task options, and change ABI to accept them
introduce new options parameter to all task spawning

[Concurrency] ABI for asynclet start to accept options

[Concurrency] fix unittest usages of changed task creation ABI

[Concurrency] introduce constants for parameter indexes in ownership

[Concurrency] fix test/SILOptimizer/closure_lifetime_fixup_concurrency.swift
2021-06-21 13:03:50 +09:00
Arnold Schwaighofer
1cf63f8316 Fix taskWait function family calls on arm64e
The function pointer we pass to the task_wait functions needs to be
signed.
2021-06-18 13:47:50 -07:00
swift_jenkins
cd4fc2f5fa Merge remote-tracking branch 'origin/main' into next 2021-06-15 07:04:46 -07:00
Arnold Schwaighofer
10e3d2e3af Change _wait(_throwing) ABIs to reduce code size
Changes the task, taskGroup, asyncLet wait funtion call ABIs.

To reduce code size pass the context parameters and resumption function
as arguments to the wait function.

This means that the suspend point does not need to store parent context
and resumption to the suspend point's context.

```
  void swift_task_future_wait_throwing(
    OpaqueValue * result,
    SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
    AsyncTask *task,
    ThrowingTaskFutureWaitContinuationFunction *resume,
    AsyncContext *callContext);
```

The runtime passes the caller context to the resume entry point saving
the load of the parent context in the resumption function.

This patch adds a `Metadata *` field to `GroupImpl`. The await entry
pointer no longer pass the metadata pointer and there is a path through
the runtime where the task future is no longer available.
2021-06-08 10:41:26 -07:00
swift_jenkins
4eff2c1b0d Merge remote-tracking branch 'origin/main' into next 2021-06-02 06:41:35 -07:00
Arnold Schwaighofer
d06c9f3247 IRGen: Add the swiftasync attribute to the resume function call for await_async_continuation
Without this we are going to crash (timing dependent) in
withUnsafeContinuation and bridged async objective c calls.

rdar://78031499
2021-06-01 15:47:32 -07:00
swift_jenkins
66146d5d54 Merge remote-tracking branch 'origin/main' into next 2021-05-03 07:43:02 -07:00
Arnold Schwaighofer
8699c229e6 Check the callee for async'ness 2021-04-30 13:54:47 -07:00
Arnold Schwaighofer
0edbca04bf IRGen: Don't ignore the error parameter in some async functions
Calls that emit the result to memory follow a different path that we
missed to update with error handling code.

rdar://76599021
2021-04-30 12:22:50 -07:00
swift_jenkins
50c215ca92 Merge remote-tracking branch 'origin/main' into next 2021-04-23 13:28:08 -07:00
Arnold Schwaighofer
1f890dc6a2 IRGen: Fix async dynamic replacements
We need to emit a full async suspend sequence when calling the
replacement.

rdar://77072724
2021-04-23 09:03:51 -07:00
swift_jenkins
2c2f2ae3db Merge remote-tracking branch 'origin/main' into next 2021-04-23 01:41:35 -07:00
Yuta Saito
619226b480 Fix calling convention mismatch on Builtin.getCurrentAsyncTask (#37008)
* Add explicit calling convention on builtin GetCurrentTask

This builtin function emits a call of swift_task_getCurrent, and user
code can declare the same name function with slightly different
signature at LLVM level (data size should be same) using @_silgen_name.
In that case, IRGen insert cast inst to cast the function to the
expected signature. But this cast inst drops calling convention info, so
call inst was emitted without swiftcc.

This patch changed to emit a call of swift_task_getCurrent with the
explicit calling convention.

* Add test case to ensure builtin function cc when conflict
2021-04-23 09:35:37 +01:00
swift_jenkins
8a495314e8 Merge remote-tracking branch 'origin/main' into next 2021-04-20 00:21:01 -07:00
Konrad `ktoso` Malawski
d3c5ebc9b7 [AsyncLet] reimplemented with new ABI and builtins 2021-04-19 10:06:23 +09:00
Konrad `ktoso` Malawski
ba615029c7 [Concurrency] Store child record when async let child task spawned 2021-04-19 10:06:23 +09:00
swift_jenkins
11c3675001 Merge remote-tracking branch 'origin/main' into next 2021-04-08 14:01:51 -07:00
John McCall
156264f8e8 Make ExecutorRef two words. 2021-04-08 12:57:12 -04:00
swift_jenkins
d90eb93471 Merge remote-tracking branch 'origin/main' into next 2021-04-07 23:21:42 -07:00
Nate Chandler
6bbc96b8c8 [IRGen] Added fn ptr to async FunctionPointer.
The address of the function to be called when generating code to invoke
the function associated with FunctionPointer which is produced via
direct reference is by definition statically known; it is neither necessary
nor desireable to load this address out of the AsyncFunctionPointer
corresponding to the function.

Here, that spurious additional work is skipped.  The approach is to add
a second value to the FunctionPointer struct.  For FunctionPointers
whose kind is AsyncFunctionPointer, this value is either null or else
the address of the corresponding function.

rdar://71376092
2021-04-07 16:11:09 -07:00
swift_jenkins
54cd4d21cb Merge remote-tracking branch 'origin/main' into next 2021-04-06 13:41:18 -07:00
Nate Chandler
d3e0e7af07 [ptrauth] Signed AsyncFunctionPointers as data.
Previously, AsyncFunctionPointer constants were signed as code.  That
was incorrect considering that these constants are in fact data.  Here,
that is fixed.

rdar://76118522
2021-04-05 18:24:41 -07:00
swift_jenkins
96a053afeb Merge remote-tracking branch 'origin/main' into next 2021-04-01 19:02:19 -07:00
Arnold Schwaighofer
8e1d25b9f9 IRGen: Fix async throw emission for indirect direct values
rdar://76009728
2021-04-01 07:22:13 -07:00
Arnold Schwaighofer
027119fecb Merge remote-tracking branch 'upstream/main' into next 2021-03-29 12:33:25 -07:00