@@ -164,10 +164,12 @@ class ModuleDepGraph {
164
164
std::unordered_set<std::string> externalDependencies;
165
165
166
166
// / The new version of "Marked."
167
- // / Aka "isMarked". Holds the swiftDeps paths for jobs the driver has or will
168
- // / schedule.
169
- // / TODO: Move scheduledJobs out of the graph, ultimately.
170
- std::unordered_set<std::string> swiftDepsOfJobsThatNeedRunning;
167
+ // / Aka "isMarked".
168
+ // / If job is in here, all of its dependent jobs have already been searched
169
+ // / for jobs that depend on them, OR the job is about to be scheduled and
170
+ // / we'll need to run all dependent jobs after it completes. (See the call to
171
+ // / \c markIntransitive in \c shouldScheduleCompileJobAccordingToCondition.)
172
+ std::unordered_set<std::string> swiftDepsOfMarkedJobs;
171
173
172
174
// / Keyed by swiftdeps filename, so we can get back to Jobs.
173
175
std::unordered_map<std::string, const driver::Job *> jobsBySwiftDeps;
@@ -307,6 +309,10 @@ class ModuleDepGraph {
307
309
// / For the dot file.
308
310
std::string getGraphID () const { return " driver" ; }
309
311
312
+ void forCorrespondingImplementationOfProvidedInterface (
313
+ const ModuleDepGraphNode *,
314
+ function_ref<void (ModuleDepGraphNode *)>) const ;
315
+
310
316
void forEachUseOf (const ModuleDepGraphNode *def,
311
317
function_ref<void (const ModuleDepGraphNode *use)>);
312
318
@@ -326,6 +332,8 @@ class ModuleDepGraph {
326
332
// / Interface to status quo code in the driver.
327
333
bool isMarked (const driver::Job *) const ;
328
334
335
+ bool isSwiftDepsMarked (StringRef swiftDeps) const ;
336
+
329
337
// / Given a "cascading" job, that is a job whose dependents must be recompiled
330
338
// / when this job is recompiled, Compute two sets of jobs:
331
339
// / 1. Return value (via visited) is the set of jobs needing recompilation
@@ -334,9 +342,9 @@ class ModuleDepGraph {
334
342
// / are recompiled. Such jobs are added to the \ref scheduledJobs set, and
335
343
// / accessed via \ref isMarked.
336
344
// /
337
- // / Only return jobs marked that were previously unmarked. Not required for
338
- // / the driver because it won't run a job twice, but required for the unit
339
- // / test .
345
+ // / Returns jobs to be run because of changes to any/ever node in the
346
+ // / argument. Only return jobs marked that were previously unmarked, assuming
347
+ // / previously marked jobs are already scheduled .
340
348
std::vector<const driver::Job*> markTransitive (
341
349
const driver::Job *jobToBeRecompiled, const void *ignored = nullptr );
342
350
@@ -413,7 +421,7 @@ class ModuleDepGraph {
413
421
// / Integrate a SourceFileDepGraph into the receiver.
414
422
// / Integration happens when the driver needs to read SourceFileDepGraph.
415
423
CoarseGrainedDependencyGraphImpl::LoadResult
416
- integrate (const SourceFileDepGraph &);
424
+ integrate (const SourceFileDepGraph &, StringRef swiftDepsOfJob );
417
425
418
426
enum class LocationOfPreexistingNode { nowhere, here, elsewhere };
419
427
@@ -431,7 +439,8 @@ class ModuleDepGraph {
431
439
bool
432
440
integrateSourceFileDepGraphNode (const SourceFileDepGraph &g,
433
441
const SourceFileDepGraphNode *integrand,
434
- const PreexistingNodeIfAny preexistingMatch);
442
+ const PreexistingNodeIfAny preexistingMatch,
443
+ StringRef swiftDepsOfJob);
435
444
436
445
// / Integrate the \p integrand, a node that represents a Decl in the swiftDeps
437
446
// / file being integrated. \p preexistingNodeInPlace holds the node
@@ -442,7 +451,7 @@ class ModuleDepGraph {
442
451
// / ModuleDepGraphNode.
443
452
std::pair<bool , ModuleDepGraphNode *>
444
453
integrateSourceFileDeclNode (const SourceFileDepGraphNode *integrand,
445
- StringRef swiftDepsOfSourceFileGraph ,
454
+ StringRef swiftDepsOfJob ,
446
455
const PreexistingNodeIfAny preexistingMatch);
447
456
448
457
// / Create a brand-new ModuleDepGraphNode to integrate \p integrand.
@@ -463,14 +472,25 @@ class ModuleDepGraph {
463
472
// / Given a definition node, and a list of already found dependents,
464
473
// / recursively add transitive closure of dependents of the definition
465
474
// / into the already found dependents.
475
+ // /
476
+ // / \param foundDependents gets filled out with all dependent nodes found
477
+ // / \param definition the starting definition
478
+ // / \param shouldConsiderUse returns true if a use should be considered
466
479
void findDependentNodes (
467
480
std::unordered_set<const ModuleDepGraphNode *> &foundDependents,
468
- const ModuleDepGraphNode *definition);
481
+ const ModuleDepGraphNode *definition,
482
+ function_ref<bool (const ModuleDepGraphNode *use)> shouldConsiderUse);
469
483
470
484
// / Givien a set of nodes, return the set of swiftDeps for the jobs those
471
485
// / nodes are in.
472
- llvm::StringSet<> computeSwiftDepsFromInterfaceNodes (
473
- ArrayRef<const ModuleDepGraphNode *> nodes);
486
+ std::vector<std::string>
487
+ computeSwiftDepsFromNodes (ArrayRef<const ModuleDepGraphNode *> nodes) const ;
488
+
489
+ std::vector<const driver::Job *>
490
+ getUnmarkedJobsFrom (const ArrayRef<const ModuleDepGraphNode *> nodes) const ;
491
+
492
+ // / Mark any jobs for these nodes
493
+ void markJobsFrom (ArrayRef<const ModuleDepGraphNode *>);
474
494
475
495
// / Record a visit to this node for later dependency printing
476
496
size_t traceArrival (const ModuleDepGraphNode *visitedNode);
@@ -483,8 +503,8 @@ class ModuleDepGraph {
483
503
const driver::Job *dependentJob);
484
504
485
505
// / Return true if job was not scheduled before
486
- bool recordJobNeedsRunning (StringRef swiftDeps) {
487
- return swiftDepsOfJobsThatNeedRunning .insert (swiftDeps).second ;
506
+ bool markJobViaSwiftDeps (StringRef swiftDeps) {
507
+ return swiftDepsOfMarkedJobs .insert (swiftDeps).second ;
488
508
}
489
509
490
510
// / For debugging and visualization, write out the graph to a dot file.
0 commit comments