Commit Graph

1578 Commits

Author SHA1 Message Date
Slava Pestov
3a92d2fc53 AST: Remove legacy GSB-based GenericSignature query implementation 2022-01-12 12:33:34 -05:00
Evan Wilde
130f5caf48 Add experimental-async-top-level flag
Protect this feature behind a feature flag until it's ready for
prime-time.
2022-01-11 11:04:43 -08:00
Nuri Amari
130f2de7fd Improve ClangImporter failure diagnostics
This patch introduces new diagnostics to the ClangImporter to help
explain why certain C, Objective-C or C++ declarations fail to import
into Swift. This patch includes new diagnostics for the following entities:

- C functions
- C struct fields
- Macros
- Objective-C properties
- Objective-C methods

In particular, notes are attached to indicate when any of the above
entities fail to import as a result of refering an incomplete (only
forward declared) type.

The new diangostics are hidden behind two new flags, -enable-experimental-clang-importer-diagnostics
and -enable-experimental-eager-clang-module-diagnostics. The first flag emits diagnostics lazily,
while the second eagerly imports all declarations visible from loaded Clang modules. The first
flag is intended for day to day swiftc use, the second for module linting or debugging the importer.
2022-01-02 12:43:59 -05:00
Alex Hoppen
669e3f34a6 Merge pull request #40155 from ahoppen/pr/improve-module-search-path-lookup
[Serialization] Improve module loading performance
2021-12-20 18:09:17 +01:00
nate-chandler
e31c155f78 Merge pull request #40555 from nate-chandler/copy_propagation/rename-disabled-flags
Clarified copy-prop/lexical-lifetime flags.
2021-12-16 15:28:26 -08:00
Nate Chandler
08bd7c5c99 Replaced -disable-copy-prop with multi-var.
Replaced the -disable-copy-propagation flag with
-enable-copy-propagation=false where the latter is a new multi-var
-enable-copy-propagation= which can take one of three values:
- true
- requested-passes-only
- false
2021-12-15 21:36:53 -08:00
Nate Chandler
e881e2accd Base LexicalLifetimes dflt on SILOpts::CopyProp.
Previously, the default value for SILOptions::LexicalLifetimes was based
on a copy propagation behavior (which can then be overridden by the
flags for lexical lifetimems) only when the copy propagation was
explicitly specified.  Instead, set base the default value for this
option (SILOptions::LexicalLifetimes) on the effective copy propagation
behavior (i.e. SILOptions::CopyPropagation) regardless of whether an
explicit behavior has been specified.

Doing so will ensure that the desired behavior occurs as the default
behavior for copy-propagation changes, but for now this change is NFC.
2021-12-15 21:36:46 -08:00
Slava Pestov
c1384f36a8 SIL: Add -disable-subst-sil-function-types flag to work around type lowering bugs 2021-12-15 12:14:34 -05:00
nate-chandler
660929dff5 Merge pull request #40539 from nate-chandler/copy_propagation/rename-options
[NFC] Tweaked SILOptions fields for copy propagation.
2021-12-14 07:56:04 -08:00
Alex Hoppen
fe7878ecce [Serialization] Improve module loading performance
When looking for a Swift module on disk, we were scanning all module search paths if they contain the module we are searching for. In a setup where each module is contained in its own framework search path, this scaled quadratically with the number of modules being imported. E.g. a setup with 100 modules being imported form 100 module search paths could cause on the order of 10,000 checks of `FileSystem::exists`. While these checks are fairly fast (~10µs), they add up to ~100ms.

