Commit Graph

1892 Commits

Author SHA1 Message Date
Kavon Farvardin
29acda5136 Merge pull request #69406 from kavon/noncopyable-generics-pt2
[NoncopyableGenerics] handle `~Copyable` in `where`, `some`, and compositions.
2023-10-28 22:36:22 -07:00
Allan Shortlidge
66abd325f9 Merge pull request #69456 from tshortli/serialization-lazy-typecheck-custom-attr
Serialization: Resolve type of CustomAttr before serializing
2023-10-27 14:29:19 -07:00
Meghana Gupta
3c244c30b0 Merge pull request #69436 from apple/revert-69416-revert-69254-dwarf-version
Revert "Revert "Make the DWARF version emitted by the Swift compiler configurable.""
2023-10-27 13:38:48 -07:00
Allan Shortlidge
33edb6642d Serialization: Resolve type of CustomAttr before serializing.
This fixing a crash during serialization when lazy typechecking is enabled.

Resolves rdar://117442955
2023-10-26 22:46:58 -07:00
Sophia Poirier
4c9a726183 nonisolated(unsafe) to opt out of strict concurrency static checking for global variables 2023-10-26 16:22:28 -07:00
Adrian Prantl
5d978b44ca Revert "Revert "Make the DWARF version emitted by the Swift compiler configurable."" 2023-10-26 12:29:18 -07:00
Adrian Prantl
2a32ca5944 Revert "Make the DWARF version emitted by the Swift compiler configurable." 2023-10-25 13:28:28 -07:00
Adrian Prantl
d19fe381fa Use LLVM definitions for Swift section names (NFC) 2023-10-24 10:58:40 -07:00
Yuta Saito
4f0e3bf3ea Merge pull request #69207 from kateinoigakukun/yt/cdecl-without-body
Introduce `@extern(c)` to declare C function without Clang module
2023-10-23 12:48:12 -07:00
Kavon Farvardin
66712ce6e0 [Sema] introduce InverseType
This type will become the corresponding type that is resolved for an
`InverseTypeRepr`. This kind of type is not expected to appear past type
 checking (currently, not even past requirement lowering!).
2023-10-23 10:37:22 -07:00
Yuta Saito
b27fd9a616 [c-interop] Add @_extern(c) attribute to declare C function in Swift 2023-10-20 15:34:08 +00:00
Evan Wilde
312bd47f4c Merge remote-tracking branch 'main' into 'rebranch' 2023-10-16 23:00:12 -07:00
Mishal Shah
3594f8ecaf Merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
	test/IRGen/opaque-pointer-llvm.swift
2023-10-15 23:49:40 -07:00
Becca Royal-Gordon
5c8bcfdf52 [NFC] Correct AFD::needsNewVTableEntry()
Serialization depended on a longstanding bug in NeedsNewVTableEntryRequest: For a member of a non-class, it always returned `true`, not `false`. It turns out this was because serialization was conflating the concepts of vtable entries and witness table entries, so it needed NeedsNewVTableEntryRequest to return true for members of protocols. Untangle this logic so that NeedsNewVTableEntryRequest can be given the logical behavior.
2023-10-13 14:33:44 -07:00
Artem Chikin
6a699b61b1 Merge pull request #69109 from artemcm/EBM_BridgingHeader_Fix
[Explicit Module Builds] Restore prior behavior of consuming `.h` dependencies of binary module dependencies directly, instead of attempting to load their PCH
2023-10-13 09:04:37 -07:00
swift-ci
d432ad3f51 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-12 10:54:41 -07:00
Allan Shortlidge
229398c01d Merge pull request #69141 from tshortli/silgen-lazy-typecheck
SILGen: Introduce option to skip non-exportable declarations
2023-10-12 10:49:06 -07:00
swift-ci
13417f9331 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-12 09:35:04 -07:00
Yuta Saito
051bf4dd43 Merge pull request #69107 from kateinoigakukun/yt/extern-wasm-sym
[wasm] Add @_extern(wasm) attribute support
2023-10-12 09:29:13 -07:00
Artem Chikin
75ee48ca77 [Dependency Scanning] Do now write out bridging header dependencies of binary modules unless in CAS mode
We only record these dependencies in CAS mode, because we require explicit PCH tasks to be produced for imported header of binary module dependencies. In the meantime, in non-CAS mode loading clients will consume the `.h` files encoded in the `.swiftmodules` directly.

