Commit Graph

668 Commits

Author SHA1 Message Date
Alexis Laferrière
b9b71b552d Serialization: bump the format version by one to avoid conflicts with other branches 2024-08-15 10:20:37 -07:00
Ben Barham
273d7ee79d [Serialization] Do not serialize unstable hashes
https://github.com/llvm/llvm-project/pull/96282 changed
`get_execution_seed` to be non-deterministic. Use stable hashes instead.
2024-08-13 19:51:35 -07:00
Egor Zhdan
059f0f97d1 [cxx-interop] Allow compiling with libc++ on Linux
This makes sure that Swift respects `-Xcc -stdlib=libc++` flags.

Clang already has existing logic to discover the system-wide libc++ installation on Linux. We rely on that logic here.

Importing a Swift module that was built with a different C++ stdlib is not supported and emits an error.

The Cxx module can be imported when compiling with any C++ stdlib. The synthesized conformances, e.g. to CxxRandomAccessCollection also work. However, CxxStdlib currently cannot be imported when compiling with libc++, since on Linux it refers to symbols from libstdc++ which have different mangled names in libc++.

rdar://118357548 / https://github.com/swiftlang/swift/issues/69825
2024-08-08 16:24:58 +01:00
Meghana Gupta
154989463b Add support for lifetime dependence in parameter position 2024-07-10 14:20:03 -07:00
nate-chandler
04debd3536 Merge pull request #74922 from nate-chandler/lifetime-completion/20240701/1
[LifetimeCompletion] Flag ends synthesized in dead-ends.
2024-07-04 00:23:57 -07:00
Nate Chandler
b150a484f2 [SIL] Add dead_end flag to dealloc_box. 2024-07-03 15:26:59 -07:00
Nate Chandler
a8cc3bfdda [SIL] Add dead_end flag to destroy_value. 2024-07-03 15:26:59 -07:00
Michael Gottesman
34195ff213 Merge pull request #74610 from gottesmm/pr-324fd70c13e87a329334341aae4667f2d1be152c
[sending] Remove transferring.
2024-07-02 14:02:18 -07:00
Akira Hatanaka
42bc49d3fe Add a new parameter convention @in_cxx for non-trivial C++ classes that are passed indirectly and destructed by the caller (#73019)
This corresponds to the parameter-passing convention of the Itanium C++
ABI, in which the argument is passed indirectly and possibly modified,
but not destroyed, by the callee.

@in_cxx is handled the same way as @in in callers and @in_guaranteed in
callees. OwnershipModelEliminator emits the call to destroy_addr that is
needed to destroy the argument in the caller.

rdar://122707697
2024-06-27 09:44:04 -07:00
Michael Gottesman
112071e57d [sending] Remove transferring.
Out of an abundance of caution, we:

1. Left in parsing support for transferring but internally made it rely on the
internals of sending.

2. Added a warning to tell people that transferring was going to
be removed very soon.

Now that we have given people some time, remove support for parsing
transferring.

rdar://130253724
2024-06-21 16:03:21 -07:00
Meghana Gupta
c14559173d Add dependsOn(immortal) 2024-06-11 11:18:10 -07:00
Meghana Gupta
af1d6017f9 Merge pull request #74132 from meg-gupta/deleteresultdependson
Remove resultDependsOn/resultDependsOnSelf
2024-06-06 10:23:31 -07:00
Nate Chandler
2a5d07522d [SIL] Add extend_lifetime instruction.
It indicates that the value's lifetime continues to at least this point.
The boundary formed by all consuming uses together with these
instructions will encompass all uses of the value.
2024-06-05 16:28:26 -07:00
Meghana Gupta
470fa2f365 Remove resultDependsOn/resultDependsOnSelf 2024-06-05 11:36:16 -07:00
Alexis Laferrière
ab6a7017d0 Merge branch 'main' into serial-fix-control-block 2024-06-05 10:46:49 -07:00
Alejandro Alonso
324cb2df1f Merge pull request #73955 from Azoy/show-me-those-moves
[IRGen] Add option for raw layout to move as its like type
2024-05-30 20:32:49 -07:00
Alejandro Alonso
a9da08ccb6 Add option for raw layout to move as its like type 2024-05-28 14:34:22 -07:00
Ellie Shin
5ccc4cd394 SIL function can be serialized with different kinds: [serialized] or
[serialized_for_package] if Package CMO is enabled. The latter kind
allows a function to be serialized even if it contains loadable types,
if Package CMO is enabled. Renamed IsSerialized_t as SerializedKind_t.

The tri-state serialization kind requires validating inlinability
depending on the serialization kinds of callee vs caller; e.g. if the
callee is [serialized_for_package], the caller must be _not_ [serialized].
Renamed `hasValidLinkageForFragileInline` as `canBeInlinedIntoCaller`
that takes in its caller's SerializedKind as an argument. Another argument
`assumeFragileCaller` is also added to ensure that the calle sites of
this function know the caller is serialized unless it's called for SIL
inlining optimization passes.

The [serialized_for_package] attribute is allowed for SIL function, global var,
v-table, and witness-table.

Resolves rdar://128406520
2024-05-23 15:53:02 -07:00
Alexis Laferrière
998a40aed2 Serialization: Move SDK version to the end of the control block enum 2024-05-22 14:47:44 -07:00
Alexis Laferrière
76e7fa9372 Serialization: Move the distribution channel to the end of the control block enum 2024-05-22 14:47:44 -07:00
Michael Gottesman
d759ec97ea Merge pull request #73696 from gottesmm/rdar128216574
[sending] Add support for 'sending'
2024-05-18 05:42:41 -04:00
Michael Gottesman
e3e78ad6bb [sending] Change the internals of sending to be based around 'sending' instead of 'transferring'.
We still only parse transferring... but this sets us up for adding the new
'sending' syntax by first validating that this internal change does not mess up
the current transferring impl since we want both to keep working for now.

rdar://128216574
2024-05-16 12:20:45 -07:00
Alexis Laferrière
074df70248 Serialization: Write the target SDK in the binary swiftmodule 2024-05-16 11:52:36 -07:00
Ellie Shin
2d81d0f2c7 [SIL] Add a new attribute [serialized_for_package] to support
package-wide resilience domain if Package CMO is enabled.

The purpose of the attribute includes:
- Indicates that certain types such as loadable types are
allowed in serialized functions in resiliently built module
if the optimization is enabled, which are otherwise disallowed.
- Used during SIL deserialization to determine whether such
functions are allowed.
- Used to determine if a callee can be inlined into a caller
that's serialized without package-cmo, e.g. with an explicit
annotation like @inlinable, where the callee was serialized
due to package-cmo.

Resolves rdar://127870822
2024-05-15 12:43:15 -07:00
Ellie Shin
0c0d8c0316 Merge branch 'main' into elsh/pkg-sil-verify 2024-04-18 13:34:29 -07:00
Ellie Shin
45e8454a9e Merge branch 'main' into elsh/pkg-sil-verify 2024-04-17 22:46:55 -07:00
Ellie Shin
fbb3382e21 During Package CMO, SIL cloning happens during which
SILOptions::EnableSerializePackage info is lost.

SILVerifier needs this info to determine whether resilience
can be bypassed for decls serialized in a resiliently
built module when Package CMO optimization enabled.

This PR adds SerializePackageEnabled bit to Module format
and uses that in SILVerifier.

Resolves rdar://126157356
2024-04-17 22:37:48 -07:00
Nate Chandler
ba467d2bd2 [Sema] Enable suppression of inferred conformances.
Add the machinery to support suppression of inference of conformance to
protocols that would otherwise be derived automatically.

This commit does not enable any conformances to be suppressed.
2024-04-15 16:46:22 -07:00
Erik Eckstein
ac4bc89c9a SIL: add the borrowed-from instruction.
It declares from which enclosing values a guaranteed phi argument is borrowed from.
2024-04-10 13:38:10 +02:00
Becca Royal-Gordon
8fc46fece8 [NFC] Add flag distinguishing @impl and @objcImpl
They will have slightly different enablement and diagnostic behavior in a future commit.
2024-03-27 14:29:56 -07:00
Anton Korobeynikov
d84847ac9d Reland Allow normal function results of @yield_once coroutines (#71645)
* Allow normal function results of @yield_once coroutines

* Address review comments

* Workaround LLVM coroutine codegen problem: it assumes that unwind path never returns.
This is not true to Swift coroutines as unwind path should end with error result.
2024-03-27 13:09:02 -07:00
Allan Shortlidge
5068579261 Serialization: Remove serialization support for @_allowFeatureSuppression.
It isn't used since the attribute doesn't get serialized.
2024-03-26 16:59:43 -07:00
Konrad `ktoso` Malawski
6132386371 [Distributed] Complete handling of protocol calls and witnesses using adjusted mangling scheme (#72416) 2024-03-23 23:54:23 +09:00
Slava Pestov
e3d434fbbe Serialization: Serialize ProtocolDecl::getSuperclassDecl() instead of ProtocolDecl::getSuperclass()
Protocols with a superclass bound written as `protocol P where Self: C`
return null from getSuperclass(). Unqualified lookup only cares about
getSuperclassDecl(), so serialize that instead.

Fixes rdar://problem/124478687.
2024-03-21 13:09:21 -04:00
Kavon Farvardin
149c052ec5 use new noncopyable types infrastructure
The infrastructure underpinning the new feature NoncopyableGenerics is
mature enough to be used.
2024-03-14 23:10:44 -07:00
Konrad `ktoso` Malawski
8854438d87 [Distributed] Remove _distributedThunkTarget; it is not necessary (#72245) 2024-03-11 20:48:05 -07:00
Nate Chandler
3dbeebaa9b [SIL] Add var_decl flag to alloc_stack. 2024-03-08 22:28:22 -08:00
Michael Gottesman
622afad384 [transferring] Represent transferring at the SIL level on SILResultInfo rather than a bit on SILFunctionType.
We preserve the current semantics that we have today by requiring that either all SILResultInfo are transferring or none are transferring. This also let me swap to @sil_transferring representation.

I did both of these things to fix SIL issues around transferring.

It also ensures that we now properly emit
2024-03-07 19:44:39 -08:00
Meghana Gupta
eb84095c0d Serialize lifetime dependence info on function types as well 2024-03-05 16:20:52 -08:00
Ellie Shin
8ffd8efe2d Merge branch 'main' into es-check-exp 2024-03-02 14:55:17 -08:00
John McCall
1437acdf22 Implement conditional feature suppression.
Our standard conception of suppressible features assumes we should
always suppress the feature if the compiler doesn't support it.
This presumes that there's no harm in suppressing the feature, and
that's a fine assumption for features that are just adding information
or suppressing new diagnostics.  Features that are semantically
relevant, maybe even ABI-breaking, are not a good fit for this,
and so instead of reprinting the decl with the feature suppressed,
we just have to hide the decl entirely.  The missing middle here
is that it's sometimes useful to be able to adopt a type change
to an existing declaration, and we'd like older compilers to be
able to use the older version of the declaration.  Making a type
change this way is, of course, only really acceptable for
@_alwaysEmitIntoClient declarations; but those represent quite a
few declarations that we'd like to be able to refine the types of.

Rather than trying to come up with heuristics based on
@_alwaysEmitIntoClient or other sources of information, this design
just requires the declaration to opt in with a new attribute,
@_allowFeatureSuppress.  When a declaration opts in to suppression
for a conditionally-suppressible feature, the printer uses the
suppression serially-print-with-downgraded-options approach;
otherwise it uses the print-only-if-feature-is-available approach.
2024-03-01 22:10:14 -05:00
Ellie Shin
30669fca65 Currently when checking if resilience check can be bypassed within a package,
we only check if the loaded module is built from a package interface. This is
not enough as a binary module could just contain exportable decls if built with
experimental-skip-non-exportable-decls, essentially resulting in content equivalent
to interface content. This might be made a default behavior so this PR requires
a module to opt in to allow non-resilient access by a participating client in the
same package.

Since it affects module format, SWIFTMODULE_VERSION_MINOR is updated.

rdar://123651270
2024-03-01 15:13:58 -08:00
Alexis Laferrière
1e4fe67f40 Serialization: restrict swiftmodules to distribution channels
There are scenarios where different compilers are distributed with
compatible serialization format versions and the same tag. Distinguish
swiftmodules in such a case by assigning them to different distribution
channels. A compiler expecting a specific channel will only read
swiftmodules from the same channel. The channels should be defined by
downstream code as it is by definition vendor specific.

For development, a no-channel compiler loads or defining the env var
SWIFT_IGNORE_SWIFTMODULE_REVISION skips this new check.

rdar://123731777
2024-03-01 10:52:44 -08:00
Pavel Yaskevich
6b99c8151d [Serialization] ProtocolLayout: Serialize inherited protocols instead of types 2024-02-28 17:06:37 -08:00
Pavel Yaskevich
1df8ef7430 [Serialization] ProtocolLayout: Serialize superclass 2024-02-28 16:04:28 -08:00
Pavel Yaskevich
f9ec3b1d7e Merge pull request #71796 from xedin/make-dist-new-requirements-conditionally-available
[Distributed] Make new protocol requirements conditionally available
2024-02-22 15:18:52 -08:00
Pavel Yaskevich
65d164a9c3 Revert "[SIL] Distributed: Remove logic related to ad-hoc requirements from SILFunction"
This reverts commit 1909b12370.
2024-02-21 13:29:47 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Konrad `ktoso` Malawski
e9c7f3c382 [Distributed] Target identifiers for protocol calls (#70928) 2024-02-16 07:19:20 -08:00
Michael Gottesman
23ab974574 Merge pull request #71567 from gottesmm/transferring-param
[transferring] Implement transferring result and clean up transferring param support by making transferring a bit on param instead of a ParamSpecifier.
2024-02-14 17:54:48 -08:00