Commit Graph

823 Commits

Author SHA1 Message Date
Zak Kent
17fedabb5e [Immediate] Implemented SwiftMaterializationUnit
Implemented SwiftMaterializationUnit, supporting
lazy compilation of individual Swift functions.
2023-08-14 13:28:22 -07:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Steven Wu
b78b569450 [CAS] Consolidate compile cache flags
Rename `-enable-cas` to `-compile-cache-job` to align with clang option
names and promote that to a new driver only flag.

Few other additions to driver flag for caching behaviors:
* `-compile-cache-remarks`: now cache hit/miss remarks are guarded behind
  this flag
* `-compile-cache-skip`: skip replaying from the cache. Useful as a
  debugging tool to do the compilation using CAS inputs even the output
  is a hit from the cache.
2023-06-26 10:34:27 -07:00
Steven Wu
47137709a4 [CAS] Virtualize TBD output
Virtualize TBD file output so we can check the output determinisim and
also be cached.
2023-06-12 13:22:10 -07:00
Steven Wu
8fb0d5f803 Virtualize swiftconstvalues output
Virtualize swiftconstvalues output so it can be cached inside CAS.
2023-06-12 13:22:10 -07:00
Steven Wu
daaee2705b Merge pull request #65924 from cachemeifyoucan/eng/PR-swift-cache-replay
[CAS] Teach swift-frontend to replay result from cache
2023-05-30 12:56:46 -07:00
Steven Wu
c2c24145bf Merge pull request #65925 from cachemeifyoucan/eng/PR-swift-frontend-tweaks-for-caching
Cleanup some redundant dependencies and unnecessary works that prevent compiler caching.
2023-05-23 15:32:05 -07:00
Steven Wu
16e4cfae76 [ObjcHeader] Fix objc header generation when pch is explicited passed
When swift-frontend is explicitly passed the pch file as bridging header
on command-line through `-import-objc-header`, it needs to print the
original source file name if needed to the generated objc header.

rdar://109411245
2023-05-17 14:15:55 -07:00
Steven Wu
8bd4ac8016 [CachedDiags] Don't cache diagnostics if command-line failed 2023-05-16 16:38:54 -07:00
Steven Wu
359c37eba7 [EmitPCH] Do not cache PCH in memory during emit-pch action
When pch are explicitly created, there is no need to cached produced pch
in memory since pch is only going to be consumed by a later process.
2023-05-16 16:38:54 -07:00
Steven Wu
371e3c9352 [CAS] Teach swift-frontend to replay result from cache 2023-05-15 13:42:15 -07:00
Steven Wu
c7d66b8845 Teach swift to compute cache key for compiler outputs
Teach swift how to serialize its input into CAS to create a cache key
for compiler outputs. To compute the cache key for the output, it first
needs to compute a base-key for the compiler invocation. The base key is
computed from: swift compiler version and the command-line arguments for
the invocation.