Followup changes to SwiftDriver will enable explicit PCH compilation of such dependenceis, but for the time being restore prior behavior for non-CAS explicit module builds.

Resolves rdar://116006619
2023-10-12 06:24:11 -07:00
Allan Shortlidge
a7daf13bf6 AST: Introduce and adopt Decl::isExposedToClients().
This method is a more ergonomic utility wrapping DeclExportabilityVisitor.
2023-10-11 22:41:31 -07:00
swift-ci
bfc9d85449 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-11 18:14:16 -07:00
Slava Pestov
a3fa3bf110 Merge pull request #69038 from slavapestov/clean-up-associated-conformances
Preparation for lazily populating associated conformances
2023-10-11 20:58:27 -04:00
Artem Chikin
3bb5424296 [Serialization] Serialize source '.h' path when an explicit '.pch' bridging header is provided
In explicit module builds, bridging header is passed directly as a '.pch' input.

Loading clients may not be able to directly import this PCH because it was built against mis-matched dependencies with a different context hash. So instead they should directly injest the '.h' depndency and build it against their own set of dependencies.
2023-10-11 13:15:12 -07:00
Slava Pestov
793c7a18e2 Serialization: Use forEachAssociatedConformance() 2023-10-11 15:04:09 -04:00
swift-ci
d967b1878a Merge remote-tracking branch 'origin/main' into rebranch 2023-10-10 20:08:25 -07:00
Allan Shortlidge
f131c8a3f5 Frontend: Introduce -experimental-skip-non-exportable-decls.
Rename -experimental-serialize-external-decls only to
-experimental-skip-non-exportable-decls in preparation for the flag being used
to influence more than just serialization.

Resolves rdar://116771543
2023-10-10 16:07:04 -07:00
Yuta Saito
bd898b0e7e [wasm] add @_extern(wasm) attribute support
This attribute instructs the compiler that this function declaration
should be "import"ed from host environment. It's equivalent of Clang's
`__attribute__((import_module("module"), import_name("field")))`
2023-10-10 22:42:08 +00:00
swift-ci
1ba3021ab0 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-04 20:25:08 -07:00
Holly Borla
3cb9bb89bc [Concurrency] Serialize default argument isolation. 2023-10-04 13:12:11 -07:00
swift-ci
06f9a8a703 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-30 11:33:40 -07:00
Doug Gregor
51eed19d4b [Typed throws] Type system support for typed throws.
Add the thrown type into the AST representation of function types,
mapping from function type representations and declarations into the
appropriate thrown type. Add tests for serialization, printing, and
basic equivalence of function types that have thrown errors.
2023-09-29 10:51:53 -07:00
Doug Gregor
ef642098f2 [Typed throws] Parsing and AST representation for typed errors
Parse typed throw specifiers as `throws(X)` in every place where there
are effects specified, and record the resulting thrown error type in
the AST except the type system. This includes:
* `FunctionTypeRepr`, for the parsed representation of types
* `AbstractFunctionDecl`, for various function-like declarations
* `ClosureExpr`, for closures
* `ArrowExpr`, for parsing of types within expression context

This also introduces some serialization logic for the thrown error
type of function-like declarations, along with an API to extract the
thrown interface type from one of those declarations, although right
now it will either be `Error` or empty.
2023-09-29 10:51:51 -07:00
swift-ci
ddbe38ec7b Merge remote-tracking branch 'origin/main' into rebranch 2023-09-28 09:38:05 -07:00
Yuta Saito
6d378a3ec3 [wasm] add @_expose(wasm) attribute support
This attribute instructs the compiler that this function declaration
should be "export"ed from this .wasm module. It's equivalent of Clang's
`__attribute__((export_name("name")))`
2023-09-26 14:13:33 +00:00
swift-ci
1b6470ca9c Merge remote-tracking branch 'origin/main' into rebranch 2023-09-20 15:07:15 -07:00
Yuta Saito
c5314bd3af Centralize KeyPath accessor calling convention logic to IRGen
KeyPath's getter/setter/hash/equals functions have their own calling
convention, which receives generic arguments and embedded indices from a
given KeyPath argument buffer.
The convention was previously implemented by:
1. Accepting an argument buffer as an UnsafeRawPointer and casting it to
   indices tuple pointer in SIL.
