Commit Graph

2133 Commits

Author SHA1 Message Date
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
c43f87101f Merge branch 'main' into rebranch
Conflicts:
      lib/Basic/Platform.cpp

```
diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp
index 240edfa144a..1797c87635f 100644
--- a/lib/Basic/Platform.cpp
+++ b/lib/Basic/Platform.cpp
@@ -200,10 +200,7 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
   case llvm::Triple::CUDA:
   case llvm::Triple::DragonFly:
   case llvm::Triple::DriverKit:
-<<<<<<< HEAD
   case llvm::Triple::ELFIAMCU:
-=======
->>>>>>> main
   case llvm::Triple::Emscripten:
   case llvm::Triple::Fuchsia:
   case llvm::Triple::HermitCore:
```
2024-04-17 13:32: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
Steven Wu
7a68d364f4 [Caching] Embed bridging header in binary module correctly when caching
When caching is enabled with include-tree, the bridging header PCH is
created from the include tree directly. Setup the rewriter correctly
when embedding the bridging header into swift binary module.

rdar://125719747
2024-04-15 14:46:38 -07:00
swift-ci
5b6eadf416 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-12 13:37:42 -07:00
Meghana Gupta
e60e43cac1 Serialize inferred lifetime dependence info as well 2024-04-08 15:15:47 -07:00
Ben Barham
cacfd3e3ae Rename llvm::support::endianness to llvm::endianness
LLVM is gearing up to move to `std::endianness` and as part of that has
moved `llvm::support::endianness` to `llvm::endianness`
(bbdbcd83e6702f314d147a680247058a899ba261). Rename our uses.
2024-04-08 08:58:58 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Alex Lorenz
bdc3717834 Merge pull request #72643 from hyp/eng/cxx-interop/xrefcts
[cxx-interop] serialize x-refs for class template specializations
2024-04-01 08:08:25 -07:00
Alex Lorenz
0c7b1cee13 [cxx-interop] serialize x-refs for class template specializations
Fixes https://github.com/apple/swift/issues/70253
2024-03-29 10:08:18 -07: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
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
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
Ben Barham
9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00
Konrad `ktoso` Malawski
8854438d87 [Distributed] Remove _distributedThunkTarget; it is not necessary (#72245) 2024-03-11 20:48:05 -07: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
1d76a1fa56 [Serialization] Bump number of bits for decl/type block id to 9 2024-02-28 17:57:31 -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
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -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
Joe Groff
a0810ec93a Merge pull request #71684 from jckarter/value-ownership-abi-fix
Fix ABI breakage caused by `ValueOwnership` order change.
2024-02-20 11:17:55 -08:00
Allan Shortlidge
62d5f6f917 Merge pull request #71739 from tshortli/module-serialization-remarks
Serialization: Skip invalid decls during module serialization
2024-02-20 10:44:33 -08:00
Joe Groff
b9f91144d1 Fix ABI breakage caused by ValueOwnership order change.
The `ABI` headers had accidentally grown an `#include` into compiler headers,
allowing the enum constant values of the `ValueOwnership` enum to leak into
the runtime ABI. Sever this inappropriate relationship by declaring a separate
`ParameterOwnership` enum with ABI-stable values in the ABI headers, and
explicitly converting between the AST and ABI representation where needed.
Fixes rdar://122435628.
2024-02-20 07:55:16 -08:00
Allan Shortlidge
b46d179d46 Serialization: Skip patterns with invalid types.
Prevents a crash during module emission with `-enable-lazy-typechecking` when
the type of a `Pattern` cannot be resolved.
2024-02-19 20:52:17 -08:00
Allan Shortlidge
65ea9c8313 Serialization: Skip custom attributes with invalid types.
Prevents a crash during module emission with `-enable-lazy-typechecking` when
the type corresponding to a `CustomAttr` cannot be resolved.
2024-02-19 20:52:17 -08:00
Allan Shortlidge
72da8f4e9c Serialization: Skip invalid decls during module serialization.
When `-enable-lazy-typecheck` is specified, serialization may be expected to
run on an AST containing invalid declarations since type checking may happen
on-demand, during serialization, in this mode. If the declarations that are
invalid are not skipped, then the compiler is likely to crash when attempting
to serialize them. Now, invalid declarations are skipped and an error is
emitted at the end of serialization to note that serialization failed.

Additionally, a new `-Rmodule-serialization` flag can be specified to request
more detailed information about module serialization failures. This would be
useful in a situation where lazy typechecking does not produce any diagnostic
for some reason, but module serialization fails and more information is
therefore required to debug.

Resolves rdar://123260476
2024-02-19 20:52:17 -08:00
Michael Gottesman
61de03ca0f Remove clang optimize off that snuck into tree. 2024-02-17 21:27:33 -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
Doug Gregor
81ffafdc6a Merge pull request #70602 from ApolloZhu/macro/expression-as-default-argument
[Macros] Expression macro as caller-side default argument
2024-02-14 16:10:11 -08:00
Michael Gottesman
f3edb5730a [transferring] Add support for transferring results.
rdar://121324697
2024-02-14 14:39:02 -08:00
Michael Gottesman
bf2ec7eb85 [transferring] Change transferring to no longer be a ParamSpecifier.
Instead it is a bit on ParamDecl and SILParameterInfo. I preserve the consuming
behavior by making it so that the type checker changes the ParamSpecifier to
ImplicitlyCopyableConsuming if we have a default param specifier and
transferring is set. NOTE: The user can never write ImplicitlyCopyableConsuming.

NOTE: I had to expand the amount of flags that can be stored in ParamDecl so I
stole bits from TypeRepr and added some logic for packing option bits into
TyRepr and DefaultValue.

rdar://121324715
2024-02-14 13:04:46 -08:00
Michael Gottesman
1f0527d47f [ast] Rename ParamSpecifier::{Transferring,ImplicitlyCopyableConsuming}.
The reason why I am doing this is that I am going to be changing transferring to
not be a true ParamSpecifier. Instead, it is going to be a bit on Param that
changes the default ParamSpecifier used. That being said, I cannot use consuming
for this purpose since consuming today implies no implicit copy semantics, which
we do not want unless the user specifically asks for it by writing consuming.
2024-02-14 13:04:21 -08:00
John McCall
d5142668f4 SIL and IRGen support for @isolated(any). SILGen to come. 2024-02-13 03:04:13 -05:00
Andrew Trick
8b24382494 SwiftCompilerSources: cleanup and extend ArgumentConventions
Provide APIs needed by lifetime dependence diagnostics, namely LifetimeDependenceConvention.

Reorganize the APIs so it's easy to find related functionality which
API is responsible for which functionality.

Remove the originalFunctionConvention complexity. It is no longer
needed for lifetime dependence inference, and generally should be
avoided in SIL.

Add some placeholder FIXMEs because this not a good PR in which to
change existing functionality.
2024-02-12 09:57:14 -08:00
Meghana Gupta
a66b7b6335 Don't represent mutate lifetime dependence separately 2024-02-08 14:05:01 -08:00
John McCall
2f8a33cf0a Experimental type-checking support for @isolated(any) function types. 2024-02-06 22:54:27 -05:00
Apollo Zhu
b09a22a9a0 Somewhat working
Test shadowed variable of same type

Fully type check caller side macro expansion

Skip macro default arg caller side expr at decl primary

Test macro expand more complex expressions

Set synthesized expression as implicit

Add test case for with argument, not compiling currently

Test with swiftinterface

Always use the string representation of the default argument

Now works across module boundary

Check works for multiple files

Make default argument expression work in single file

Use expected-error

Disallow expression macro as default argument

Using as a sub expression in default argument still allowed as expression macros behave the same as built-in magic literals
2024-02-06 15:02:11 -08:00
Andrew Trick
e738b8a77e Merge pull request #71353 from meg-gupta/initlifetimedep
Support for lifetime dependence specifiers on initializers
2024-02-05 08:55:54 -08:00
Meghana Gupta
0835d00972 Add serialization/deserialization support to lifetime depedence on initializers 2024-02-02 11:50:14 -08:00
Rintaro Ishizaki
92e70ef80a [AST] Remove DeclAttrKind::Count
Introduce NumDeclAttrKinds for number of enum values. Use optional for
invalid attribute kind. This align with `TypeAttrKind`.
2024-02-02 09:36:49 -08:00
Rintaro Ishizaki
8fdc4cc225 [AST] Split Attr.def to DeclAttr.def and TypeAttr.def 2024-02-02 09:36:49 -08:00