Skip to content

Commit ee280e6

Browse files
authored
Merge pull request #34224 from CodaFi/radical-incrementalism
2 parents 7b64c07 + 8fbcdf3 commit ee280e6

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

include/swift/Driver/Action.h

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class JobAction : public Action {
127127
}
128128
};
129129

130-
class CompileJobAction : public JobAction {
130+
class IncrementalJobAction : public JobAction {
131131
public:
132132
struct InputInfo {
133133
enum Status {
@@ -136,6 +136,8 @@ class CompileJobAction : public JobAction {
136136
NeedsNonCascadingBuild,
137137
NewlyAdded
138138
};
139+
140+
public:
139141
Status status = UpToDate;
140142
llvm::sys::TimePoint<> previousModTime;
141143

@@ -153,18 +155,32 @@ class CompileJobAction : public JobAction {
153155
InputInfo inputInfo;
154156

155157
public:
156-
CompileJobAction(file_types::ID OutputType)
157-
: JobAction(Action::Kind::CompileJob, None, OutputType),
158-
inputInfo() {}
159-
160-
CompileJobAction(Action *Input, file_types::ID OutputType, InputInfo info)
161-
: JobAction(Action::Kind::CompileJob, Input, OutputType),
162-
inputInfo(info) {}
158+
IncrementalJobAction(Kind Kind, ArrayRef<const Action *> Inputs,
159+
file_types::ID Type, InputInfo info)
160+
: JobAction(Kind, Inputs, Type), inputInfo(info) {}
163161

162+
public:
164163
InputInfo getInputInfo() const {
165164
return inputInfo;
166165
}
167166

167+
public:
168+
static bool classof(const Action *A) {
169+
return A->getKind() == Action::Kind::CompileJob;
170+
}
171+
};
172+
173+
class CompileJobAction : public IncrementalJobAction {
174+
private:
175+
virtual void anchor() override;
176+
177+
public:
178+
CompileJobAction(file_types::ID OutputType)
179+
: IncrementalJobAction(Action::Kind::CompileJob, None, OutputType, {}) {}
180+
CompileJobAction(Action *Input, file_types::ID OutputType, InputInfo info)
181+
: IncrementalJobAction(Action::Kind::CompileJob, Input, OutputType,
182+
info) {}
183+
168184
static bool classof(const Action *A) {
169185
return A->getKind() == Action::Kind::CompileJob;
170186
}

lib/Driver/Action.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ void InputAction::anchor() {}
4343

4444
void JobAction::anchor() {}
4545

46+
void IncrementalJobAction::anchor() {}
47+
4648
void CompileJobAction::anchor() {}
4749

4850
void InterpretJobAction::anchor() {}

lib/Driver/Compilation.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ namespace driver {
860860
computeFirstRoundCompileJobsForIncrementalCompilation();
861861

862862
for (const Job *Cmd : Comp.getJobs()) {
863-
if (Cmd->getFirstSwiftPrimaryInput().empty() ||
863+
if (!isa<IncrementalJobAction>(Cmd->getSource()) ||
864864
compileJobsToSchedule.count(Cmd)) {
865865
scheduleCommandIfNecessaryAndPossible(Cmd);
866866
noteBuilding(Cmd, /*willBeBuilding*/ true, /*isTentative=*/false,
@@ -899,20 +899,22 @@ namespace driver {
899899
CommandSet
900900
computeDependenciesAndGetNeededCompileJobs(const bool forRanges) {
901901
auto getEveryCompileJob = [&] {
902-
CommandSet everyCompileJob;
902+
CommandSet everyIncrementalJob;
903903
for (const Job *Cmd : Comp.getJobs()) {
904-
if (!Cmd->getFirstSwiftPrimaryInput().empty())
905-
everyCompileJob.insert(Cmd);
904+
if (isa<IncrementalJobAction>(Cmd->getSource()))
905+
everyIncrementalJob.insert(Cmd);
906906
}
907-
return everyCompileJob;
907+
return everyIncrementalJob;
908908
};
909909

910910
CommandSet jobsToSchedule;
911911
CommandSet initialCascadingCommands;
912912
for (const Job *cmd : Comp.getJobs()) {
913-
const StringRef primary = cmd->getFirstSwiftPrimaryInput();
914-
if (primary.empty())
915-
continue; // not Compile
913+
// Skip jobs that have no associated incremental info.
914+
if (!isa<IncrementalJobAction>(cmd->getSource())) {
915+
continue;
916+
}
917+
916918
const Optional<std::pair<bool, bool>> shouldSchedAndIsCascading =
917919
computeShouldInitiallyScheduleJobAndDependendents(cmd, forRanges);
918920
if (!shouldSchedAndIsCascading)

0 commit comments

Comments
 (0)