Commit Graph

71 Commits

Author SHA1 Message Date
Mishal Shah
aa6a588f45 Merge pull request #69163 from apple/rebranch
Merge `rebranch` into `main` to support `stable/20230725` llvm-project branch
2023-10-23 09:26:37 -07:00
Konrad `ktoso` Malawski
b542a5dc19 Simplify branching logic 2023-10-20 13:43:46 +09:00
Konrad `ktoso` Malawski
2bda332738 Remove dumpContext 2023-10-20 13:15:47 +09:00
Konrad `ktoso` Malawski
137dddba17 handle detecting generic code better 2023-10-20 10:40:33 +09:00
Konrad `ktoso` Malawski
8159b239d1 [Distributed] Handle dispach thunks of decodeNextArgument in Distributed IRGen
correct way to detect dispatch thunk presence in GenDistributed
2023-10-20 10:30:46 +09:00
Evan Wilde
f4946e9718 Updating more alignment APIs
Adding a few more updates to places where the ABI Alignment functions
changed. `getABITypeAlignment` was replaced with `getABITypeAlign`,
which returns an `llvm::Align` instead of an unsigned int.
2023-07-25 12:28:28 -07:00
Evan Wilde
26a974e772 [NFC] Headers headers headers!
Including headers that were being transitively included from LLVM
before. Also pointing them at the new locations for some of them.
2023-07-17 10:55:55 -07:00
Evan Wilde
8ce6ee8dd1 Updating API usages
LLVM deprecated, renamed, and removed a bunch of APIs. This patch
contains a lot of the changes needed to deal with that.

The SetVector type changed the template parameters.

APInt updated multiple names, countPopulation became popcount,
getAllOnesValue became getAllOnes, getNullValue became getZero, etc...

Clang type nullability check stopped taking a clang AST context.

The LLVM IRGen Function type stopped exposing basic block list directly,
but gained enough API surface that the translation isn't too bad.
(GenControl.cpp, LLVMMergeFunctions.cpp)

llvm::Optional had a transform function. That was being used in a couple
of places, so I've added a new implementation under STLExtras that
transforms valid optionals, otherwise it returns nullopt.
2023-07-17 10:53:42 -07:00
Konrad `ktoso` Malawski
1b74ea62b4 Add test to exercise Indirect_In codepaths in DistributedAccessor emit 2023-07-12 13:22:49 +09:00
Konrad `ktoso` Malawski
5abfc91291 [Distributed] Fix handling indirect @in convention params in distributed funcs
rdar://111887706
2023-07-12 10:24:38 +09:00
Konrad `ktoso` Malawski
b54f409763 [Distributed] Handle composite type in generic bound in distributed accessor
rdar://111664985
2023-07-05 10:36:59 +09:00
Konrad `ktoso` Malawski
0104f2b324 formatting 2023-05-19 23:41:58 +02:00
Konrad `ktoso` Malawski
cd3e243ff8 [Distributed] Ensure decoded classes get refcounted down to 0 from decoding 2023-05-19 23:29:49 +02:00
Pavel Yaskevich
8569c9d081 [IRGen] Distributed: Destroy loaded arguments after the call
Arguments that have been loaded due to underlying method conversion
have to be destroyed after the call otherwise they are going to leak.

Resolves: https://github.com/apple/swift/issues/65853
Resolves: rdar://109207043
2023-05-15 14:46:19 -07:00
John McCall
d25a8aec8b Add explicit lowering for value packs and pack expansions.
- SILPackType carries whether the elements are stored directly
  in the pack, which we're not currently using in the lowering,
  but it's probably something we'll want in the final ABI.
  Having this also makes it clear that we're doing the right
  thing with substitution and element lowering.  I also toyed
  with making this a scalar type, which made it necessary in
  various places, although eventually I pulled back to the
  design where we always use packs as addresses.

- Pack boundaries are a core ABI concept, so the lowering has
  to wrap parameter pack expansions up as packs.  There are huge
  unimplemented holes here where the abstraction pattern will
  need to tell us how many elements to gather into the pack,
  but a naive approach is good enough to get things off the
  ground.

- Pack conventions are related to the existing parameter and
  result conventions, but they're different on enough grounds
  that they deserve to be separated.
2023-01-29 03:29:06 -05:00
Slava Pestov
aae03550b4 IRGen: Basic support for computing function signatures with shape parameters 2022-12-13 11:56:33 -05:00
Nate Chandler
8d8577e5b0 [SIL] Removed Indirect_In_Constant convention.
It is no different from @in.

