[Driver] Refactor DependencyGraph in preparation for private dependencies.

- Give loadWithPath an enum result that includes "NeedsRebuilding".
  This will be returned when a new dependency is discovered that
  retroactively affects the graph.
- Don't clear the "provides" set for a node when it gets reloaded;
  just append to it. This lets us avoid calling markTransitive twice.
- Use proper types for "depends" and "provides" entries instead of std::pair.
- Use swift::OptionSet instead of a manual bitmask.
- Use separate "depends" and "provides" callbacks when parsing dependency
  files.

No expected functionality change.

Swift SVN r23851
This commit is contained in:
Jordan Rose
2014-12-11 01:11:57 +00:00
parent e423412131
commit e48245a715
3 changed files with 150 additions and 95 deletions

View File

@@ -131,10 +131,16 @@ int Compilation::performJobsInList(const JobList &JL, PerformJobsState &State) {
StringRef DependenciesFile =
Cmd->getOutput().getAdditionalOutputForType(types::TY_SwiftDeps);
if (!DependenciesFile.empty()) {
if (DepGraph.loadFromPath(Cmd, DependenciesFile))
switch (DepGraph.loadFromPath(Cmd, DependenciesFile)) {
case DependencyGraphImpl::LoadResult::HadError:
NeedToRunEverything = true;
else
break;
case DependencyGraphImpl::LoadResult::Valid:
Condition = Cmd->getCondition();
break;
case DependencyGraphImpl::LoadResult::NeedsRebuilding:
llvm_unreachable("we haven't marked anything in this graph yet");
}
}
switch (Condition) {
@@ -226,20 +232,25 @@ int Compilation::performJobsInList(const JobList &JL, PerformJobsState &State) {
Output.getAdditionalOutputForType(types::TY_SwiftDeps);
if (!DependenciesFile.empty()) {
SmallVector<const Job *, 16> Dependents;
DepGraph.markTransitive(Dependents, FinishedCmd);
if (DepGraph.loadFromPath(FinishedCmd, DependenciesFile)) {
switch (DepGraph.loadFromPath(FinishedCmd, DependenciesFile)) {
case DependencyGraphImpl::LoadResult::HadError:
NeedToRunEverything = true;
for (const Job *Cmd : DeferredCommands)
scheduleCommandIfNecessaryAndPossible(Cmd);
DeferredCommands.clear();
} else {
Dependents.clear();
break;
case DependencyGraphImpl::LoadResult::NeedsRebuilding:
llvm_unreachable("currently unused");
case DependencyGraphImpl::LoadResult::Valid:
DepGraph.markTransitive(Dependents, FinishedCmd);
for (const Job *Cmd : Dependents) {
DeferredCommands.erase(Cmd);
scheduleCommandIfNecessaryAndPossible(Cmd);
}
break;
}
for (const Job *Cmd : Dependents) {
DeferredCommands.erase(Cmd);
scheduleCommandIfNecessaryAndPossible(Cmd);
}
}
}