Skip to content

Commit 1687855

Browse files
authored
Merge pull request #34991 from CodaFi/depletion-layer
[Driver] A Pile of Nits
2 parents 88efaac + 2b2c5dc commit 1687855

File tree

5 files changed

+32
-59
lines changed

5 files changed

+32
-59
lines changed

include/swift/Driver/FineGrainedDependencyDriverGraph.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,12 @@ class ModuleDepGraph {
493493

494494
template <typename Nodes>
495495
std::vector<const driver::Job *>
496-
findJobsToRecompileWhenNodesChange(const Nodes &);
496+
findJobsToRecompileWhenNodesChange(const Nodes &nodes) {
497+
std::vector<ModuleDepGraphNode *> foundDependents;
498+
for (ModuleDepGraphNode *n : nodes)
499+
findPreviouslyUntracedDependents(foundDependents, n);
500+
return jobsContaining(foundDependents);
501+
}
497502

498503
private:
499504
std::vector<const driver::Job *>

lib/AST/FineGrainedDependencies.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@ void DepGraphNode::dump() const {
339339
void DepGraphNode::dump(raw_ostream &os) const {
340340
key.dump(os);
341341
if (fingerprint.hasValue())
342-
llvm::errs() << "fingerprint: " << fingerprint.getValue() << "";
342+
os << "fingerprint: " << fingerprint.getValue() << "";
343343
else
344-
llvm::errs() << "no fingerprint";
344+
os << "no fingerprint";
345345
}
346346

347347
void SourceFileDepGraphNode::dump() const {

lib/AST/FrontendSourceFileDepGraphFactory.cpp

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -406,26 +406,19 @@ class UsedDeclEnumerator {
406406
StringRef swiftDeps;
407407

408408
/// Cache these for efficiency
409-
const DependencyKey sourceFileInterface;
410409
const DependencyKey sourceFileImplementation;
411410

412-
function_ref<void(const DependencyKey &, const DependencyKey &)> createDefUse;
413-
414411
public:
415-
UsedDeclEnumerator(
416-
const SourceFile *SF, const DependencyTracker &depTracker,
417-
StringRef swiftDeps,
418-
function_ref<void(const DependencyKey &, const DependencyKey &)>
419-
createDefUse)
412+
UsedDeclEnumerator(const SourceFile *SF, const DependencyTracker &depTracker,
413+
StringRef swiftDeps)
420414
: SF(SF), depTracker(depTracker), swiftDeps(swiftDeps),
421-
sourceFileInterface(DependencyKey::createKeyForWholeSourceFile(
422-
DeclAspect::interface, swiftDeps)),
423415
sourceFileImplementation(DependencyKey::createKeyForWholeSourceFile(
424-
DeclAspect::implementation, swiftDeps)),
425-
createDefUse(createDefUse) {}
416+
DeclAspect::implementation, swiftDeps)) {}
426417

427418
public:
428-
void enumerateAllUses() {
419+
using UseEnumerator =
420+
llvm::function_ref<void(const DependencyKey &, const DependencyKey &)>;
421+
void enumerateAllUses(UseEnumerator enumerator) {
429422
auto &Ctx = SF->getASTContext();
430423
Ctx.evaluator.enumerateReferencesInFile(SF, [&](const auto &ref) {
431424
std::string name = ref.name.userFacingName().str();
@@ -437,36 +430,37 @@ class UsedDeclEnumerator {
437430
case Kind::Tombstone:
438431
llvm_unreachable("Cannot enumerate dead reference!");
439432
case Kind::TopLevel:
440-
return enumerateUse<NodeKind::topLevel>("", name);
433+
return enumerateUse<NodeKind::topLevel>("", name, enumerator);
441434
case Kind::Dynamic:
442-
return enumerateUse<NodeKind::dynamicLookup>("", name);
435+
return enumerateUse<NodeKind::dynamicLookup>("", name, enumerator);
443436
case Kind::PotentialMember: {
444437
std::string context = DependencyKey::computeContextForProvidedEntity<
445438
NodeKind::potentialMember>(nominal);
446-
return enumerateUse<NodeKind::potentialMember>(context, "");
439+
return enumerateUse<NodeKind::potentialMember>(context, "", enumerator);
447440
}
448441
case Kind::UsedMember: {
449442
std::string context =
450443
DependencyKey::computeContextForProvidedEntity<NodeKind::member>(
451444
nominal);
452-
return enumerateUse<NodeKind::member>(context, name);
445+
return enumerateUse<NodeKind::member>(context, name, enumerator);
453446
}
454447
}
455448
});
456-
enumerateExternalUses();
457-
enumerateNominalUses();
449+
enumerateExternalUses(enumerator);
450+
enumerateNominalUses(enumerator);
458451
}
459452

460453
private:
461454
template <NodeKind kind>
462-
void enumerateUse(StringRef context, StringRef name) {
455+
void enumerateUse(StringRef context, StringRef name,
456+
UseEnumerator createDefUse) {
463457
// Assume that what is depended-upon is the interface
464458
createDefUse(
465459
DependencyKey(kind, DeclAspect::interface, context.str(), name.str()),
466460
sourceFileImplementation);
467461
}
468462

469-
void enumerateNominalUses() {
463+
void enumerateNominalUses(UseEnumerator enumerator) {
470464
auto &Ctx = SF->getASTContext();
471465
Ctx.evaluator.enumerateReferencesInFile(SF, [&](const auto &ref) {
472466
const NominalTypeDecl *subject = ref.subject;
@@ -477,26 +471,26 @@ class UsedDeclEnumerator {
477471
std::string context =
478472
DependencyKey::computeContextForProvidedEntity<NodeKind::nominal>(
479473
subject);
480-
enumerateUse<NodeKind::nominal>(context, "");
474+
enumerateUse<NodeKind::nominal>(context, "", enumerator);
481475
});
482476
}
483477

484-
void enumerateExternalUses() {
478+
void enumerateExternalUses(UseEnumerator enumerator) {
485479
for (StringRef s : depTracker.getIncrementalDependencies())
486-
enumerateUse<NodeKind::incrementalExternalDepend>("", s);
480+
enumerateUse<NodeKind::incrementalExternalDepend>("", s, enumerator);
487481

488482
for (StringRef s : depTracker.getDependencies())
489-
enumerateUse<NodeKind::externalDepend>("", s);
483+
enumerateUse<NodeKind::externalDepend>("", s, enumerator);
490484
}
491485
};
492486
} // end namespace
493487

494488
void FrontendSourceFileDepGraphFactory::addAllUsedDecls() {
495-
UsedDeclEnumerator(SF, depTracker, swiftDeps,
496-
[&](const DependencyKey &def, const DependencyKey &use) {
497-
addAUsedDecl(def, use);
498-
})
499-
.enumerateAllUses();
489+
UsedDeclEnumerator(SF, depTracker, swiftDeps)
490+
.enumerateAllUses(
491+
[&](const DependencyKey &def, const DependencyKey &use) {
492+
addAUsedDecl(def, use);
493+
});
500494
}
501495

502496
//==============================================================================

lib/Driver/Compilation.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,6 @@ namespace driver {
488488
reloadAndRemarkDepsOnNormalExit(const Job *FinishedCmd,
489489
const bool cmdFailed, const bool forRanges,
490490
StringRef DependenciesFile) {
491-
return reloadAndRemarkFineGrainedDepsOnNormalExit(
492-
FinishedCmd, cmdFailed, forRanges, DependenciesFile);
493-
}
494-
495-
std::vector<const Job *> reloadAndRemarkFineGrainedDepsOnNormalExit(
496-
const Job *FinishedCmd, const bool cmdFailed, const bool forRanges,
497-
StringRef DependenciesFile) {
498491
const auto changedNodes = getFineGrainedDepGraph(forRanges).loadFromPath(
499492
FinishedCmd, DependenciesFile, Comp.getDiags());
500493
const bool loadFailed = !changedNodes;

lib/Driver/FineGrainedDependencyDriverGraph.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,25 +156,6 @@ std::vector<const Job *> ModuleDepGraph::findJobsToRecompileWhenWholeJobChanges(
156156
return findJobsToRecompileWhenNodesChange(allNodesInJob);
157157
}
158158

159-
template <typename Nodes>
160-
std::vector<const Job *>
161-
ModuleDepGraph::findJobsToRecompileWhenNodesChange(const Nodes &nodes) {
162-
std::vector<ModuleDepGraphNode *> foundDependents;
163-
for (ModuleDepGraphNode *n : nodes)
164-
findPreviouslyUntracedDependents(foundDependents, n);
165-
return jobsContaining(foundDependents);
166-
}
167-
168-
template std::vector<const Job *>
169-
ModuleDepGraph::findJobsToRecompileWhenNodesChange<
170-
std::unordered_set<ModuleDepGraphNode *>>(
171-
const std::unordered_set<ModuleDepGraphNode *> &);
172-
173-
template std::vector<const Job *>
174-
ModuleDepGraph::findJobsToRecompileWhenNodesChange<
175-
std::vector<ModuleDepGraphNode *>>(
176-
const std::vector<ModuleDepGraphNode *> &);
177-
178159
std::vector<std::string> ModuleDepGraph::computeSwiftDepsFromNodes(
179160
ArrayRef<const ModuleDepGraphNode *> nodes) const {
180161
llvm::StringSet<> swiftDepsOfNodes;

0 commit comments

Comments
 (0)