Commit Graph

668 Commits

Author SHA1 Message Date
Artem Chikin
7d1d8a4661 [Dependency Scanning] Factor ModuleDependenciesCache out of a CompilerInstance into callers of scanDependencies
It is now the responsibility of the scanDependencies code to instantiate (and share) the cache.
e.g. FrontendTool instantiates a new cache per `-scan-dependencies` invocation, and the DependencyScanningTool keeps one shared cache across its lifetime.
2021-01-07 09:08:20 -08:00
Alexis Laferrière
d79a58fbb4 [Frontend] Fix use of unique pointer to VFS
rdar://72137092
2020-12-09 08:29:37 -08:00
Rintaro Ishizaki
bf5d22257a [Frontend] Opt-in missing file recovery 2020-12-04 15:23:43 -08:00
Rintaro Ishizaki
055dc66d3b [Frontend] Recover missing input file by dummy input buffer.
Also, continue trying opening files even if any of primary files are
missing so that the caller can know all files failed to open.

rdar://problem/33757793
2020-12-04 15:23:29 -08:00
Ben Barham
b0577b0641 Merge pull request #34472 from bnbarham/benb/allow-errors-69815975
[Serialization] Add an option to output modules regardless of errors
2020-11-11 08:30:18 +10:00
Artem Chikin
3e3be76efb Merge pull request #34646 from artemcm/BatchScanShouldShareCache
[Dependency Scanner] Share `ModuleDependenciesCache` as a part of the CompilerInstance
2020-11-10 14:10:11 -08:00
Artem Chikin
10b6b9d47c [Dependency Scanner] Share ModuleDependenciesCache as a part of the CompilerInstance
This will allow individual module scans in batch-scanning mode to share the already-scanned Swift and Clang modules, and avoid instantiating a brand new Clang `DependencyScanningService` for each batch entry.

Performance-improvement anecdote:
A simple experiment which performs a batch scan of all modules involved in planning a build of SwiftPM (using SwiftPM in explicit module build mode), which includes 126 batch entries (scan entry-points), with 21 distinct Swift modules and 27 distinct Clang modules (many Clang modules are scanned multiple times, at different target versions), this modification reduces the total time taken from ~34 seconds to ~6.
2020-11-10 09:26:34 -08:00
Ben Barham
241559dc88 [Serialization] Add an option to output modules regardless of errors
Adds a new frontend option
"-experimental-allow-module-with-compiler-errors". If any compilation
errors occur while generating the .swiftmodule, this mode will skip SIL
entirely and only serialize the (likey invalid) AST.

This existence of this option during generation is serialized into the
resulting .swiftmodule. Errors found in deserialization are only allowed
if it is set.

Primarily intended for IDE requests (eg. indexing and code completion)
to ensure robust cross-module results, despite possible errors.

Resolves rdar://69815975
2020-11-10 14:47:22 +10:00
Doug Gregor
ff14a40f49 [Concurrency] Don't import _Concurrency implicitly when building a module.
Another fix for rdar://71045297.
2020-11-09 11:15:12 -08:00
swift-ci
f82e962262 Merge pull request #34609 from apple/disable-implicit-concur-import 2020-11-06 15:16:45 -08:00
Kavon Farvardin
242e9fe464 add the -disable-implicit-concurrency-module-import hidden flag 2020-11-06 08:54:01 -08:00
Ben Barham
7cee600bcd [SILGen] Add flag to skip typechecking and SIL gen for function bodies
Adds a new flag "-experimental-skip-all-function-bodies" that skips
typechecking and SIL generation for all function bodies (where
possible).

`didSet` functions are still typechecked and have SIL generated as their
body is checked for the `oldValue` parameter, but are not serialized.
Parsing will generally be skipped as well, but this isn't necessarily
the case since other flags (eg. "-verify-syntax-tree") may force delayed
parsing off.
2020-11-06 12:08:19 +10:00
Doug Gregor
13c17aef95 [Concurrency] Only auto-import _Concurrency when auto-importing Swift.
This allows the standard library to build with concurrency enabled.
Fixes rdar://70700689.
2020-10-29 14:57:10 -07:00
John McCall
a8464dcaf1 Implicitly import _Concurrency under -enable-experimental-concurrency 2020-10-22 00:53:15 -04:00
Brent Royal-Gordon
f71923778b Add -testable-import-module frontend flag
This is just like -import-module, but it does an @testable import. Simple, right?