Each compiler output from swift will gets its own key. The key for the
output is computed from: the base key for the compiler invocation + the
primary input for the output + the output type.
2023-04-24 13:55:38 -07:00
Steven Wu
09b8af86fb Virtualize swift compiler outputs (#63206)
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
2023-04-05 23:34:37 +08:00
Ben Barham
8ce26c779e [Frontend] Remove reference to uninitialized ASTContext
Certain actions do not initialize `ASTContext`, eg.
`TypecheckModuleFromInterface`. But `performAction` was always grabbing
a `ASTContext&`. With `_GLIBCXX_ASSERTIONS` and
`_LIBCPP_ENABLE_ASSERTIONS` now enabled in an asserts build, this hits
an assert in `unique_ptr::operator*` that checks for a null deref.
2023-02-15 10:13:51 -08:00
Doug Gregor
db60d60eb7 Merge pull request #63318 from DougGregor/emit-macro-expansion-buffers-for-diags
[Macros] Emit macro expansion buffers for diagnostics.
2023-01-31 11:40:44 -08:00
Doug Gregor
8871129896 [Macros] Add frontend flag to dump macro expansions for diagnostics.
Add frontend flag `-emit-macro-expansion-files diagnostics` to emit any
macro expansion buffers referenced by diagnostics into files in a
temporary directory. This makes debugging type-checking failures in
macro expansions far easier, because you can see them after the
compiler process has exited.
2023-01-30 18:05:53 -08:00
zoecarver
306df1887d Revert "[cxx-interop] Fix crash when indexing with C++ interop enabled."
This reverts commit 883a9abf53.
2023-01-28 16:26:07 -08:00
Alexis Laferrière
010973c276 [Frontend|NFC] Rename ModuleInterfaceOptions::PrintPrivateInterfaceContent 2022-12-08 15:10:03 -08:00
Nuri Amari
cd4b9a6416 Add support for textual imports to -emit-objc-header
Currently headers produced with `-emit-objc-header` /
`-emit-objc-header-path` produce headers that include modular imports.
If the consumer wishes to operate without modules enabled, these headers
cannot be used. This patch introduces a new flag
(`-emit-clang-header-nonmodular-includes`) that when enabled
attempts to argument each modular import included in such a header with
a set of equivalent textual imports.
2022-12-03 13:07:39 -08:00
Evan Wilde
7c0c89546f Revert "Add support for textual imports to -emit-objc-header" 2022-12-02 15:02:19 -08:00
Nuri Amari
91fd5f80e0 Merge pull request #60971 from NuriAmari/textual-imports 2022-11-29 18:24:19 -08:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Nuri Amari
89a01dddfb Add support for textual imports to -emit-objc-header
Currently headers produced with `-emit-objc-header` /
`-emit-objc-header-path` produce headers that include modular imports.
If the consumer wishes to operate without modules enabled, these headers
cannot be used. This patch introduces a new flag
(`-emit-clang-header-nonmodular-includes`) that when enabled
attempts to argument each modular import included in such a header with
a set of equivalent textual imports.
2022-11-19 12:05:09 -08:00
Robert Widmann
37e7052c68 Remove -emit-syntax and -verify-syntax-tree 2022-11-16 15:07:48 -08:00
Alexis Laferrière
47b29b68db Merge pull request #61649 from xymus/index-swiftinterfaces
[Index] Force indexing of system modules to read only from swiftinterfaces
2022-10-31 14:18:45 -07:00
Alexis Laferrière
83cd432785 [Frontend] Intro global control to force loading from swiftinterface
Intro ASTContext::setIgnoreAdjacentModules to change module loading to
accept load only resilient modules from their swiftinterfaces, ignoring
the adjacent module and any silencing swiftinterfaces errors.
2022-10-31 10:58:54 -07:00
Allan Shortlidge
41269e6895 TBDGen: Merge TBDGen library into IRGen.
The relationship between the code in these two libraries was fundamentally circular, indicating that they should not have been split. With other changes that I'm making to remove circular dependencies from the CMake build graph I eventually uncovered that these two libraries were required to link each other circularly, but that had been hidden by other cycles in the build graph previously.
2022-10-27 11:28:02 -07:00
Anthony Latsis
18156d1177 Merge pull request #61347 from AnthonyLatsis/migrate-compiler-to-gh-issues
Gardening: Migrate compiler sources to GitHub issues
2022-09-30 10:48:52 +03:00
Anthony Latsis
2843e0c871 Gardening: Migrate compiler sources to GitHub issues 2022-09-29 23:58:55 +03:00
Alex Lorenz
c193a63fd4 [interop][SwiftToCxx] add -enable-experimental-cxx-interop-in-clang-header flag that lets you enable reverse interop only 2022-09-27 11:26:21 -07:00
Artem Chikin
aee45799b8 Invoke Explicit Interface Build when '-explicit-interface-module-build' is specified on a '-compile-module-from-interface' frontend action, using the CompilerInstance instantiated directly from the command-line in order to build the module. 2022-08-16 08:36:58 -07:00
Artem Chikin
7fd2a29fb7 Refactor 'ModuleInterfaceBuilder' to separate CompilerInstance setup logic from compilation logic (moved to ExplicitModuleInterfaceBuilder). 2022-08-16 08:36:55 -07:00
swift-ci
e6fb394cb5 Merge remote-tracking branch 'origin/main' into rebranch 2022-08-02 06:56:37 -07:00
Artem Chikin
6e7f3076b8 Add rudimentary emission of compile-time-known default-initialized property values of specific conformances. 2022-08-01 11:06:59 -07:00
swift-ci
b99996dbbd Merge remote-tracking branch 'origin/main' into rebranch 2022-07-21 13:37:34 -07:00
Artem Chikin
b1fee939f1 Add supplementary output path handling for extracted compile-time-known values 2022-07-19 16:24:26 -07:00
swift-ci
2487c19575 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-11 20:34:04 -07:00
Tony Allevato
4d16c43d21 Add -index-include-locals flag.
When this flag is passed, index store data emitted during a build
will also contain definitions/references for local symbols.
2022-07-11 14:08:07 -07:00
swift-ci
aab8da997e Merge remote-tracking branch 'origin/main' into rebranch 2022-06-29 16:34:49 -07:00
Allan Shortlidge
3308e4b38c NFC: Fix a few warnings emitted when building swift-frontend. 2022-06-29 12:09:42 -07:00
swift-ci
1ec185309f Merge remote-tracking branch 'origin/main' into rebranch 2022-06-24 00:14:42 -07:00
Erik Eckstein
ca291fb147 SIL: store IRGenOptions in SILModule
SIL optimization passes can use the IRGen options to do target specific optimizations.
2022-06-23 22:16:42 +02:00
swift-ci
7cb90dc351 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-10 15:33:41 -07:00
Arnold Schwaighofer
821ba47079 IRGen: Add a frontend option to force single LLVM module emission in multithreaded mode
This allows to experiment with single module LLVM emission without
having to change drivers that expect multiple output files.

rdar://94744623
2022-06-10 09:46:07 -07:00
swift-ci
797e0acecf Merge remote-tracking branch 'origin/main' into rebranch 2022-06-07 11:13:30 -07:00
Artem Chikin
11f24ca20d Merge pull request #59256 from artemcm/FrontendParseableUnknownExtensions
[Parseable Output] Generate valid output for files of unknown types
2022-06-07 10:57:41 -07:00
Artem Chikin
19c5c201dc [Parseable Output] Generate valid output for files of unknown types
When we encounter an input or output with an unknown extension 'TY_INVALID', still produce valid JSON specifying the type as "unknown" instead of either crashing or producing malformed JSON.

Resolves rdar://94348593
2022-06-03 11:40:32 -07:00
swift-ci
8866f0cf4f Merge remote-tracking branch 'origin/main' into rebranch 2022-06-03 09:53:40 -07:00
Ben Barham
15c0ce3545 Merge pull request #58932 from DavidGoldman/ignoreclangmoduleindexing
Add `-index-ignore-clang-modules` flag to prevent indexing Clang modules
2022-06-03 09:42:56 -07:00