Commit Graph

680 Commits

Author SHA1 Message Date
Meghana Gupta
e61d87c01c Add support for parsing @lifetime attribute to specify lifetime dependencies on declarations 2024-09-09 22:02:42 -07:00
Alexis Laferrière
c70162c703 Merge branch 'main' into public-module-name 2024-09-05 20:02:07 -07:00
Alexis Laferrière
37521ad21d Serialization: Read and write support for public module name 2024-09-04 16:20:12 -07:00
Alejandro Alonso
46a4d56c2b Bring back the isOpaqueType parameter for deserialization 2024-09-04 15:13:49 -07:00
Alejandro Alonso
15db739055 Serialize IntegerType
Use BCBlob
2024-09-04 15:13:47 -07:00
Alejandro Alonso
e0f2b812e8 Add serialization and parser tests for SIL 2024-09-04 15:13:47 -07:00
Slava Pestov
b9b6bb7b69 AST: Introduce new kind of sugared GenericTypeParamType
This one just stores an identifier instead of a declaration.
2024-09-04 15:13:46 -07:00
Alejandro Alonso
f4f60f4344 Remove Value requirement Add GenericTypeParamKind 2024-09-04 15:13:43 -07:00
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Slava Pestov
e3ff6f0697 AST: Fiddle with GenericEnvironment::forOpenedExistential() again 2024-09-03 17:31:26 -04:00
Allan Shortlidge
789b795cec SILOptimizer: Allow inlining of transparent functions in @backDeployed thunks.
In order for availability checks in iOS apps to be evaluated correctly when
running on macOS, the application binary must call a copy of
`_stdlib_isOSVersionAtLeast_AEIC()` that was emitted into the app, instead of
calling the `_stdlib_isOSVersionAtLeast()` function provided by the standard
library. This is because the call to the underlying compiler-rt function
`__isPlatformVersionAtLeast()` must be given the correct platform identifier
argument; if the call is not emitted into the client, then the macOS platform
identifier is used and the iOS version number will be mistakenly interpreted as
a macOS version number at runtime.

The `_stdlib_isOSVersionAtLeast()` function in the standard library is marked
`@_transparent` on iOS so that its call to `_stdlib_isOSVersionAtLeast_AEIC()`
is always inlined into the client. This works for the code generated by normal
`if #available` checks, but for the `@backDeployed` function thunks, the calls
to `_stdlib_isOSVersionAtLeast()` were not being inlined and that was causing
calls to `@backDeployed` functions to crash in iOS apps running on macOS since
their availability checks were being misevaluated.

The SIL optimizer has a heuristic which inhibits mandatory inlining in
functions that are classified as thunks, in order to save code size. This
heuristic needs to be relaxed in `@backDeployed` thunks, so that mandatory
inlining of `_stdlib_isOSVersionAtLeast()` can behave as expected. The change
should be safe since the only `@_transparent` function a `@backDeployed` thunk
is ever expected to call is `_stdlib_isOSVersionAtLeast()`.

Resolves rdar://134793410.
2024-08-29 08:43:07 -07:00
Slava Pestov
5577f27661 AST: Opened existential environments store outer substitutions 2024-08-20 16:54:51 -04:00
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