Commit Graph

5047 Commits

Author SHA1 Message Date
Alexis Laferrière
fb3944f1b1 Serialization: Error on mismatch between requirements and confirmances
When deserialization a protocol conformance from a binary swiftmodule
file the compiler can encounter inconsistencies caused by stale module
files. Replace the hard crash with a proper error and print the list of
requirements and conformances being compared to stderr for manual
inspection. Recover silently when we can afford to, during indexing or
in LLDB.
2025-03-07 14:05:57 -08:00
Alexis Laferrière
ea5658eece Serialization: Protect readNormalProtocolConformanceXRef
Failures in `readNormalProtocolConformanceXRef` are usually caused by a
dependency change without the required rebuild of its dependents.
Display a proper error instead of crashing when encountering such an
issue during normal compilation. Recover silently when we can afford to,
during indexing or in LLDB.
2025-03-07 14:05:57 -08:00
Alexis Laferrière
e814b3f66c Serialization: Intro enableExtendedDeserializationRecovery
Introduce a new deserialization mode `enableExtendedDeserializationRecovery`
for use when we can afford inconsistent information from a swiftmodule
file. It's enabled automatically in debugger mode, when user errors are
allowed and during index-while-building.
2025-03-07 10:55:00 -08:00
Allan Shortlidge
b64df7384e AST: Simplify AvailabilityRange construction.
Introduce a constructor that takes an `llvm::VersionTuple` directly, instead of
needing to spell out `VersionRange::allGTE(<tuple>)` which is unnecessarily
verbose.
2025-03-04 19:41:04 -08:00
Artem Chikin
6da529f098 Merge pull request #79753 from artemcm/NewConstFeatureDefinition
[Compile Time Values] Add a new experimental feature and the parsing of the `@const` attribute
2025-03-04 12:26:04 -08:00
Qiongsi Wu
3271c193aa [Dependency Scanning] Remove Unnecessary Code that Computes Module Output Path (#79752)
https://github.com/swiftlang/swift/pull/79297 implemented current working directory pruning but left some unnecessary code
that computes Swift interface module output path prematurely. This PR removes the code that computes the output path too 
early. The `ExplicitModuleDependencyResolver` now adds the path to the command line after it can correctly compute it. 

Context: https://github.com/swiftlang/swift/pull/79297/files#r1955314542
2025-03-04 08:44:25 -08:00
Artem Chikin
de26e960e2 Rename '_const' attribute to 'CompileTimeLiteral'
To pave the way for the new experimental feature which will operate on '@const' attribute and expand the scope of what's currently handled by '_const' without breaking compatibility, for now.
2025-03-04 07:30:02 -08:00
Alexis Laferrière
eb148b1d37 Merge pull request #79713 from xymus/index-while-building-allow-errors
Index: Accept more deserialization inconsistencies during index-while-building
2025-03-03 11:33:31 -08:00
Alexis Laferrière
302d6f1dcf Index: Accept compiler errors during index-while-building
Force allowing reading from modules with compiler errors during
index-while-building as a way to recover from more deserialization
issues.
2025-02-28 14:56:26 -08:00
Artem Chikin
78153f1d0e Merge pull request #79676 from artemcm/RefineCrossImportOverlayResolutionLogic
[Dependency Scanning] Refine cross-import overlay detection algorithm
2025-02-28 08:58:25 -08:00
Artem Chikin
809dbf0994 [Dependency Scanning] Keep track of whether a given Swift 'import' statement is '@_exported' 2025-02-26 15:52:46 -08:00
Doug Gregor
7aac28e64b [Serialization] Add the STRICT_MEMORY_SAFETY record type. 2025-02-26 15:29:46 -08:00
Pavel Yaskevich
3cc24f7c19 [Serialization] Serialize a flag that indicates whether ExtensibleEnum feature is supported by a module
When `ExtensibleEnums` flag is set, it's going to be reflected in
the module file produced by the compiler to make sure that consumers
know that non-`@frozen` enumerations can gain new cases in the
future and switching cannot be exhaustive.
2025-02-25 00:05:21 -08:00
Usama Hameed
500187cf1e Add support for serializing debug_value instructions (#78056)
This patch adds support for serialization of debug value instructions. Enablement is currently gated behind the -experimental-serialize-debug-info flag.

Previously, debug_value instructions were lost during serialization. This made it harder to debug cross module inlined functions.
2025-02-24 20:21:15 -08:00
Alexis Laferrière
ecaa041344 Merge pull request #79165 from xymus/deser-protect-generic-params
Serialization: Protect `maybeReadGenericParams` against errors
2025-02-21 17:24:55 -08:00
Rintaro Ishizaki
6980509f8c [ASTGen] Generate DefaultArgumentInitializer
Rework ParamDecl contextualization.
2025-02-18 11:13:39 -08:00
Joe Groff
f778170cfb Merge pull request #79351 from jckarter/lifetime-dependence-lowering
SIL: Lower lifetime dependencies when lowering function types.
2025-02-17 07:51:20 -08:00
Hamish Knight
1e8dc55b7f [AST] NFC: Remove InitRetType
This is no longer used.
2025-02-16 18:52:23 +00:00
Pavel Yaskevich
515221c959 Merge pull request #79375 from xedin/isolation-caller-in-type-context
[AST/Sema] Add new function type isolation - `caller` to cover `@execution(caller)` attribute
2025-02-14 16:01:28 -08:00
Joe Groff
c65475628f SIL: Lower lifetime dependencies when lowering function types.
Map the lifetime dependencies described in terms of the formal AST-level parameters
to the correct parameter(s) in the lowered SIL function type. There can be 0, 1,
or many SIL parameters per formal parameter because of tuple exploding. Also,
record which dependencies are on addressable parameters (meaning that the dependency
includes not only the value of the parameter, but its specific memory location).
2025-02-14 09:47:53 -08:00
Pavel Yaskevich
cdb5396c00 [AST] Declare NonIsolatedCaller as kind of FunctionTypeIsolation
This would make sure that async function types marked as `@execution(caller)`
have correct isolation.

Also defines all of the possible conversions to and from `caller`
isolated function types.
2025-02-13 14:35:54 -08:00
Qiongsi Wu
9a5a83ad60 Modify ModuleDependencyInfo so we can set swift interface module output paths consistently and avoid const_casts. 2025-02-12 20:19:39 -08:00
Erik Eckstein
e0b4f71af6 SIL: remove the alloc_vector instruction
It's not needed anymore, because the "FixedArray" experimental feature is replaced by inline-arrays.
2025-02-12 10:51:14 +01:00
Michael Gottesman
7e350bb4ce Revert "[concurrency] Add Concurrent/ConcurrentUnsafe and use it instead of ActorIsolation::Nonisolated."
This reverts commit 0cb64638d0.
2025-02-06 14:05:06 -08:00
Michael Gottesman
f05f08c2c0 Revert "[concurrency] Make ActorIsolation::Nonisolated -> CallerIsolationInheriting and delete CallerIsolationInheriting."
This reverts commit 543b1e6ca3.
2025-02-06 14:04:30 -08:00
Saleem Abdulrasool
9c85fbc8da AST,DependencyScan,IRGen,Serialization,Tooling: track library style (#78777)
Track if the dependency is static or dynamic. This is in preparation for
helping rename the static library to differentiate it from import
libraries.
2025-02-06 13:22:56 -08:00
Alexis Laferrière
8d69807ed6 Merge pull request #79166 from xymus/deser-record-opaque-return-type
Serialization: Record OPAQUE_RETURN_TYPE_DECLS for llvm readers
2025-02-06 10:49:53 -08:00
Steven Wu
c1063d0992 Merge pull request #78623 from cachemeifyoucan/eng/bridging-header-auto-chaining
[BridgingHeader] Auto bridging header chaining
2025-02-05 14:23:26 -08:00
Alexis Laferrière
73573bb47b Serialization: record OPAQUE_RETURN_TYPE_DECLS for llvm readers 2025-02-05 11:32:06 -08:00
Alexis Laferrière
6c23def371 Serialization: protect maybeReadGenericParams against errors
Update signature and implementation of `maybeReadGenericParams` to pass
up errors to the caller. Also update all of its callers to pass up any
error.

rdar://126582124
2025-02-05 09:59:40 -08:00
Steven Wu
9d59044bb1 [BrdigingHeader] Auto bridging header chaining
Add ability to automatically chaining the bridging headers discovered from all
dependencies module when doing swift caching build. This will eliminate all
implicit bridging header imports from the build and make the bridging header
importing behavior much more reliable, while keep the compatibility at maximum.

For example, if the current module A depends on module B and C, and both B and
C are binary modules that uses bridging header, when building module A,
dependency scanner will construct a new header that chains three bridging
headers together with the option to build a PCH from it. This will make all
importing errors more obvious while improving the performance.
2025-02-05 09:41:04 -08:00
Alex Hoppen
fc2ee364ef Merge pull request #78899 from ahoppen/rdar141440011
[Serialization] Ensure we run `InheritedTypeRequest` before serializing inherited type
2025-02-04 18:36:48 -08:00
Alexis Laferrière
6852e0b9bb Merge pull request #79092 from xymus/more-serial-remarks
Serialization: Report deserialization remarks from lookup services
2025-02-04 09:03:23 -08:00
Alexis Laferrière
66402f110a Serialization: use diagnoseAndConsumeError in ModuleFile.cpp 2025-02-03 11:09:04 -08:00
Michael Gottesman
543b1e6ca3 [concurrency] Make ActorIsolation::Nonisolated -> CallerIsolationInheriting and delete CallerIsolationInheriting. 2025-02-03 10:56:08 -08:00
Michael Gottesman
0cb64638d0 [concurrency] Add Concurrent/ConcurrentUnsafe and use it instead of ActorIsolation::Nonisolated.
This is just the first part of a larger transition.
2025-02-03 10:56:06 -08:00
Meghana Gupta
681a6c814a Merge pull request #78939 from meg-gupta/ossamoduleson
Enable serialization in OSSA
2025-01-30 23:25:19 -08:00
Anthony Latsis
34f9b80cbc Merge pull request #78750 from AnthonyLatsis/oryza-sativa
[Gardening] Fix some set but not used variables
2025-01-31 04:29:05 +00:00
Meghana Gupta
1625001d69 Diagnose importing non-ossa module when -enable-ossa-modules is on 2025-01-30 17:10:04 -08:00
Meghana Gupta
7c45c8390b Bump module format for ossa serialization 2025-01-30 17:10:04 -08:00
Anthony Latsis
a84dfc8387 [Gardening] Fix some set but not used variables 2025-01-30 21:34:38 +00:00
Artem Chikin
e3de9d57ae Merge pull request #78153 from artemcm/ResolveImplicitConformancesDeserialization
[Deserialization] Use `swift::lookupConformance` to resolve implicit conformances
2025-01-30 10:58:37 -08:00
Artem Chikin
477ba0dd97 [Dependency Scanning] Remove references to per-triple PCM variant compilation 2025-01-29 11:32:07 -08:00
Allan Shortlidge
e019a32122 AST: Introduce and adopt DeclContext::isInSwiftinterface().
Checking whether a declaration is in a `.swiftinterface` is a very common query
that is made somewhat awkward because declarations are not always in source
files. To make these checks more ergonomic, expose a convenience on
DeclContext.
2025-01-27 19:25:41 -08:00
Alex Hoppen
2cfccccdd1 [Serialization] Ensure we run InheritedTypeRequest before serializing inherited type
When using `-experimental-skip-all-function-bodies` we don’t run the `TypeCheckSourceFileRequest` and thus don’t go through the decl checker, which calls `InheritedTypeRequest` on all inheritance clauses. This means that the inherited entries are not populated by the time we serialize the module. Trigger the computation of inherited entries by calling `InheritedTypeRequest` during serialization.

Unfortunately, we can’t use the type returned by `getResolvedType` for the serialization because `getResolvedType` returns an inverted protocol type for suppressed conformances but during serialization, we want to serialize the suppressed type with a `isSuppressedBit`. We thus need to call `getEntry(i).getType()` again to get the type to serialize.

rdar://141440011
2025-01-27 08:32:18 -08:00
eeckstein
95f1dfbf07 Merge pull request #78885 from eeckstein/fix-without-actually-escaping
Fix two problems with `withoutActuallyEscaping`
2025-01-27 07:59:02 +01:00
Allan Shortlidge
7b8cbd7109 AST: Store unresolved domain strings in AvailableAttr.
This is the first step towards resolving the AvailabilityDomain associated with
an AvailableAttr during type checking instead of parsing.
2025-01-26 13:50:56 -08:00
Doug Gregor
9af4d6eb65 Merge pull request #78730 from DougGregor/safe-attr
Introduce the @safe attribute as described in the opt-in safety checking proposal
2025-01-24 19:42:52 -08:00
Erik Eckstein
3ec5d7de24 SIL: replace the is_escaping_closure instruction with destroy_not_escaped_closure
The problem with `is_escaping_closure` was that it didn't consume its operand and therefore reference count checks were unreliable.
For example, copy-propagation could break it.
As this instruction was always used together with an immediately following `destroy_value` of the closure, it makes sense to combine both into a `destroy_not_escaped_closure`.
It
1. checks the reference count and returns true if it is 1
2. consumes and destroys the operand
2025-01-24 19:23:27 +01:00
Pavel Yaskevich
4b595b1b53 Merge pull request #78834 from xedin/fix-serialization-issue-with-execution-attr
[Serialization] `@execution` attribute should serialize behavior (not…
2025-01-23 15:52:43 -08:00