Fixes rdar://66544654.
2020-10-09 18:59:20 -07:00
Brent Royal-Gordon
c13067a0e0 [NFC] Rework ImplicitImportInfo::ModuleNames
Replace with an array of AttributedImport<UnloadedImportedModule> to add flexibility.
2020-10-09 18:58:03 -07:00
Xi Ge
8ccee27db7 ModuleInterface: refactor ModuleInterfaceChecker out of ModuleInterfaceLoader
This refactoring allows us to drop ModuleInterfaceLoader when explicit modules
are enabled. Before this change, the dependencies scanner needs the loader to be
present to access functionalities like collecting prebuilt module candidates.
2020-10-01 10:30:48 -07:00
Robert Widmann
574ee39397 Stage in frontend flags for experimental cross-module incremental builds 2020-09-24 17:11:28 -06:00
Robert Widmann
3287c4b271 [NFC] Refactor Main File Computation 2020-09-11 22:28:59 -06:00
Robert Widmann
a8766cce5b [NFC] Refactor InputFile's Accessors 2020-09-11 22:28:58 -06:00
Robert Widmann
75116e9f86 [NFC] Inline CompilerInstance::setUpForInput 2020-09-11 21:24:26 -06:00
Robert Widmann
c3e33bec7a [NFC] Drop getSourceFileKind 2020-09-11 21:24:26 -06:00
Robert Widmann
d4b2e167ac Model ObjCHeader Inputs
These inputs were previously modeled as Swift files, which would lead to bizarre situations where parts of the pipeline expecting Swift inputs actually wound up parsing Objective-C.
2020-09-11 13:55:48 -06:00
Xi Ge
a4d731ed9f ModuleLoader: remove several walk-arounds for not having a persistent ClangImporterOptions available. NFC 2020-09-02 15:10:50 -07:00
Xi Ge
c403b140e1 ClangImporter: refactor ClangImporterOptions to be ASTContext-owned. NFC
We need ClangImporterOptions to be persistent for several scenarios: (1)
when creating a sub-ASTContext to build Swift modules from interfaces; and
(2) when creating a new Clang instance to invoke Clang dependencies scanner.

This change is NFC.
2020-09-01 14:04:22 -07:00
Robert Widmann
4c7ccf5abe [NFC] Clean Up FrontendTool
Try to impose a simple structure that splits performing actions from the
pre and post-pipeline conditions. Wherever actions would take more than
a simple return, split them into functions. Refine functions that
perform effects to return status codes when they fail. Finally,
delineate functions that need semantic analysis from those that do not.

Overall this should be NFC.
2020-08-27 16:15:44 -07:00
Artem Chikin
99938758f7 Merge pull request #33630 from artemcm/ScannerCanImport
[Explicit Module Builds] Handle #canImport in the dependency scanner by adding scanner "loaders" to the ASTContext.
2020-08-27 11:24:26 -07:00
Artem Chikin
78159c83f7 [Explicit Module Builds] Handle #canImport in the dependency scanner by adding scanner "loaders" to the ASTContext. 2020-08-25 14:20:38 -07:00
Brent Royal-Gordon
9bc787ef5f Add a “typecheck module interface” mode 2020-08-07 16:00:15 -07:00
Varun Gandhi
1ddf4ff790 [Gardening] Use consistent style for referencing notes. 2020-07-25 23:36:17 -07:00
Artem Chikin
140fd73f83 [Explicit Module Builds] Prevent SerializedModuleLoader from running in Explicit Module Build mode.
In order to avoid accidentally implicitly loading modules that are expected but were not provided as explicit inputs.

