Commit Graph

5087 Commits

Author SHA1 Message Date
Erik Eckstein
7d70a70acf SIL: add the drop_deinit instruction
his instruction is a marker for a following destroy instruction to suppress the call of the move-only type's deinitializer.
2023-04-11 10:25:48 +02:00
Alexis Laferrière
ddf85dbe65 Merge pull request #64991 from xymus/serial-opaque-types
[Serialization] Only read the underlying type of an opaque type if inlinable
2023-04-07 16:11:58 -07:00
Alexis Laferrière
445307beec [Serialization] Always read opaque type underlying types in merge-module
When reading a swiftmodule that's part of the main module the compiler
should have access to all internal details. In that case, read the
underlying type to opaque types.

This was caught by `SILOptimizer/specialize_opaque_result_types2.sil`
which has a merge-module like behavior reading it sib files as input.
2023-04-07 08:37:06 -07:00
Alexis Laferrière
8ba60da81f [Serialization] Only write the underlying type of an opaque type if inlinable
Clients of a resilient module using opaque types don't need access to
the underlying type unless it's used in an inlinable context. Plus, the
underlying type can reference internal details which can lead to crashes
when they reference implementation-only dependencies. To clean up this
behavior, let's only serialize the underlying type if used by an
inlinable function.

rdar://105128784
2023-04-07 07:49:45 -07:00
Richard Wei
01e6fe2936 [Macros] Code item macros
Add support for declaring and expanding code item macros.  Add experimental feature flag `CodeItemMacros`.
2023-04-04 09:54:57 -07:00
Artem Chikin
f4bac4575d Merge pull request #64829 from artemcm/DisableASTGenParseInDepScan
[Dependency Scanning] Disable Swift Parser ASTGen during dependency scan
2023-04-03 09:27:24 -07:00
Slava Pestov
3d9a79e4b1 Merge pull request #64777 from slavapestov/sil-optimizer-variadic-generics
SIL optimizer fixes for variadic generics
2023-04-03 11:30:03 -04:00
Doug Gregor
f7e479759d Merge pull request #64854 from DougGregor/top-level-macro-lookup 2023-04-03 06:50:39 -07:00
Doug Gregor
828de17b00 [Macros] Resolve macro names using unqualified lookup that ignores expansions
The macro name resolution in the source lookup cache was only looking at
macros in the current module, meaning that any names introduced by peer
or declaration macros declared in one module but used in another would
not be found by name lookup.

Switch the source lookup cache over to using the same
`forEachPotentialResolvedMacro` API that is used by lookup within
types, so we have consistent name-lookup-level macro resolution in both
places.

... except that would be horribly cyclic, of course, so introduce name
lookup flags to ignore top-level declarations introduced by macro
expansions. This is semantically correct because macro expansions are
not allowed to introduce new macros anyway, because that would have
been a terrible idea.