To improve this, perform a first scan of all module search paths and list the files they contain. From this, create a lookup map that maps filenames to the search paths they can be found in. E.g. for
```
searchPath1/
  Module1.framework

searchPath2/
  Module1.framework
  Module2.swiftmodule
```
we create the following lookup table
```
Module1.framework -> [searchPath1, searchPath2]
Module2.swiftmodule -> [searchPath2]
```
2021-12-14 12:44:13 +01:00
swift-ci
36d6a34bec Merge pull request #40535 from nate-chandler/lexical_lifetimes/allow-flags-compatible-with-move-only-to-be-passed 2021-12-13 18:02:07 -08:00
Nate Chandler
59ae5180ba [NFC] Used SILOption field for copy propagation.
Replaced the quad-state (of state which one was illegal) of two booleans
(EnableCopyPropagation and DisableCopyPropagation) with an enum.
2021-12-13 17:44:28 -08:00
Nate Chandler
868ae0e259 Error on bad copy propagation flag combo.
Diagnose passing both -enable-copy-propagation and
-disable-copy-propagation.
2021-12-13 17:44:24 -08:00
Nate Chandler
0cee5b227e Fixed flag checking for lexical borrow scopes.
Previously the following pairs were prohibited incorrectly:
- -enable-lexical-borrow-scopes=true, -enable-experimental-move-only
- -enable-lexical-lifetimes=true, -enable-experimental-move-only
and the following pairs were allowed incorrectly:
- -enable-lexical-borrow-scopes=false, -enable-experimental-move-only
- -enable-lexical-lifetimes=false, -enable-experimental-move-only
Here, that's fixed.  The first two pairs are allowed and the second two
pairs prohibited.
2021-12-13 14:55:01 -08:00
nate-chandler
68f5d8d7ca Merge pull request #40519 from nate-chandler/lexical_lifetimes/disable-with-copy-propagation
Disable lexical-lifetimes with copy-propagation.
2021-12-12 20:28:49 -08:00
Ellie Shin
2ab97edd6a Merge pull request #40494 from apple/es-complete
[Module Aliasing] Add module aliasing option to swift-ide-test
Add module aliasing handling in code complete
Resolves rdar://86294338
2021-12-10 22:36:50 -08:00
Nate Chandler
08a3d3c367 Disable lexical-lifetimes with copy-propagation.
If -disable-copy-propagation is passed, just emit lexical diagnostic
markers but do not enable lexical lifetimes.
2021-12-10 18:36:35 -08:00
Nate Chandler
1464c1b1ff [NFC] Renamed LexicalLifetimesOption cases.
The cases' new names more accurately reflect what behavior occurs when
SILOptions::LexicalLifetimes is assigned that case.
2021-12-10 18:36:28 -08:00
Ellie Shin
4ad3a551b4 Exit early args are invalid
Add batch-code-compelte test
2021-12-10 17:14:18 -08:00
Ellie Shin
b5b285e54e Reuse compute module aliases function
Update tests
2021-12-10 16:06:18 -08:00
Holly Borla
69be7b17fc Merge pull request #40282 from hborla/existential-any
[SE-0335] Introduce existential `any`
2021-12-10 08:56:03 -08:00
Ellie Shin
1e5160b809 Update comments 2021-12-10 00:48:26 -08:00
Ellie Shin
93132b8ce3 Add module aliasing option to swift-ide-test
Add module aliasing handling in code complete
Resolves rdar://86294338
2021-12-09 15:36:55 -08:00
Slava Pestov
75ade66b21 Merge pull request #40459 from slavapestov/rqm-disabled-merged-types
RequirementMachine: Add flags to enable and disable merged associated types
2021-12-09 16:45:56 -05:00
Holly Borla
7cdda6dc80 [FrontendOptions] Add a frontend flag -enable-explicit-existential-types
to enable the 'any' keyword.
2021-12-09 09:26:12 -08:00
Nate Chandler
ea42e2f334 Enabling copy propagation enables lexical lifetimes.
The effect of passing -enable-copy-propagation is both to enable the
CopyPropagation pass to shorten object lifetimes and also to enable
lexical lifetimes to ensure that object lifetimes aren't shortened while
a variable is still in scope and used.

