Commit Graph

123 Commits

Author SHA1 Message Date
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Artem Chikin
73b01dccfc Remove incremental builds from the Legacy driver
The C++-based driver is deprecated and this will help reduce the code surface that requires maintenance as the legacy driver is fully sunset.
2024-01-16 16:34:51 -08:00
Paolo Tranquilli
5b755228c3 Fix Compilation::Result constructor 2023-08-11 12:34:05 +02:00
Paolo Tranquilli
3b8597ca25 Merge branch 'main' into c++20-compatibility 2023-08-10 09:51:53 +02:00
Tony Allevato
79935f9720 Add explicit ctors for aggregation for types that default or delete ctors.
In C++20, types that declare or delete their default/copy/move constructors are no longer aggregates, so the aggregate uses of these types will not compile under C++20. Adding them fixes this, without affecting older language modes.
2023-08-02 14:22:32 -04:00
Paolo Tranquilli
e13a85c8f1 NFC: make headers compatible with C++20
In a downstream project we are using the Swift code as a library and
compiling with C++20. This mostly works except for two backward
incompatibilities introduced by C++20:

* [P1008] disallows aggregate initialization when defaulted or deleted
  constructors are specified. This lead to a compilation error for
  aggregate initialization of `swift::Compilation::Result`. The backward
  and forward compatible fix for that is to provide a constructor
  turning aggregate initializations into a normal constructor call.
* [P1185] introduces more candidates for overload resolution of
  comparison operator calls. As explained in [P1630], this leads in some
  cases to ambiguity compilation errors in C++20, which is exactly the
  case with `swift::ValueOwnershipKind`. The fix in this case is to
  remove some redundant operator calls conditionally on the
  `__cpp_impl_three_way_comparison` feature test macro, which [includes
  the papers mentioned above][feature_test].

[P1008]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1008r1.pdf
[P1185]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1185r2.html
[P1630]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1630r1.html
[feature_test]: https://en.cppreference.com/w/cpp/feature_test
2023-07-31 17:34:05 +02: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
Robert Widmann
d15bcc3670 Remove Argument Parsing For Source Ranges 2021-01-13 17:12:27 -08:00
Robert Widmann
35c45949a2 Remove IncrementalSchemeComparator 2021-01-13 16:49:19 -08:00
Robert Widmann
859b87fd8c Move The Last Pieces for Cross-Module Incremental Builds
We're going to play a dirty, dirty trick - but it'll make our users'
lives better in the end so stick with me here.

In order to build up an incremental compilation, we need two sources of
dependency information:

1) "Priors" - Swiftdeps with dependency information from the past
   build(s)
2) "Posteriors" - Swiftdeps with dependencies from after we rebuild the
   file or module or whatever

With normal swift files built in incremental mode, the priors are given by the
swiftdeps files which are generated parallel to a swift file and usually
placed in the build directory alongside the object files. Because we
have entries in the output file map, we can always know where these
swiftdeps files are. The priors are integrated by the driver and then
the build is scheduled. As the build runs and jobs complete, their
swiftdeps are reloaded and re-integrated. The resulting changes are then
traversed and more jobs are scheduled if necessary. These give us the
posteriors we desire.

A module flips this on its head. The swiftdeps information serialized
in a module functions as the *posterior* since the driver consuming the
module has no way of knowing how to rebuild the module, and because its
dependencies are, for all intents and purposes, fixed in time. The
missing piece of the puzzle is the priors. That is, we need some way of
knowing what the "past" interface of the module looked like so we can
compare it to the "present" interface. Moreover, we need to always know
where to look for these priors.

We solve this problem by serializing a file alongside the build record:
the "external" build record. This is given by a... creative encoding
of multiple source file dependency graphs into a single source file
dependency graph. The rough structure of this is:

   SourceFile => interface <BUILD_RECORD>.external
   | - Incremental External Dependency => interface <MODULE_1>.swiftmodule
   | | - <dependency> ...
   | | - <dependency> ...
   | | - <dependency> ...
   | - Incremental External Dependency => interface <MODULE_2>.swiftmodule
   | | - <dependency> ...
   | | - <dependency> ...
   | - Incremental External Dependency => interface <MODULE_3>.swiftmodule
   | - ...

Sorta, `cat`'ing a bunch of source file dependency graphs together but
with incremental external dependency nodes acting as glue.

Now for the trick:

We have to unpack this structure and integrate it to get our priors.
This is easy. The tricky bit comes in integrate itself. Because the
top-level source file node points directly at the external build record,
not the original swift modules that defined these dependency nodes, we
swap the key it wants to use (the external build record) for the
incremental external dependency acting as the "parent" of the dependency
node. We do this by following the arc we carefully laid down in the
structure above.

For rdar://69595010
Goes a long way towards rdar://48955139, rdar://64238133
2020-12-10 18:45:21 -08:00
Robert Widmann
905c3d8830 [Gardening] Document Compilation::Result 2020-12-09 19:28:50 -08:00
Robert Widmann
d4e76d0a47 [NFC] Use Result::code to Simplify Some Callsites 2020-12-09 19:28:50 -08:00
Robert Widmann
d4022929c1 [NFC] Mark Result as move-only
This required dropping some superfluous 'const' qualification in the module dependency graph.
2020-12-09 19:28:50 -08:00
Robert Widmann
3ecb0b0b06 [NFC] Move "HadAbnormalExit" Flag Into Compilation::Result 2020-12-09 19:25:56 -08:00
Robert Widmann
d815e2724a [NFC] Add Compilation::Result
In order to extract the module dependency graph from the compilation the driver just ran, define a separate semantic type to hold a result code and the graph itself.
2020-12-09 19:25:56 -08:00
Robert Widmann
b0f0587963 Keep a Cache of Externally-Dependent Jobs
A more durable form of #34218. Keep a side cache of externally-dependent
jobs for now. This ensures our pseudo-Jobs don't get prematurely
deallocated before the tracing machinery has had a chance to report the
structure of the Job graph.