Continue parse @in_constant in textual and serialized SIL, but just as
an alias for @in.
2022-12-09 21:54:00 -08:00
Arnold Schwaighofer
ae77e795c6 IRGen: Fix the computation of the number of type metadata pointers for distributed thunks under opaque pointer IR
When using opaque pointers we can no longer depend on the LLVM IR type
to perform the computation. Instead compute the number while we are
building a signature.
2022-10-24 09:04:30 -07:00
Holly Borla
c4b946195e [AST] Replace the "type sequence" terminology with "parameter pack". 2022-10-10 16:28:13 -07:00
Arnold Schwaighofer
d810b0f7e4 IRGen: Pass the elementType of pointers through to operations
In preparation for moving to llvm's opaque pointer representation
replace getPointerElementType and CreateCall/CreateLoad/Store uses that
dependent on the address operand's pointer element type.

This means an `Address` carries the element type and we use
`FunctionPointer` in more places or read the function type off the
`llvm::Function`.
2022-10-03 15:27:12 -07:00
Josh Soref
9fa14ca215 Spelling irgen (#42470)
* spelling: abstractable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: across

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: clazz

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: command

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: components

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: current

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: declared

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: discrimination

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: entities

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: except

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: existential

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: generic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialize

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: inserted

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: instantiate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: instantiation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interfere

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interferes

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: intrinsic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: metadata

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: might

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: multiple

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: necessary

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: objective

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: occurrences

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: outlined

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: parameters

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: payload

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: rearchitecting

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: replaceable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: reverse

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: rewritable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: shareably

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: specializations

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: speedup

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: template

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: that

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: the

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: transferred

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: uninitialized

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: witness

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-21 14:02:03 -07:00
Pavel Yaskevich
8c8360a6a1 [Distributed] IRGen: Remove a decodeNextArgument access workaround
The symbol is always retained now, so the workaround to use witness
table for non-final classes is no longer necessary.
2022-04-18 16:53:47 -07:00
Konrad `ktoso` Malawski
4e2c059e20 review feedback, cleanup getting decode func 2022-04-18 16:53:47 -07:00
Pavel Yaskevich
75d155829a [Distributed] Accessor: Add support for generic distributed actors
Augment accessor to support generic distributed actor declarations
e.g. `distributed actor X<T: Codable>`.
2022-03-24 14:12:06 -07:00
Pavel Yaskevich
72fca4ca07 [Distributed] IRGen: Make distributed accessors generic over invocation decoder type
Since invocation decoder is no longer required to be a class-bound
type, accessors have to be made generic over actual type of decoder.

Each accessor still knows what is the expected type of a decoder is
(based on the distributed actor it's associated with), so it still
does direct method calls but it has to load data decoder instance
first iff the decoder is a class.
2022-02-16 14:23:55 -08:00
John McCall
58fe89f359 [NFC] Split up the "special convention" for runtime async functions
The special convention currently means three things:

1. There is no async FP symbol for the function.  Calls should go directly
to the function symbol, and an async context of fixed static size should be
allocated.  This is mandatory for calling runtime-provided async functions.

2. The callee context should be allocated but not initialized.  The main
context pointer passed should be the caller's context, and the continuation
function pointer and callee context should be passed as separate arguments.
The function will resume the continuation function pointer with the caller's
context.  This is a micro-optimization appropriate for functions that are
expected to frequently return immediately; other functions shouldn't bother.

3. Generic arguments should be suppressed.  This is a microoptimization for
certain specific runtime functions where we happen to know that the runtime
already stores the appropriate information internally.  Other functions
probably don't want this.

Obviously, these different treatments should be split into different
predicates so that functions can opt in to different subsets of them.

I've also set the code up so that runtime functions can more easily
request a specific static async context size.  Previously, it was a
confusingly embedded assumption that the static context size was always
exactly two pointers more than the header.
2022-02-15 04:12:05 -05:00
Pavel Yaskevich
67628b7330 Merge pull request #41218 from xedin/dist-watchos-32bit-issues
[Distributed] IRGen: Fix loading of the witness tables
2022-02-05 08:37:17 -08:00
Pavel Yaskevich
ab25d4e62a [Distributed] IRGen: Fix loading of the witness tables
The witness table is an array of pointers - `void **`,
which means that the list of the witnesses has type of `void ***`.

Instead of using result of `emitAddressAtOffset` accessor
should set the correct type for the list, which is `void ***`
and emit bit a lot for each of the witness table slots.

Resolves: rdar://87568630
Resolves: rdar://88340451
2022-02-05 01:12:47 -08:00
Pavel Yaskevich
df3d47f6e5 [Distributed] IRGen: Let debug info know about distributed accessor
Use `emitArtificialFunction` to let debug info know that compiler
is about to generate code for distributed accessor.
2022-02-03 14:47:12 -08:00
Pavel Yaskevich
9694597790 [Distributed] IRGen: Cache protocol requirements of decode method 2022-01-31 00:38:26 -08:00
Pavel Yaskevich
b43d341ef1 [Distributed] IRGen: Augment accessor to lookup witness tables for decode call
`decodeNextArgument` requires (at least) that argument type conform
to a serialization requirement, witness table(s) for all protocol
requirements have to be lookup up by accessor to form correct
`decodeNextArgument` invocation.
2022-01-30 19:04:36 -08:00
Pavel Yaskevich
35e639fc35 [Distributed] IRGen: Don't use designated initializers to create ArgumentDecoderInfo 2022-01-29 14:33:41 -08:00
Pavel Yaskevich
80e6f5039e [Distributed] IRGen: Use direct reference to decodeNextArgument if decoder is final 2022-01-29 14:33:41 -08:00
Pavel Yaskevich
aa44c1dbe1 [Distributed] IRGen: Emit an early return upon argument decoding failure 2022-01-29 14:33:41 -08:00
Pavel Yaskevich
7b159d3edd [Distributed] IRGen: Switch accessor to accept argument decoder instance instead of argument buffer
This obsoletes `HeterogeneousBuffer` and instead emits calls to
`decodeNextArgument` directly in distributed accessor.
2022-01-29 14:33:41 -08:00
Pavel Yaskevich
3a754cbbf2 [Distributed] IRGen: Find a suitable decoder method to decode argument values
Given a distributed thunk, find and cache a pointer to suitable
argument decoder method together with its type. The decoder is
a concrete type associated with actor via `InvocationDecoder`
associated type on `DistributedActorSystem` which should have a
`decodeNextArgument` method.
2022-01-29 14:33:41 -08:00
Pavel Yaskevich
0e03f1e3c7 [Distributed] IRGen: Switch to use InvocationDecoder instead of argument value buffer 2022-01-29 14:33:41 -08:00
Pavel Yaskevich
4cfd1d0adc [Distributed] Switch accessor parameter convention to Direct_Unowned since all of them are trivial 2022-01-24 16:19:53 -08:00
Pavel Yaskevich
59ff689f28 [Distributed] IRGen: Teach distributed thunk accessor to load witness tables (when needed) 2022-01-24 10:18:00 -08:00
Pavel Yaskevich
dc978f2934 [Distributed] IRGen: Support argument with generic parameters passed directly
This is the case of e.g. `Array<T>` where argument is `Array<Int>`
we need to compute offset/size based on argument metadata but load
the argument using parameter type information.
2022-01-24 10:18:00 -08:00
Pavel Yaskevich
cf47cfa7b2 [Distributed] IRGen: Add generic argument substitutions to argument explosion of thunk call 2022-01-24 10:18:00 -08:00
Pavel Yaskevich
406af83329 [Distributed] Runtime/IRGen: Allow passing substitutions to distributed accessor
Accept an optional list of substitutions which are required to form
a call to a generic distributed thunk.
2022-01-24 10:18:00 -08:00
Pavel Yaskevich
925b59826d [Distributed] IRGen: Drop result type for accessor parameters 2022-01-24 10:18:00 -08:00
Pavel Yaskevich
51df87447a [Distributed] IRGen: Support loading both concrete and generic argument values
To load generic argument value, we need to retrieve argument type
from the argument types buffer, based on that load value size and
alignment, and only then fetch actual value from the argument buffer
as `swift.opaque *`.
2022-01-24 10:17:59 -08:00
Pavel Yaskevich
e7ceddc564 [Distributed] IRGen: Provide argument/result types to the accessor 2022-01-24 10:17:59 -08:00
Pavel Yaskevich
0c2121a1a4 [Distributed] IRGen: Fix misspelling in getRawPointerParameter 2022-01-14 15:39:04 -08:00
Konrad `ktoso` Malawski
9438cf6b2e [Distributed] Func metadata operations and implement executeDistributedTarget entry (#40605)
* [Distributed] Implement func metadata and executeDistributedTarget

dont expose new entrypoints

able to get all the way to calling _execute

* [Distributed] reimplement distributed get type info impls

* [Distributed] comment out distributed_actor_remoteCall for now

* [Distributed] disable test on linux for now
2022-01-09 23:55:06 +09:00
Pavel Yaskevich
d516281da9 [Distributed] NFC: Remove Method from accessor APIs
The API is not constrained to methods only, it should support
computed properties as well.
2021-12-23 14:10:05 -08:00
Pavel Yaskevich
375494b3fc [Distributed] IRGen: Fix method pointer retrieval
`getPointerToMethod()` should acoount for the fact that distributed
thunk is an async function, so direct pointer should be to "async
pointer" information instead of SIL function.
2021-12-22 18:11:01 -08:00
Pavel Yaskevich
bcf2d5a1aa [Distributed] IRGen: Make accessor thin and require actor as (last) guaranteed argument 2021-12-22 16:17:53 -08:00