Add a new flag, -enable-lexical-borrow-scopes=true to override
-enable-copy-propagation's effect (setting it to ::ExperimentalLate) on
SILOptions::LexicalLifetimes that sets it to ::Early even in the face of
-enable-copy-propagation.  The old flag -disable-lexical-lifetimes is
renamed to -enable-lexical-borrow-scopes=false but continues to set that
option to ::Off even when -enable-copy-propagation is passed.
2021-12-08 19:13:21 -08:00
Slava Pestov
c1339240cd RequirementMachine: Add flags to enable and disable merged associated types
On by default, no change from current behavior. I'm going to try turning
this off (and hopefully ripping it out entirely) once I fix a few bugs.
2021-12-08 21:32:42 -05:00
Nate Chandler
1961be8845 Renamed flag to -enable-lexical-lifetimes.
Previously, both swift-frontend and sil-opt put lexical lifetimes behind
a flag named -enable-experimental-lexical-lifetimes.  That's redundant.
Here, the experimental portion of the name is dropped.
2021-12-03 17:40:37 -08:00
Xi Ge
b8a2d0752f Merge pull request #40379 from apple/revert-40368-revert-40357-obfuscate-searialized-paths
Re-apply "serialization: obfuscate the serialized search paths"
2021-12-02 19:21:04 -08:00
Holly Borla
47b375fb3f Merge pull request #40361 from hborla/enable-structural-opaque-types
[SE-0328] Enable structural opaque result types.
2021-12-02 15:00:18 -08:00
Xi Ge
6377c3a742 Revert "Revert "serialization: obfuscate the serialized search paths"" 2021-12-02 13:21:04 -08:00
Saleem Abdulrasool
11d5d6d4ca Revert "serialization: obfuscate the serialized search paths" 2021-12-02 08:18:23 -08:00
Xi Ge
0047d81f9a serialization: obfuscate the serialized search paths
We noticed some Swift clients rely on the serialized search paths in the module to
find dependencies and droping these paths altogether can lead to build failures like
rdar://85840921.