rdar://70053563
2020-10-07 10:39:17 -07:00
Robert Widmann
964f640636 Drop "Private Deps" Flag
In order for type body fingerprints to work, these declarations must always be included. Drop the ability to turn this off.
2020-10-01 14:40:45 -07:00
Robert Widmann
74765a8ba8 Remove Type Body Fingerprints Flags
This infrastructure has more than proven itself. Drop the code paths and tests supporting the status quo.
2020-10-01 13:09:00 -07:00
Robert Widmann
48415ad228 [NFC] Stage in driver flags for experimental cross-module incremental builds 2020-09-24 17:10:57 -06:00
Robert Widmann
14188f4428 Remove ~moduleonly Duplicate of Compilation Record
We thought we would need this while exploring  certain pre-build optimizations a la rdar://problem/37725110. This information was never used.
2020-09-24 11:42:06 -06:00
Florian Friedrich
67073c7a67 Fix typo in comparison in comments and help text 2020-07-09 18:05:25 +02:00
Varun Gandhi
fea589e470 [NFC] Remove redundant includes for llvm/ADT/DenseSet.h. 2020-05-31 13:07:45 -07:00
Slava Pestov
368d47429d Frontend: Remove coarse-grained dependency graph implementation 2020-04-29 16:55:53 -04:00
David Ungar
d61f6f2f66 Changes to support per-type-body fingerprints. 2020-01-27 15:14:46 -08:00
David Ungar
98b86c63d1 Use the initial value of EnableFineGrainedDependencies as the default. 2020-01-23 12:12:17 -08:00
David Ungar
cbd458c968 Make tests more deterministic by sorting jobs before scheduling 2020-01-16 13:20:35 -08:00
David Ungar
cc89dad526 Fine-grained and driver fixes.
Restructure fine-grained-dependencies to enable unit testing

Get frontend to emit correct swiftdeps file (fine-grained when needed) and only emit dot file for -emit-fine-grained-dependency-sourcefile-dot-files

Use deterministic order for more information outputs.

Set EnableFineGrainedDependencies consistently in frontend.

Tolerate errors that result in null getExtendedNominal()

Fix memory issue by removing node everywhere.

Break up print routine

Be more verbose so it will compile on Linux.

Sort batchable jobs, too.
2020-01-11 21:57:14 -08:00
Saleem Abdulrasool
b483047afe Revert "[Incremental] Dependency fixes in preparation for fine-grained dependencies" 2020-01-09 19:14:47 -08:00
David Ungar
6fffe724f2 Fine-grained and driver fixes.
Restructure fine-grained-dependencies to enable unit testing

Get frontend to emit correct swiftdeps file (fine-grained when needed) and only emit dot file for -emit-fine-grained-dependency-sourcefile-dot-files

Use deterministic order for more information outputs.

Set EnableFineGrainedDependencies consistently in frontend.

Tolerate errors that result in null getExtendedNominal()

Fix memory issue by removing node everywhere.

Break up print routine

Be more verbose so it will compile on Linux.

Sort batchable jobs, too.
2020-01-04 14:37:06 -08:00
David Ungar
2a79331ac3 add -enable/disable-only-one-dependency-file flag, on by default 2019-12-18 16:07:51 -08:00
David Ungar
73a46ce57e Revert "[Incremental, Driver] Only emit a real make-style dependency file for one frontend job." 2019-12-12 22:26:25 -08:00
David Ungar
2fc0f7899c Fix comment for OnlyOneDependencyFile 2019-12-11 15:49:12 -08:00
David Ungar
46687189a7 -only-one-dependency-file causes only the first frontend job to emit a real dependency file. 2019-12-10 22:52:57 -08:00
David Ungar
6a6e9357ef Change "experimental" to "fine-grained". 2019-12-04 08:50:44 -08:00
David Ungar
3d3507b7b6 Remove unparsed ranges and use diffs to schedule dependents earlier. 2019-12-03 17:23:02 -08:00
David Ungar
3cba2306ca Moving tests and driver refactoring. 2019-12-03 09:24:17 -08:00
David Ungar
08cfe80061 Don't crash when asking for comparison but not incremental 2019-11-23 11:21:33 -08:00
David Ungar
468a23cef9 report stages unfmt 2019-11-20 13:28:19 -08:00
David Ungar
ae64f471cd Reporting refactoring 2019-11-19 16:42:21 -08:00
David Ungar
bc403424ee Use sets 2019-11-19 13:10:33 -08:00
David Ungar
ee17f61179 factor out comparator and report supp jobs 2019-11-19 12:22:04 -08:00
David Ungar
d2146d1c47 Report falling back differently. 2019-11-18 23:09:58 -08:00
David Ungar
38a6559aa9 Take path arg for comparo 2019-11-18 20:23:10 -08:00
David Ungar
3433bf8cef comparision WIP 2019-11-16 21:39:19 -08:00
David Ungar
52feb1391b Correct uninitialized flag bug. 2019-11-12 20:41:03 -08:00
David Ungar
742c3985bd Source-range-based dependencies
Frontend outputs source-as-compiled, and source-ranges file with function body ranges and ranges that were unparsed in secondaries.
Driver computes diffs for each source file. If diffs are in function bodies, only recompiles that one file. Else if diffs are in what another file did not parse, then the other file need not be rebuilt.
2019-11-12 20:41:02 -08:00
David Ungar
b82694c307 Format 2019-01-30 17:19:56 -08:00
David Ungar
2f65ac3735 Cosmetic cleanups 2019-01-30 17:16:49 -08:00