Fixes rdar://107321469. Peer and declaration macros at module scope
should work a whole lot better now.
2023-04-02 23:15:38 -07:00
Joe Groff
e5ea789e25 Merge pull request #64690 from gottesmm/pr-08a1f1872f4e90eb29be0ba7c845d07fbb008571
[move-only] Add a new type of mark_must_check initable_but_not_consumable
2023-04-02 08:29:16 -07:00
Richard Wei
eb8e984b97 [Macros] Private discriminators for outermost-private MacroExpansionDecl (#64813)
Add a private discriminator to the mangling of an outermost-private `MacroExpansionDecl` so that declaration macros in different files won't have colliding macro expansion buffer names.

rdar://107462515
2023-03-31 20:36:29 -07:00
Michael Gottesman
43d8ab24f4 [move-only] Add a new type of mark_must_check initable_but_not_consumable.
This is used to teach the checker that the thing being checked is supposed to be
uninitialized at the mark_must_check point so that we don't put a destroy_addr
there.

The way this is implemented is that we always initially add
assignable_but_not_consumable but in DI once we discover that the assign we are
guarding is an init, we convert the assignable to its initable variant.

rdar://106525988
2023-03-31 17:32:58 -07:00
Artem Chikin
cc34ba00e2 [Dependency Scanning] Disable Swift Parser ASTGen during dependency scan
On both input moduel source-files and interface files.
This currently yields dramatic scanning performance improvements at no cost - we do not require an AST during scan.
2023-03-31 15:49:54 -07:00
Alexis Laferrière
4327c7342f [Serialization] Attempt to load transitive impl-only dependencies on testable imports
Implementation-only dependencies may be referenced from internal decls.
When that module is imported as @testable, clients see the internal
decls and may fail accessing them if the transitive implementation-only
dependencies are not loaded.

Let's consider such transtive implementation-only dependencies as
optional for @testable imports. As such, the compiler will attempt to
load them for test targets, and won't fail if the dependency is missing.

We can make these dependencies required for non-public imports, but it
could be project breaking to do so for implementation-only dependencies.
Considering them as optional is a decent compromise.

rdar://79459263
2023-03-31 09:34:56 -07:00
Slava Pestov
1d27f5b386 Serialization: Actually deserialize same-shape requirements
I added a test for this a while ago... but the test wasn't running. Fix the
test, and fix the bug.
2023-03-30 14:10:27 -04:00
Doug Gregor
7c7459ac6b Merge pull request #64641 from DougGregor/macro-replacement-expansion 2023-03-29 20:47:30 -07:00
Doug Gregor
38230b79f9 [Macros] Add (de-)serialization for expanded macro definitions 2023-03-29 16:32:32 -07:00
Doug Gregor
9292231e1f [Macros] Start recording expanded macro definitions and replacements
Handle a trivial macro defined in terms of another macro.
2023-03-29 16:32:28 -07:00
Alexis Laferrière
9e18563faf [Sema] Support -testable-import-module to load transitive non-public dependencies
When using the -testable-import-module argument to insert a testable
import, there's no ImportDecl on which to show the diagnostics when
loading transitive dependencies. Clean up the logic to still load
dependencies in such a case.
2023-03-29 13:59:29 -07:00
Alexis Laferrière
f7f69c6ae1 [Serialization] Load non-public transitive dependencies on @testable imports
A @testable import allows a client to call internal decls which may
refer to non-public dependencies. To support such a use case, load
non-public transitive dependencies of a module when it's imported
@testable from the main module.

This replaces the previous behavior where we loaded those dependencies
for any modules built for testing. This was risky as we would load more
module for any debug build, opening the door to a different behavior
between debug and release builds. In contrast, applying this logic to
@testable clients will only change the behavior of test targets.

rdar://107329303
2023-03-29 13:59:28 -07:00
Alexis Laferrière
87431a7a66 [Serialization|NFC] Split diagnoseSerializedASTLoadFailure in two
The new diagnoseSerializedASTLoadFailureTransitive diagnose problems for
transitive dependencies only: missing dependency, missing underlying
module, or circular dependency.
2023-03-29 13:59:28 -07:00
Alexis Laferrière
3c52406355 [Serialization|NFC] Extract logic loading dependencies out of associateWithFileContext 2023-03-29 13:59:28 -07:00
Alexis Laferrière
d707dc4d81 Merge pull request #64516 from xymus/remark-transitive
[Serialization] Remark on transitive dependencies and loading requirement
2023-03-28 09:18:07 -07:00
swift-ci
8ac71b115c Merge pull request #64525 from beccadax/checkmate-ii
Re-merge #63668: Improve @objcImplementation member checking
2023-03-28 00:56:44 -07:00
Konrad `ktoso` Malawski
0586c14b60 [Concurrency] SerialExecutor.isSameExclusiveExecutionContext (#64604) 2023-03-28 15:56:28 +09:00
Alexis Laferrière
bf2d2475f3 [Serialization] Remark on transitive dependencies 2023-03-27 10:04:03 -07:00
Becca Royal-Gordon
43e48ef37f Better support destructors in objcImpl 2023-03-25 14:52:40 -07:00
Alexis Laferrière
efb7f2423e Merge pull request #64618 from xymus/fix-106430304
[Serialization] Pass up deserialization errors when reading generic type params
2023-03-24 17:42:49 -07:00
Alexis Laferrière
1ec1df6f03 [Serialization] Pass up deserialization errors under generic type params
There is no related test as we don't have reproducer code and we've seen
it only in the debugger, but I believe the fix is sound on its own.

rdar://106430304
2023-03-24 13:49:53 -07:00
Ellie Shin
c2bb890f63 Merge pull request #64488 from apple/es-load
Do not load modules of the same package if built from interface
2023-03-22 23:26:12 -07:00
Ellie Shin
fc2b61da71 - Do not load modules of the same package if built from interface.
- Show diagnostics with an interface path

Resolves rdar://104617990
2023-03-22 17:30:27 -07:00
Alexis Laferrière
cc433261ba Merge pull request #64522 from xymus/access-level-import-testable
[Serialization] Load non-public dependencies of modules when testing is enabled
2023-03-22 12:54:39 -07:00
John McCall
7505a8a487 Merge pull request #64517 from rjmccall/arity-reabstraction-closures
Implement arity reabstraction for closures
2023-03-22 14:14:23 -04:00
Alexis Laferrière
599346885e [Serialization] Differentiate module loading behavior for non-public imports
Differentiate `internal` and `fileprivate` imports from
implementation-only imports at the module-wide level to offer a
different module loading strategy. The main difference is for non-public
imports from a module with testing enabled to be loaded by transitive
clients.

Ideally, we would only load transitive non-public dependencies on
testable imports of the middle module. The current module loading logic
doesn't allow for this behavior easily as a module may be first loaded
for a normal import and extra dependencies would have to be loaded on
later imports. We may want to refactor the module loading logic to allow
this if needed.

rdar://106514965
2023-03-21 16:46:53 -07:00
Alexis Laferrière
d7cd65cdd6 [Serialization] Move some package-only import logic from writer to reader
Let's centralize the logic deciding if we load a transitive dependency
on the client side and have the producer write the truth in the
swiftmodule.
2023-03-21 16:45:49 -07:00
John McCall
3fe46464c7 Allow a SILFunctionArgument to be a parameter pack.
We might want to record the *sequence* of parameter decls associated
with a parameter pack, but currently we're not doing that.
2023-03-21 17:36:05 -04:00
Alexis Laferrière
e010d7d494 Merge pull request #64487 from xymus/transitive-loading-refactor
[Serialization] Refactor how we decide to load transitive dependencies
2023-03-21 11:30:41 -07:00
Alexis Laferrière
201c4b6205 Merge pull request #64486 from xymus/import-filter-refactor
[Sema] Intro common sets of import filters to simplify calls to `getImportedModules`
2023-03-21 11:10:50 -07:00
Alexis Laferrière
8aadcf464f [Serialization] Do not accept packages without a name
Realign the module loading behavior with the one of the package
access-level. If the package name is an empty string, don't accept other
modules with an empty package name as being part of the same module and
don't load package dependencies in such a case.
2023-03-20 14:03:45 -07:00
Alexis Laferrière
fa58280587 [Serialization] Fix missing lookup of package-only dependencies in swiftmodule
I don't think this logic is used in practice without merge-modules.
Let's still implement it for the configurations still using
merge-modules and for general consistency.
2023-03-20 14:03:45 -07:00
Alexis Laferrière
56e013edb9 [Serialization] Try to load transitive package dependencies in the debugger 2023-03-20 14:03:45 -07:00
Alexis Laferrière
c2181b136d [Serialization] Use the new logic for transitive dependencies in the scanner 2023-03-20 14:03:45 -07:00
Alexis Laferrière
61c0827427 [Serialization] Refactor logic deciding transitive module loading logic
Refactor and centralize the logic about how implementation-only and
package-only dependencies should be loaded.
2023-03-20 13:53:10 -07:00
Michael Gottesman
8d12f893c2 [sil] Add a moveable_value_debuginfo field to AllocBoxInst.
Just getting parsing/serialization to work. I haven't wired it up to anything.
2023-03-19 15:50:29 -07:00
Michael Gottesman
4a309575d7 [sil] Rename [moved] flag on debug_value/alloc_stack to moveable_value_debuginfo.
This is in preparation for wiring up debug info support for noncopyable
values. Originally this flag name made sense since it was set when we performed
consume operator checking. Now I am going to use it for noncopyable types as
well. I think the new name uses_moveable_value_debuginfo actually describes what
the flag is supposed to do, tell IRGen that the value may be moved since it
needs to use moveable value debug info emission.
2023-03-19 15:38:42 -07:00
Alexis Laferrière
205a2edf38 [Sema] Intro set of import filters for general use
Calling getImportedModules requires to list the desired kind of imports.
With the new kind of imports this has become cumbersome. Let's simplify
it by offering common sets of imports. Advanced call sites can still
list the desired imports explicitly.
2023-03-17 16:05:44 -07:00
John McCall
09018a8981 [NFC] Store interface shape types in opened element environments 2023-03-15 17:25:04 -04:00
Kavon Farvardin
a8a44ebb17 Merge pull request #64106 from kavon/enable-moveonly-by-default
Enable moveonly / noncopyable types by default
2023-03-15 09:59:29 -07:00
Konrad `ktoso` Malawski
41f99fc2ae [Executors][Distributed] custom executors for distributed actor (#64237)
* [Executors][Distributed] custom executors for distributed actor

* harden ordering guarantees of synthesised fields

* the issue was that a non-default actor must implement the is remote check differently

* NonDefaultDistributedActor to complete support and remote flag handling

* invoke nonDefaultDistributedActorInitialize when necessary in SILGen

* refactor inline assertion into method

* cleanup

* [Executors][Distributed] Update module version for NonDefaultDistributedActor

* Minor docs cleanup

* we solved those fixme's

* add mangling test for non-def-dist-actor
2023-03-15 23:42:55 +09:00
Kavon Farvardin
ea1e83b1d7 move noncopyable types out from behind the feature flag
Since these types depend on lexical borrow scopes (a SIL
option), we're now making that the requirement whenever
such types appear.
2023-03-13 22:39:31 -07:00