Skip to content

Commit 6f65e0e

Browse files
author
David Ungar
committed
Change unfinished handling
1 parent 021a40a commit 6f65e0e

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

lib/Driver/Compilation.cpp

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,20 +1571,46 @@ namespace driver {
15711571
if (!ScheduledCommands.count(Cmd))
15721572
continue;
15731573

1574-
// Be conservative, in case we use ranges this time but not next.
1575-
bool mightBeCascading = true;
1576-
if (Comp.getIncrementalBuildEnabled()) {
1577-
const bool forRanges = Comp.getEnableSourceRangeDependencies();
1578-
mightBeCascading = Comp.getEnableFineGrainedDependencies()
1579-
? getFineGrainedDepGraph(forRanges)
1580-
.haveAnyNodesBeenTraversedIn(Cmd)
1581-
: getDepGraph(forRanges).isMarked(Cmd);
1582-
}
1583-
UnfinishedCommands.insert({Cmd, mightBeCascading});
1574+
const bool needsCascadingBuild =
1575+
computeNeedsCascadingBuildForUnfinishedCommand(Cmd);
1576+
UnfinishedCommands.insert({Cmd, needsCascadingBuild});
15841577
}
15851578
}
15861579
}
15871580

1581+
/// When the driver next runs, it will read the build record, and the
1582+
/// unfinished job status will be set to either \c NeedsCascading... or
1583+
/// \c NeedsNonCascading...
1584+
/// Decide which it will be.
1585+
/// As far as I can tell, the only difference the result of this function
1586+
/// makes is how soon
1587+
/// required dependents are recompiled. Here's my reasoning:
1588+
///
1589+
/// When the driver next runs, the condition will be filtered through
1590+
/// \c loadDependenciesAndComputeCondition .
1591+
/// Then, the cascading predicate is returned from
1592+
/// \c isCompileJobInitiallyNeededForDependencyBasedIncrementalCompilation
1593+
/// and \c computeShouldInitiallyScheduleJobAndDependendents Then, in \c
1594+
/// computeDependenciesAndGetNeededCompileJobs if the job needs a cascading
1595+
/// build, it's dependents will be scheduled immediately.
1596+
/// After the job finishes, it's dependencies will be processed again.
1597+
/// If a non-cascading job failed, the driver will schedule all of its
1598+
/// dependents. (All of its dependents are assumed to have already been
1599+
/// scheduled.) If the job succeeds, the revised dependencies are consulted
1600+
/// to schedule any needed jobs.
1601+
1602+
bool computeNeedsCascadingBuildForUnfinishedCommand(const Job *Cmd) {
1603+
if (!Comp.getIncrementalBuildEnabled())
1604+
return true;
1605+
const bool forRanges = Comp.getEnableSourceRangeDependencies();
1606+
if (!Comp.getEnableFineGrainedDependencies()) {
1607+
// Mysterious legacy code
1608+
return getDepGraph(forRanges).isMarked(Cmd);
1609+
}
1610+
// See the comment on the whole function above
1611+
return false;
1612+
}
1613+
15881614
public:
15891615
void populateInputInfoMap(InputInfoMap &inputs) const {
15901616
for (auto &entry : UnfinishedCommands) {

0 commit comments

Comments
 (0)