Commit Graph

40 Commits

Author SHA1 Message Date
Robert Widmann
ef7dfadb53 Register Dependency Arcs for Extension Members
This was a hole in the existing dependency tracking infrastructure. David managed to discover a way to exploit this bug to get a miscompile in rdar://74583179. There, members of extensions were not counted towards the interface hash of a type and so mutating them could lead to e.g. the wrong declaration being selected in an overload set.

To start tracking extensions, we need to add two new kinds of arcs:
1) A nominal arc to the extension
2) A member arc to the extension

Unfortunately, extensions are also unique in Swift in that they do not have a name to allow us to unique them. Luckily, we do have a way of identifying extensions: their fingerprint. These arcs are therefore emitted with the extended nominal type and the fingerprint of the extension as their context. This effectively invents a new nominal type for every extension.
2021-02-23 12:09:32 -08:00
Robert Widmann
d4673467af Switch the Subject of Dependency References to a DeclContext 2021-02-23 12:09:32 -08:00
Robert Widmann
59000e6ebe [NFC] Inline DependencyKey::createForProvidedEntityInterface 2021-02-23 12:09:32 -08:00
Robert Widmann
2b6d1a8f81 [NFC] Convert the Templates Computing DependencyKeys to the Builder Pattern
It can be quite difficult to tell at a glance just how any particular decl is going to be converted into a key. The space of available template specializations is also 2-dimensional which adds an additional level of difficulty when the time comes to extend or refactor any of them. Unroll all of the templates into a builder that coalesces the commonalities of the ways DependencyKeys are built to combat this.
2021-02-22 14:52:21 -08:00
Robert Widmann
764df6dc70 Fold Incremental External Dependency Nodes Into External Dependency Nodes
Remove this distinction without a difference. Originally, the thought
was to
1) Isolate the cross-module build infrastructure
2) Provide a signal to the driver that a dependency had swiftdeps info
   in it

But the driver need only notice swiftmodule files as external
dependencies and try to extract that information if it can to divine the
signal it needs. Additionally, we can give it fingerprints as priors to
let it know there might be incremental info to be had.
2021-02-03 11:46:04 -08:00
Robert Widmann
9141ddf3b2 Split External Dependency Enumeration from UsedDeclEnumerator 2021-02-02 09:59:26 -08:00
Robert Widmann
dab204e86e Plumb Module Fingerprints Into ModuleDepGraphFactory 2021-02-02 09:59:08 -08:00
Robert Widmann
903fd713b4 Don't Serialize dynamicLookup Dependencies in Modules
These are effectively uses from the perspective of a client module.
2020-12-10 18:31:04 -08:00
Robert Widmann
4804f03430 [NFC] Don't Store An llvm::function_ref
This class was relying on the caller to keep this member alive. In general, this will lead to startling memory ownership bugs if, say, the enumerators were returned from these functions. Pass it in as a parameter instead to formalize that contract.
2020-12-07 15:19:04 -08:00
Robert Widmann
030ed2a43b [NFC] Drop The Unused Interface Key From the Use Enumerator 2020-12-07 15:17:12 -08:00
Robert Widmann
d2a98f3b0f Address Review Comments 2020-11-18 17:12:09 -08:00
Robert Widmann
883902411b Migrate loadFingerprint onto ModuleDecl and Friends 2020-11-18 12:20:14 -08:00
Robert Widmann
912ed2711b [NFC] Use Fingerprints When Computing the Interface Hash 2020-11-18 12:20:14 -08:00
Robert Widmann
19e6bee374 [NFC] Use the Correct const-Qualification in Dependency Code
T *const does not prevent logically non-const accesses to the underlying data, it merely indicates that the pointer value itself is const. This modifier can be cast off by a copy, so it's not generally what you want here. Switch to const T * instead.
2020-11-12 10:57:56 -08:00
Robert Widmann
85947ca4d3 [NFC] Pull addAllDefinedDeclsOfAGivenType into its Base Class 2020-11-04 11:17:55 -08:00
Robert Widmann
c3881d9651 [NFC] Pull the Computation of Fingerprints Into the Common Base Class 2020-10-21 19:08:04 -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
e646ef2cbe Add incrementalExternalDepend as an Incremental NodeKind 2020-09-25 01:16:01 -06:00
Robert Widmann
044f85ad9c Add ModuleDepGraphFactory
This completes the missing piece from #34073 and means the frontend may now serialize moduledecl-based dependencies.
2020-09-24 23:27:11 -06:00
Robert Widmann
3c2b376aa2 [NFC] Refactor Reference Dependency Emission
Invert the responsibility of the entrypoint so that FrontendTool is directing the actual serialization work. The entrypoint now solely exists to construct a dependency graph.

