Skip to content

Commit 6823b93

Browse files
author
David Ungar
committed
Improvements thanks to Jordan’s feedback.
1 parent 4c61354 commit 6823b93

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

include/swift/Driver/DependencyGraph.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ class DependencyGraphImpl {
127127
/// In other words, this Job "cascades"; the need to recompile it causes other
128128
/// recompilations. It is possible that the current code marks things that do
129129
/// not need to be marked. Nothing would break if that were the case.
130-
///
131-
/// "Marked" does NOT mean that any successors in the graph have been
132-
/// processed. The traversal routines use "Visited" to avoid endless
133-
/// "recursion".
130+
134131
llvm::SmallPtrSet<const void *, 16> Marked;
135132

136133
/// A list of all external dependencies that cannot be resolved from just this
@@ -163,11 +160,7 @@ class DependencyGraphImpl {
163160
(void)newlyInserted;
164161
}
165162

166-
/// Starting at \p node, visit the transitive closure of every dependent node.
167-
/// Assume that the starting node is "cascading"; that all dependencies must
168-
/// be dirty if the start is dirty. Therefore, mark the start. For each
169-
/// visited node, add it to visited, and mark it if it cascades. The start
170-
/// node is NOT added to visited.
163+
/// See DependencyGraph::markTransitive.
171164

172165
void markTransitive(SmallVectorImpl<const void *> &visited,
173166
const void *node, MarkTracerImpl *tracer = nullptr);
@@ -280,6 +273,15 @@ class DependencyGraph : public DependencyGraphImpl {
280273
///
281274
/// If you want to see how each node gets added to \p visited, pass a local
282275
/// MarkTracer instance to \p tracer.
276+
///
277+
/// Assumes that the starting node is "cascading"; that all dependencies must
278+
/// be dirty if the start is dirty. Therefore, mark the start. For each
279+
/// visited node, add it to visited, and mark it if it cascades. The start
280+
/// node is NOT added to visited.
281+
///
282+
/// Do not confused "Marked" with "Visited".
283+
/// "Marked" does NOT influence the traversal. The traversal routines use
284+
/// "Visited" to avoid endless "recursion".
283285
template <unsigned N>
284286
void markTransitive(SmallVector<T, N> &visited, T node,
285287
MarkTracer *tracer = nullptr) {

include/swift/Driver/Job.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,20 @@ class CommandOutput {
230230
class Job {
231231
public:
232232
enum class Condition {
233-
// There was no input map, or the map makred this Job as dirty
233+
// There was no information about the previous build (i.e., an input map),
234+
// or the map marked this Job as dirty
234235
// but the input didn't change.
235236
// Be maximally conservative with dependencies.
236237
Always,
237-
// The input changed, or this job was private or [it was not dirty but
238+
// The input changed, or this job was non-cascading or [it was not dirty but
238239
// primary output was missing].
240+
// In other words, this job was scheduled as non-cascading in the last build
241+
// but didn't get to run.
239242
RunWithoutCascading,
240243
// The best case: input didn't change, output exists.
241244
// Only run if it depends on some other thing that changed.
242245
CheckDependencies,
243-
// Pessimal: run no matter what.
246+
// Pessimal: Run no matter what (but may or may not cascade).
244247
NewlyAdded
245248
};
246249

lib/Driver/Compilation.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,11 +680,6 @@ namespace driver {
680680
}
681681

682682
/// Schedule all jobs we can from the initial list provided by Compilation.
683-
///
684-
/// It would probably be safe and simpler to markTransitive on the start
685-
/// nodes in the "Always" condition from the start instead of using
686-
/// markIntransitive and having later functions call markTransitive. That
687-
/// way markInstransitive would be an implemenation detail.
688683
void scheduleInitialJobs() {
689684
for (const Job *Cmd : Comp.getJobs()) {
690685
if (!Comp.getIncrementalBuildEnabled()) {
@@ -724,6 +719,12 @@ namespace driver {
724719
// Ensure dependents will get recompiled.
725720
InitialOutOfDateCommands.push_back(Cmd);
726721
// Mark this job as cascading.
722+
//
723+
// It would probably be safe and simpler to markTransitive on the
724+
// start nodes in the "Always" condition from the start instead of
725+
// using markIntransitive and having later functions call
726+
// markTransitive. That way markInstransitive would be an
727+
// implementation detail.
727728
DepGraph.markIntransitive(Cmd);
728729
}
729730
LLVM_FALLTHROUGH;

0 commit comments

Comments
 (0)