2. Bind generic arguments info from the given argument buffer while emitting
   prologue in IRGen by creating a new forwarding thunk.

This 2-phase lowering approach was not ideal, as it blocked KeyPath
projection optimization [^1], and also required having a target arch
specific signature lowering logic in SIL-level [^2].

This patch centralizes the KeyPath accessor calling convention logic to
IRGen, by introducing `@convention(keypath_accessor_XXX)` convention in
SIL and lowering it in IRGen. This change unblocks the KeyPath projection
optimization while capturing subscript indices, and also makes it easier
to support WebAssembly target.

[^1]: https://github.com/apple/swift/pull/28799
[^2]: https://forums.swift.org/t/wasm-support/16087/21
2023-09-20 11:25:39 -07:00
swift-ci
89b27b5068 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-18 14:53:34 -07:00
swift-ci
d9a7c563cb Merge remote-tracking branch 'origin/main' into rebranch 2023-09-16 00:14:50 -07:00
Allan Shortlidge
497034ef64 AST: Requestify generic signature building for @_specialized attributes.
In order to support lazy typechecking during module emission for modules
containing specialized functions, the computation of generic signatures for
`@_specialized` attributes must be requestified.

Resolves rdar://115569606
2023-09-16 00:02:33 -07:00
Allan Shortlidge
82923d580d AST: Expose DeclExportabilityVisitor.
Extract `ExternallyAccessibleDeclVisitor` from `Serialization.cpp` into its own
header and rename it to `DeclExportabilityVisitor` to better align with
terminology in other parts of the compiler. Ideally, `DeclExportabilityVisitor`
should become the canoncial implementation of for exportability checks,
consolidating logic that is currently spread between serialization, module
interface printing, TBDGen, and type checking. For now, it is only used in
serialization to implement serialization safety checks.
2023-09-15 17:15:48 -07:00
Allan Shortlidge
1cec6a454f Serialization: Handle precedence groups and operators in ExternallyAccessibleDeclVisitor. 2023-09-14 18:11:03 -07:00
Allan Shortlidge
061578c1a8 Serialization: Handle IfConfigDecls in ExternallyAccessibleDeclVisitor. 2023-09-14 18:09:49 -07:00
Allan Shortlidge
4522963cf7 Serialization: Handle enum cases in ExternallyAccessibleDeclVisitor. 2023-09-14 17:59:17 -07:00
Allan Shortlidge
ee479fe21b Serialization: Use a DeclVisitor to implement deserialization safety.
Refactor deserialization safety to use a `DeclVisitor` CRTP instead of ad-hoc
casts. This ensures every kind of decl is handled explicitly.

Resolves rdar://115456536
2023-09-14 17:59:17 -07:00
swift-ci
151376e094 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-12 16:17:58 -07:00
Allan Shortlidge
9b641f9ba3 ModuleInterface: Typecheck PatternBindingDecls lazily before printing.
Previously, fully qualified types would be missing for global vars and
properties in `.swiftinterface` files that were emitted lazily.

Adding the test case also revealed that PatternBindingDecls needed to be
typechecked before lazy module serialization as well.
2023-09-12 09:08:10 -07:00
swift-ci
b73bfe4686 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-07 21:14:44 -07:00
Allan Shortlidge
7c1b150f39 ModuleInterface: Resolve inherited types when computing unsatisfiable conformances.
Previously, unsatisfiable conformances could be omitted from emitted
`.swiftinterface` files in lazy typechecking mode since inherited types might
be unresolved when gathering the conformances.

Adding these test cases also revealed that serialization restrictions needed to
be relaxed in order to accomodate unsatisfiable conformances.
2023-09-07 13:57:39 -07:00
swift-ci
5bb21c1303 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-07 01:14:42 -07:00