Commit Graph

6605 Commits

Author SHA1 Message Date
Rintaro Ishizaki
2c7cbe9748 [SourceKit] Initialize llvm in SourceKit
Preparation for code generation in SourceKit
2021-12-17 10:19:53 -08:00
swift-ci
09df1f9200 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-16 17:12:52 -08: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
27d758d45a [SILOpt] Make lex-lt options optional.
Use boolOrDefault to distinguish betweeen options that are unset and
those that are set (to some value).  Then, only override the default
values in SILOptions when the options are specified.
2021-12-15 21:37:07 -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
swift-ci
09c4a37ac9 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-15 16:44:42 -08:00
Ben Barham
e48fe8c2f9 Merge pull request #40351 from bnbarham/annotate-default-args
[CodeComplete] Markup default arguments
2021-12-16 10:19:25 +10:00
swift-ci
ba21f792d3 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-15 16:16:16 -08:00
swift-ci
ad7abdcbc7 Merge pull request #40278 from atrick/fix-debuginfo 2021-12-15 16:14:50 -08:00
Ben Barham
65ef8020de [CodeComplete] Add option to add calls with no defaults (or not)
Now that arguments are marked up with whether they have a default or
not, clients may not need the extra call (that has no default
arguments). Add an option to allow not adding this item.

Resolves rdar://85526214.
2021-12-15 13:30:57 +10:00
swift-ci
0aec6d22ea Merge remote-tracking branch 'origin/main' into rebranch 2021-12-14 08:13:49 -08: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
swift-ci
7ff906d730 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-14 04:53:37 -08:00
Alex Hoppen
4fc9d015de Merge pull request #40107 from ahoppen/pr/load-stdlib-in-setup
[Frontend] Load standard libarary in CompilerInstance::setup
2021-12-14 13:45:23 +01: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
Andrew Trick
77deb0e011 Add a -opt-mode flag to sil-opt
To indicate whether the specified passes should be run as-if under
-Onone, -Osize, or -O.

Important for proper debug info handling.
2021-12-13 21:35:14 -08:00
Nate Chandler
478136dd40 [NFC] [SILOpt] Explicitly specified flag defaults.
In preparation to change the default values, specify explicitly what
they are.
2021-12-13 17:44:32 -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
afe5fdc7e7 [SILOpt] Tweaked error message. 2021-12-13 17:44:20 -08:00
swift-ci
60fc05af03 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-13 10:54:40 -08:00
Alex Hoppen
ee79c9f62a Merge pull request #40504 from ahoppen/pr/fix-snapshot-nullptr-issue
[SourceKit] Fix a crash that occurred when a document without an associated source file is reopened
2021-12-13 19:46:57 +01:00
swift-ci
461e2494f5 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-13 10:37:59 -08:00
Alex Hoppen
f5b6103ef7 [SourceKit] Fix a crash that occurred when a document without an associated source file is reopened
When opening a file for the first time, we don’t store a snapshot for it. This could cause a crash when trying to consult its snapshot to see whether an AST can be reused for cursor info.
2021-12-13 16:43:32 +01:00
Alex Hoppen
22f67e89a6 [SourceKit] Explicitly specify frontend action type when creating compiler invocation
Explicitly specify the frontend action to make sure we aren’t loading thes stdlib if the performed action is syntactic only.
2021-12-13 15:32:08 +01:00
Alex Hoppen
63c31033fc [Frontend] Load standard libarary in CompilerInstance::setup
Instead of checking that the stdlib can be loaded in a variety of places, check it when setting up the compiler instance. This required a couple more checks to avoid loading the stdlib in cases where it’s not needed.

To be able to differentiate stdlib loading failures from other setup errors, make `CompilerInstance::setup` return an error message on failure via an inout parameter. Consume that error on the call side, replacing a previous, more generic error message, adding error handling where appropriate or ignoring the error message, depending on the context.
2021-12-13 15:32:08 +01: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
swift-ci
a7042191fd Merge remote-tracking branch 'origin/main' into rebranch 2021-12-10 22:53:35 -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
541c078795 Update input description 2021-12-10 16:12:30 -08:00
Ellie Shin
b5b285e54e Reuse compute module aliases function
Update tests
2021-12-10 16:06:18 -08:00
swift-ci
6aa71465d0 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-10 05:33:50 -08:00
Alex Hoppen
5a6341bd65 Merge pull request #40493 from ahoppen/pr/enqueue-consumer-on-background-queue
[SourceKit] Enqueue `SwiftASTConsumer`s async on a queue
2021-12-10 14:23:47 +01:00
Alex Hoppen
c90c7a2975 [SourceKit] Enqueue SwiftASTConsumers async on a queue
Enqueuing `SwiftASTConsumer`s might be expensive because `getBuildOperationForConsumer` consults the file system. Since all results from the AST build are processed asynchronously anyway, there’s no need to perform the enqueuing  synchronously.

rdar://86289703
2021-12-10 09:11:02 +01:00
swift-ci
1c8c75ac62 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-09 17:08:58 -08:00
Ben Barham
9dabad41b6 Merge pull request #40491 from apple/revert-40353-pr/no-semantic-info-if-not-requested
Revert "[SourceKit] Don't build an AST if no semantic info is requested"
2021-12-10 10:39:40 +10: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
Alex Hoppen
4aa911023a Merge pull request #40339 from ahoppen/pr/improve-sourcekit-stamp-handling
[SourceKit] Improvements to stamp handling in SwiftASTManager
2021-12-09 23:53:59 +01:00
Alex Hoppen
a5b3f83223 Revert "[SourceKit] Don't build an AST if no semantic info is requested" 2021-12-09 21:20:43 +01:00
swift-ci
77405f1ea0 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-09 08:13:36 -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
Alex Hoppen
e17faa5bcf [SourceKit] Improve memory cost function of ASTBuildOperation 2021-12-08 15:17:13 +01:00
Alex Hoppen
3adb9c2823 [SourceKit] Make FileContent non ref-counted
We never need to have two copies of the same `FileContent` object, so we don’t need a copy constructor and can thus pass it on the stack again, instead of storing it on the heap.
2021-12-08 15:17:13 +01:00
Alex Hoppen
dcbedc65fd [SourceKit] Remove some dupliate computation of realpaths 2021-12-08 15:17:13 +01:00
Alex Hoppen
5f4b1a0b27 [SourceKit] Don't store Stamps in ASTBuildOperation
FileContents already contains the stamps.
2021-12-08 15:17:13 +01:00
Alex Hoppen
a8bfd4fe44 [SourceKit] Store FileContents in ASTBuildOperation instead of snapshots 2021-12-08 15:17:13 +01:00