Commit Graph

12848 Commits

Author SHA1 Message Date
Pavel Yaskevich
91b6bda2d9 [IRGen] Distributed: Don't attempt to inject protocols without witness tables 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
a6a2a74c9b [SILOptimizer] Distributed: Suppress signature specialization for witnesses with ad-hoc serialization requirement 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
6c7000ae0b [Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationResultHandler.onReturn 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
4d45701046 [Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationDecoder.decodeNextArgument 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
4f32111bf8 [Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationEncoder.record{Argument, ReturnType} 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
c05497f1b6 [IRGen] Implement dynamic witness table lookup for Res of DistributedActorSystem.remoteCall witnesses
When IRGen is building a protocol witness thunk for a
`DistributedActorSystem.remoteCall` requirement we
need to supply witness tables associated with `Res`
generic parameter which are not expressible on the
requirement because they come from `SerializationRequirement`
associated type.
2024-02-12 14:26:30 -08:00
Allan Shortlidge
2990c65457 NFC: Address some unused variable warnings. 2024-02-12 12:23:42 -08:00
Cyndy Ishida
f80da87839 [TBDGen] Add back standalone OBJC_METACLASS symbols (#70827)
It turns out there are valid usecases for exposing a standalone
objc-metaclass symbols and tbd files must encode it correctly.

resolves: rdar://118499886
2024-02-12 12:23:14 -08:00
Becca Royal-Gordon
68ec6b68de Support class extensions in objcImpl
Their requirements are now included when typechecking the main body extension, and their conformances are emitted in IRGen.

Fixes rdar://118535473.
2024-02-09 21:32:06 -08:00
Kavon Farvardin
74a3839cf3 Merge pull request #71515 from kavon/ncgenerics-test-fixes-kavon-v7
Ncgenerics test fixes kavon v7
2024-02-09 19:39:18 -08:00
Slava Pestov
06b1aee360 Evaluator: Cache circular evaluation to avoid redundant diagnostics
Previously, if a request R evaluated itself N times, we would emit N
"circular reference" diagnostics. These add no value, so instead let's
cache the user-provided default value on the first circular evaluation.

This changes things slightly so that instead of returning an
llvm::Expected<Request::OutputType>, various evaluator methods take
a callback which can produce the default value.

The existing evaluateOrDefault() interface is unchanged, and a new
evaluateOrFatal() entry point replaces
llvm::cantFail(ctx.evaluator(...)).

Direct callers of the evaluator's operator() were updated to pass in
the callback. The benefit of the callback over evaluateOrDefault() is
that if the default value is expensive to constuct, like a dummy
generic signature, we will only construct it in the case where a
cycle actually happened, otherwise we just delete the callback.

(cherry picked from commit b8fcf1c709efa6cd28e1217bd0efe876f7c0d2b7)
2024-02-09 16:02:24 -08:00
Arnold Schwaighofer
ed7dead648 LargeTypesReg2Mem: Handle the optional projections with larger payloads
rdar://122598081
2024-02-09 13:09:03 -08:00
Andrew Trick
da3f583492 Add mark_dependence [unresolved]
In preparation for inserting mark_dependence instructions for lifetime
dependencies early, immediately after SILGen. That will simplify the
implementation of borrowed arguments.

Marking them unresolved is needed to make OSSA verification
conservative until lifetime dependence diagnostics runs.
2024-02-08 22:53:16 -08:00
Augusto Noronha
c10991a369 Merge pull request #71428 from augusto2112/nfc-sbm
[NFC] Move MultiPayloadEnum spare bits mask calculation into a function
2024-02-08 22:19:07 -08:00
Arnold Schwaighofer
61326af56d Merge pull request #71414 from aschwaighofer/coro_noinline
IRGen: Mark async intrinsic helper functions as always inline
2024-02-08 12:46:03 -08:00
Alastair Houghton
2aba85f12f Merge pull request #71056 from al45tair/eng/PR-120952971
[Runtime][IRGen] Trap C++ exceptions on *throw*, not catch.
2024-02-08 15:00:35 +00:00
Augusto Noronha
9c6dfd4c03 [NFC] Move MultiPayloadEnum spare bits mask calculation into a function
In preparation to emit the spare bits mask of a MultiPayloadEnum into
DWARF debug info, move the calculation of it into its own function, so
it can be reused later on.
2024-02-07 16:48:39 -08:00
Nate Cook
e317febc9d Revert "Allow normal function results of @yield_once coroutines (#69843)"
This reverts commit aa5b505014.
2024-02-07 14:57:31 -06:00
Dario Rexin
747cbfcc24 [IRGen] Mask extra tag bits in getEnumTag function for CVW (#71421)
rdar://121868127

In compact value witnesses we need to mask the extra tag bits in case they are used to store tag bits of outer enums, so we only read the ones we are interested in.
2024-02-07 08:58:07 -08:00
Anton Korobeynikov
aa5b505014 Allow normal function results of @yield_once coroutines (#69843)
This adds SIL-level support and LLVM codegen for normal results of a coroutine.

The main user of this will be autodiff as VJP of a coroutine must be a coroutine itself (in order to produce the yielded result) and return a pullback closure as a normal result.

For now only direct results are supported, but this seems to be enough for autodiff purposes.
2024-02-06 22:13:15 -08:00
nate-chandler
01bce39100 Merge pull request #71418 from nate-chandler/nfc/20240206/1/rename-inst-class
[NFC] SIL: Renamed SpecifyTestInst.
2024-02-06 22:02:05 -08:00
Augusto Noronha
dc959a4eb4 Merge pull request #71332 from augusto2112/emit-class-deb
Generate full debug info for special builtins and classes
2024-02-06 17:08:33 -08:00
Nate Chandler
b535725647 [NFC] SIL: Renamed SpecifyTestInst.
The instruction's spelling was changed to `specify_test` but the class
name wasn't updated from `TestSpecificationInst`.  Update it here.
2024-02-06 16:29:09 -08:00
Ellie Shin
e38bc9756c Merge pull request #71083 from apple/es-sil-pkg
Support a package SILLinkage
2024-02-07 09:10:13 +09:00
Arnold Schwaighofer
bc81d23102 IRGen: Mark async intrinsic helper functions as always inline
github.com/apple/swift/issues/68708
rdar://115905828
2024-02-06 11:09:06 -08:00
Alastair Houghton
76f2389fd9 [IRGen][Test] Use the new availability support.
We need to only generate references to `_swift_exceptionPersonality`
if we're building for a new enough runtime.  The previous code was
good on Darwin, but would have resulted in build problems on Linux.

rdar://120952971
2024-02-06 16:21:11 +00:00
Alastair Houghton
143a473aa4 [Runtime][IRGen] Trap C++ exceptions on *throw*, not catch.
The previous approach was effectively to catch the exception and then
run a trap instruction.  That has the unfortunate feature that we end
up with a crash at the catch site, not at the throw site, which leaves
us with very little information about which exception was thrown or
where from.

(Strictly we do have the exception pointer and could obtain exception
information, but it still won't tell us what threw it.)

Instead of that, set a personality function for Swift functions that
call potentially throwing code, and have that personality function
trap the exception during phase 1 (i.e. *before* the original stack
has been unwound).

rdar://120952971
2024-02-06 16:19:17 +00:00
Kavon Farvardin
ee12fd6655 NCGenerics: reenable round-trip for mangling 2024-02-06 08:15:26 -08:00
Slava Pestov
d46bd335de Merge pull request #71371 from slavapestov/ncgenerics-fixes-3
Non-copyable generics fixes, part 3
2024-02-06 08:35:07 -05:00
Ellie Shin
72a7760027 Support package SIL linkage.
Decls with a package access level are currently set to public SIL
linkages. This limits the ability to have more fine-grained control
and optimize around resilience and serialization.
This PR introduces a separate SIL linkage and FormalLinkage for
package decls, pipes them down to IRGen, and updates linkage checks
at call sites to include package linkage.

Resolves rdar://121409846
2024-02-06 01:23:14 -08:00
Augusto Noronha
3352e7d157 [DebugInfo] Generate full debug info for classes 2024-02-05 16:44:44 -08:00
Slava Pestov
af50d7e6b8 AST: Add allowInverses flag to AbstractGenericSignatureRequest 2024-02-05 18:43:06 -05:00
Slava Pestov
b333fb1683 IRGen: isDependentConformance() can skip protocols without witness tables 2024-02-05 18:43:06 -05:00
Slava Pestov
0f30686cf0 IRGen: Rewrite isSpecializedNominalTypeMetadataStaticallyAddressable()
The old logic looked at each generic parameter, and each conformance
of that generic parameter. This missed conformance requirements where
the subject type is a dependent member type.

Also, the check for dependent witness tables was too strict, because
it should have skipped protocols without witness tables.

Refactor everything to instead walk the substitution map directly,
and check each replacement type and conformance. This simplifies
the logic and fixes failures with non-copyable generics enabled.
2024-02-05 18:43:05 -05:00
Erik Eckstein
4c3722352e IRGen: don't use value witness functions in outlined value operations for functions with performance constraints 2024-02-05 12:37:08 +01:00
Erik Eckstein
fcd5225f39 Mangling: add mangling for outlined value operations which must not use value witness functions 2024-02-05 12:33:18 +01:00
Augusto Noronha
2084da1163 Emit the special stdlib builtin types into full dwarf metadata 2024-02-02 18:15:31 -08:00
Alastair Houghton
4c7822cdac Merge pull request #71213 from al45tair/eng/PR-121522431
[Frontend][AST][IRGen] Improve availability support.
2024-02-02 22:30:19 +00:00
Augusto Noronha
ada2e40efc Merge pull request #71249 from augusto2112/special-builtins
[NFC] Separate special builtin types into a lazily initialized vector
2024-02-02 11:03:19 -08:00
Guillaume Lessard
114f235d17 Merge pull request #71167 from vanvoorden/vanvoorden/inclusive-language
[Inclusive Language][Comments][Documentation] migrate "sanity" checks to "soundness" checks
2024-02-02 10:27:34 -08:00
Alastair Houghton
c226bf3c3c [AST][IRGen] Add -min-runtime-version option and IRGen support code.
Add a `-min-runtime-version` option that can be used to avoid problems
when building on Linux and Windows where because the runtime isn't
part of the OS, availability doesn't solve the problem of trying to
build the compiler against an older runtime.

Also add functions to IRGen to make it easy to test feature
availability using both the runtime version and the existing Darwin
availability support.

rdar://121522431
2024-02-02 16:17:08 +00:00
Allan Shortlidge
cd122d2075 NFC: Suppress a -Wunreachable-code-loop-increment warning. 2024-02-01 18:16:05 -08:00
Augusto Noronha
91ed1a076a [NFC] Separate special builtin types into a lazily initialized vector
In preparation for future patches where debug info generation will need
to access the special builtin types, lazily emit them into a separate
lazily initialized vector.
2024-02-01 17:22:12 -08:00
Slava Pestov
80205ecf9c Merge pull request #71241 from slavapestov/ncgenerics-fixes
Non-copyable generics fixes
2024-02-01 07:18:29 -05:00
Slava Pestov
af3ab14986 SILGen: Clean up substitution map construction to deal with Copyable 2024-01-31 21:55:52 -05:00
Nate Chandler
5330633993 [BitwiseCopyable] Fixed TypeInfo flags.
Although a concrete type that is bitwise copyable is bitwise takable and
trivially destroyable, neither is true for a conforming archetype in the
relevant sense.
2024-01-31 14:53:40 -08:00
Cyndy Ishida
7e5f39312d [TBDGen] update usages of MachO::SymbolKind -> MachO::EncodeKind, NFC (#71247) 2024-01-31 07:45:07 -08:00
Arnold Schwaighofer
701549fe6e Merge pull request #71215 from aschwaighofer/large_loadable_reg2mem
Large loadable types peepholes and address assignment
2024-01-30 10:41:20 -08:00
Konrad `ktoso` Malawski
4d5324560f Fix some warnings in GenDistributed.cpp (#71235) 2024-01-29 22:41:52 -08:00
Arnold Schwaighofer
5e2144bdb8 Large loadable types peepholes and address assignment
Contract some load store patterns and assign addresses to (non-address)
SIL SSA values.

rdar://115571407
2024-01-29 17:10:46 -08:00