While I'm here, prepare the way for serializing dependency graphs for modules by optimistically modeling a ModuleOrSourceFile input.
2020-09-24 20:07:02 -06:00
Robert Widmann
d2e7bdcfab Teach SwiftModules To Embed Incremental Information
Take advantage of the binary swiftdeps serialization utliities built during #32131. Add a new optional information block to swiftdeps files. For now, don't actually serialize swiftdeps information.

Frontends will use this information to determine whether to write incremental dependencies across modules into their swiftdeps files. We will then teach the driver to deserialize the data from this section and integrate it into its incremental decision making.
2020-09-24 20:07:01 -06:00
Robert Widmann
7c256f2f5a Generalize SourceFileDeclFinder
Strip mention of the SourceFile. Any FileUnit-esque thing that can provide top-level decls and `lookupClassMembers` works here - especially a ModuleDecl.
2020-09-24 11:33:15 -06:00
Robert Widmann
dd1ea9a237 [NFC] Privatize FrontendSourceFileDepGraphFactory.h 2020-09-24 11:19:53 -06:00
Robert Widmann
d57967569d Drop Interface Dependency Key APIs
Only external edges need this.
2020-09-21 14:47:39 -06:00
Robert Widmann
62555ec175 Drop Cascading Users from FrontendSourceFileDepGraphFactory's Modeling
The final set of edges that were being registered cascading were external edges. Just mark these all private - they're duplicated into the swiftdeps for each file that imports a given (usually clang) module anyways.
2020-09-21 14:11:20 -06:00
Robert Widmann
daeb081867 Remove appendHolderOfCascadingMembers 2020-09-21 10:42:33 -06:00
Robert Widmann
9e7964f4a5 Remove Reference::cascades 2020-09-21 10:37:42 -06:00
Slava Pestov
b873fe214e Code review feedback from Dave Ungar 2020-06-10 23:43:40 -04:00
Slava Pestov
d59a76c248 Dependencies: New binary format for fine-grained dependency graph 2020-06-10 15:40:55 -04:00
Robert Widmann
bf8d5412e0 Put UsedDeclEnumerator Back
This abstraction turns out to have hidden dependencies from the dependency verifier. Invert the dependency here and have it use the new enumerators in the DependencyRecorder instead.
2020-05-21 18:54:14 -07:00
Varun Gandhi
65577940d0 [NFC] Get rid of -Wrange-loop-analysis warnings. (#31324) 2020-04-27 09:47:52 -07:00
Anthony Latsis
74252028ca AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl 2020-04-23 05:16:55 +03:00
Robert Widmann
630d0f631a Merge pull request #30606 from AnthonyLatsis/rename-getfullname
[NFC] Preparations to address the «Rename to getName?» TODO on ValueDecl::getFullName
2020-04-01 09:00:04 -07:00
Robert Widmann
a337b67f69 Stage In Flags To Fall Back To Manual Tracking
Request-based incremental dependencies are enabled by default. For the time being, add a flag that will turn them off and switch back to manual dependency tracking.
2020-03-31 16:16:53 -07:00
Anthony Latsis
d0ae3ee580 [AST] Replace FuncDecl::getName & EnumElementDecl::getName with ValueDecl::getBaseIdentifier 2020-03-29 00:35:51 +03:00
David Ungar
85d70b59de Move use enumeration to ReferencedNameTracker 2020-03-02 14:39:47 -08:00
David Ungar
d5047ee208 Use isPrivateToEnclosingFile 2020-03-02 14:28:43 -08:00
David Ungar
72032493f9 Fix and test for extension body 2020-02-29 23:19:09 -08:00
David Ungar
0515e00616 Robert Widmann's .str() fixes 2020-02-19 23:58:36 -07:00
David Ungar
b367d2ebec Rename files and classes involved in SourceFileDepGraphConstruction 2020-02-19 23:57:23 -07:00