- Use either SerializedModuleLoader or ExplicitSwiftModuleLoader for loading of partial modules, depending on whether we are in Explicit Module Build or Implicit Module Build mode.
2020-07-22 09:00:40 -07:00
Hamish Knight
241c5d95e3 Merge pull request #32461 from hamishknight/its-all-linked 2020-07-08 11:07:17 -07:00
Hamish Knight
5792a72b95 Always link SIL for partial modules in SILGen
Previously we would only link `.sib` partial
modules in SILGen, with other kinds of serialized
ASTs being linked just before the SILOptimizer if
`-sil-merge-partial-modules` was specified.
However linking them always seems to be the desired
behaviour, so adjust SILGen to link SIL for all
serialized AST inputs.
2020-07-01 23:14:01 -07:00
Xi Ge
84dd4db0b1 Dependencies Scanner: report compiled Swift module paths if they are available
For the explicit module mode, swift-driver uses -compile-module-from-interface to
generate modules from interfaces found by the dependency scanner. However, we don't
need to build the binary module if up-to-date modules are available, either adjacent
to the interface file or in the prebuilt module cache directory. This patch teaches
dependencies scanner to report these ready-to-use binary modules.
2020-07-01 11:54:15 -07:00
David Zarzycki
9e85a396f6 Merge pull request #32630 from HassanElDesouky/LocaleFlagsRE
Reopen [Diag] Create frontend flags for localization
2020-07-01 05:58:50 -04:00
HassanElDesouky
063e92aa53 Create frontend flags for localization 2020-06-30 23:12:40 +02:00
Hamish Knight
7bc5440d17 [Frontend] Internalize createDependencyTracker
Expand the FrontendOptions to allow the enabling
of the dependency tracker for non-system
dependencies, and switch the previous clients of
`createDependencyTracker` over to using this
option. This ensures that the dependency tracker
is now set only during `CompilerInstance::setup`.
2020-06-29 15:26:26 -07:00
Hamish Knight
bddcda6333 [Frontend] Factor out setupDependencyTrackerIfNeeded
And call from `CompilerInstance::setup`.
2020-06-29 15:26:26 -07:00
Xi Ge
ec9cd91c1b ExplicitModuleLoader: take a JSON file that specifies details of explicit Swift modules
Instead of taking paths of Swift module files from front-end command line
arguments, we should take a JSON file specifying details of explicit modules.
The advantages is (1) .swiftdoc and .swiftsourceinfo can be associated
with a .swiftmodule file, and (2) module names are explicitly used as
keys in the JSON input so we don't need to eagerly deserialize a .swiftmodule
file to collect the module name.
2020-06-17 14:02:50 -07:00
Robert Widmann
057097a6c3 [NFC] Hide LoadedModules From Clients of ASTContext
There's no reason clients need to be able to access this data directly.
It obscures where module loading is actually happening, and makes it too
easy to accidentally register a module with the wrong identifier in the
context.

Hide the registration operations behind opaque accessors.
2020-06-16 15:09:19 -07:00
David Zarzycki
017ee7bf04 [SIL] NFC: Simplify SILVTable and save 8 bytes per SILVTable
We were not using the primary benefits of an intrusive list, namely the
ability to insert or remove from the middle of the list, so let's switch
to a plain vector. This also avoids linked-list pointer chasing.
2020-06-10 07:54:23 -04:00
Hamish Knight
55cf78b022 [Frontend] Inline performSemaUpTo
Now that it no longer needs to handle the
parse-only case, we can simplify things by having
`performSema` call into
`performParseAndResolveImportsOnly`.
2020-06-08 12:44:15 -07:00
Hamish Knight
1ed810653c [Frontend] Remove performParseOnly
Most clients were only using it to populate the
main module with files, which is now done by
`getMainModule`. Instead, they can now just rely
on parsing happening lazily.
2020-06-08 12:44:15 -07:00
Hamish Knight
7824dc1048 [Frontend] Move parse-only module load assert
Move into `performEndOfPipelineActions`, and move
the call up a bit in `performCompile` to make sure
it gets called even for a parse-only invocation.

Unfortunately this requires carving out an
exception for `-emit-imported-modules`, which can
load modules.
2020-06-08 12:44:15 -07:00
Hamish Knight
ff170df10c [Frontend] Populate files in getMainModule
Rather than waiting until one of the performXXX
methods are called, make sure all the main module's
files have been populated up-front by
`getMainModule`.
2020-06-08 12:44:14 -07:00
Hamish Knight
00dd637acc [Frontend] Factor out getSourceFileParsingOptions 2020-06-08 12:44:14 -07:00
Hamish Knight
5d72c464eb [Frontend] Remove parsing option params from performParseOnly
Lift the `DisablePoundIfEvaluation` parsing option
into `LangOptions` to subsume the need for the
`EvaluateConditionals` parameter, and sink the
computation of `CanDelayBodies` down into
`createSourceFileForMainModule`.
2020-06-08 12:44:13 -07:00
Hamish Knight
81483cc050 Merge pull request #32161 from hamishknight/pipeline-parse 2020-06-08 10:56:28 -07:00
Xi Ge
bd782be654 Front-end: add a new module loader that loads explicitly built Swift modules
To support -disable-implicit-swift-modules, the explicitly built modules
are passed down as compiler arguments. We need this new module loader to
handle these modules.

This patch also stops ModuleInterfaceLoader from building module from interface
when -disable-implicit-swift-modules is set.
2020-06-03 18:59:18 -07:00
Hamish Knight
60eae88fd1 Sink some parsing options into SourceFile::ParsingFlags
Sink the `BuildSyntaxTree` and
`CollectParsedTokens` bits into
`SourceFile::ParsingFlags`, with a static method
to get the parsing options from the lang opts.

Also add a parsing flag for enabling the interface
hash, which can be used instead of calling
`enableInterfaceHash`.
2020-06-03 11:03:55 -07:00