This change teaches the serialization to obfuscate the search paths and the deserialization
to recover them. This allows clients to keep accessing these paths without exposing
them when shipping the module to other users.
2021-12-01 11:47:41 -08:00
Holly Borla
9196c9ad41 [FrontendOptions] Enable structural opaque result types and remove
the -enable-experimental-structural-opaque-types frontend flag.
2021-11-30 15:41:23 -08:00
Kuba (Brecka) Mracek
c89eca6c34 Enforce consistent usage of -experimental-hermetic-seat-at-link flag (#39986)
We've recently added the -experimental-hermetic-seal-at-link compiler flag,
which turns on aggressive dead-stripping optimizations and assumes that library
code can be optimized against client code because all users of the library
code/types are present at link/LTO time. This means that any module that's
built with -experimental-hermetic-seal-at-link requires all clients of this
module to also use -experimental-hermetic-seal-at-link. This PR enforces that
by storing a bit in the serialized module, and checking the bit when importing
modules.
2021-11-30 10:44:58 -08:00
Slava Pestov
163293e6f9 RequirementMachine: Split up -requirement-machine-generic-signatures flag into -requirement-machine-{abstract,inferred}-signatures 2021-11-19 17:06:00 -05:00
Richard Wei
65bffd7ad7 Add _MatchingEngine and _StringProcessing modules.
These modules are part of the experimental declarative string processing feature. If accepted to the Standard Library, _StringProcessing will be available via implicit import just like _Concurrency, though _MatchingEngine will still be hidden as an implementation detail.

`_MatchingEngine` will contain the general-purpose pattern matching engine ISA, bytecode, and executor. `_StringProcessing` will contain regular expression and pattern matching APIs whose implementation depends on the matching engine..

Also consolidates frontend flag `-enable-experimental-regex` as `-enable-experimental-string-processing`.

Resolves rdar://85478647.
2021-11-19 09:27:33 -08:00
Michael Gottesman
3eba144b83 Merge pull request #40189 from gottesmm/pr-aeffd0309402b8c9a744770c71ce40ca6f0459ff
[move-operator] Specify if LexicalLifetimes is enabled using an enum instead of a bool.
2021-11-15 16:47:38 -08:00
Kuba (Brecka) Mracek
66bd5e6a39 Add ASTMangler.AllowStandardSubstitutions to allow using a stripped-down libswiftCore (#40009) 2021-11-15 15:40:35 -08:00
Michael Gottesman
72eb5e2eec [move-operator] Specify if LexicalLifetimes is enabled using an enum instead of a bool.
The reason why I am doing this is that we are going to be enabling lexical
lifetimes early in the pipeline so that I can use it for the move operator's
diagnostics.

To make it easy for passes to know whether or not they should support lexical
lifetimes, I included a query on SILOptions called
supportsLexicalLifetimes. This will return true if the pass (given the passed in
option) should insert the lexical lifetime flag. This ensures that passes that
run in both pipelines (e.x.: AllocBoxToStack) know whether or not to set the
lexical lifetime flag without having to locally reason about it.

This is just chopping off layers of a larger patch I am upstreaming.

NOTE: This is technically NFC since it leaves the default alone of not inserting
lexical lifetimes at all.
2021-11-15 13:47:22 -08:00
Michael Ilseman
2740e2707c Experimental Regex Strawperson (use Swift in the parser) (#40117)
[regex] Use Swift in the parser

Add in a strawperson use of Swift by the parser, for
future regex support.
2021-11-14 07:11:47 -07:00
Slava Pestov
d0a8abb533 RequirementMachine: Add -requirement-machine-generic-signatures flag
Just as with the others, this has three values: on, off, and verify.
Not hooked up for now.
2021-11-12 00:32:43 -05:00
Saleem Abdulrasool
af772d50fc Merge pull request #39998 from compnerd/async-inheritance
IRGen: initial pass to support `async` inheritance on Windows
2021-11-01 19:59:04 -07:00
Kuba (Brecka) Mracek
d682049d25 Under VFE/WME, disable mangled accessors and disable LLVM MergeFunctions (#39969) 2021-11-01 15:34:53 -07:00
冀卓疌
af7bee8430 Merge pull request #39853 from rjmansfield/main
Fix various typos and missing whitespace.
2021-11-02 03:05:47 +08:00
Saleem Abdulrasool
68bc33fed3 IRGen: initial pass to support async inheritance on Windows
With PE/COFF, one cannot reference a data symbol directly across the
binary module boundary.  Instead, the reference must be indirected
through the Import Address Table (IAT) to allow for position
independence.

When generating a reference to a AsyncFunctionPointer ({i8*, i32}), we
tag the pointer as being indirected by tagging bit 1 (with the
assumption that native alignment will ensure 4/8 byte alignment, freeing
the bottom 2 bits at least for bit-packing).  We tweak the
v-table/witness table emission such that all references to the
AsyncFunctionPointer are replaced with the linker synthetic import
symbol with the bit packing:

~~~
.quad __imp_$s1L1CC1yyYaKFTu+1
~~~

rather than

~~~
.quad $s1L1CC1yyYaKFTu
~~~

Upon access of the async function pointer reference, we open-code the
check for the following:

~~~
pointer = (pointer & 1) ? *(void **)(pointer & ~1) : pointer;
~~~

Thanks to @DougGregor for the discussion and the suggestion for the
pointer tagging.  Thanks to @aschwaighofer for pointers to the code that
I had missed.  Also, thanks to @SeanROlszewski for the original code
sample that led to the reduced test case.

Fixes: SR-15399
2021-11-01 11:23:51 -07:00
QuietMisdreavus
dd88e0dda6 Merge pull request #39865 from apple/QuietMisdreavus/private-swiftc-symbols
[Driver][SymbolGraph] add new flag -symbol-graph-minimum-access-level

rdar://79099869
2021-10-29 13:01:22 -06:00
Erik Eckstein
4e6c5434f3 driver/frontend: Add an -experimental-performance-annotations option to enable performance annotations 2021-10-28 18:43:14 +02:00
Michael Gottesman
60f3d61031 Merge pull request #39943 from gottesmm/pr-65ca66f5402c00e0f0fa0608409ef1c732d1fd2b
[moveOnly] Add a skeleton _move function
2021-10-28 02:23:56 -07:00
Michael Gottesman
44bd180d85 [moveOnly] Add a frontend flag -enable-experimental-move-only to control usage of move only features.
These include _move and @_noImplicitCopy. I still need to wire up the parsing of
those behind this feature.

The reason that I am adding this now is that I am going to now need to make some
changes behind a feature flag and I have not yet needed to add one. The specific
reason I needed to add one here is to ensure that I properly guard inside _move
the call to Builtin.move so as to prevent a "cond_fail" incident.

P.S.: This work depends on experimental lexical lifetimes being enabled as well,
so I did that at the same time in this PR.
2021-10-27 18:45:33 -07:00