Skip to content

Commit 0a0d22a

Browse files
author
David Ungar
committed
fmt
1 parent edbbdb6 commit 0a0d22a

File tree

2 files changed

+58
-38
lines changed

2 files changed

+58
-38
lines changed

include/swift/Driver/DriverIncrementalRanges.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class SourceRangeBasedInfo {
109109
static bool shouldScheduleCompileJob(
110110
const llvm::StringMap<SourceRangeBasedInfo> &allInfos,
111111
const driver::Job *, function_ref<void(Twine)>);
112+
112113
private:
113114
static Optional<bool> isFileNewerThan(StringRef lhs, StringRef rhs,
114115
DiagnosticEngine&);

lib/Driver/Compilation.cpp

Lines changed: 57 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -875,42 +875,52 @@ namespace driver {
875875
void scheduleFirstRoundJobsForIncrementalCompilation(
876876
DependencyGraphT &DepGraph) {
877877

878-
llvm::SmallPtrSet<const Job*, 16> compileJobsToSchedule;
879-
for (const Job *Cmd: computeFirstRoundCompileJobsForIncrementalCompilation(DepGraph))
878+
llvm::SmallPtrSet<const Job *, 16> compileJobsToSchedule;
879+
for (const Job *Cmd :
880+
computeFirstRoundCompileJobsForIncrementalCompilation(DepGraph))
880881
compileJobsToSchedule.insert(Cmd);
881882
for (const Job *Cmd : Comp.getJobs()) {
882-
if (Cmd->getFirstSwiftPrimaryInput().empty() || compileJobsToSchedule.count(Cmd))
883+
if (Cmd->getFirstSwiftPrimaryInput().empty() ||
884+
compileJobsToSchedule.count(Cmd))
883885
scheduleCommandIfNecessaryAndPossible(Cmd);
884886
else
885887
DeferredCommands.insert(Cmd);
886888
}
887889
}
888890

889-
/// Figure out the best strategy and return those jobs. May return duplicates.
891+
/// Figure out the best strategy and return those jobs. May return
892+
/// duplicates.
890893
template <typename DependencyGraphT>
891-
llvm::SmallVector<const Job*, 16>
892-
computeFirstRoundCompileJobsForIncrementalCompilation(DependencyGraphT &DepGraph) {
894+
llvm::SmallVector<const Job *, 16>
895+
computeFirstRoundCompileJobsForIncrementalCompilation(
896+
DependencyGraphT &DepGraph) {
893897
auto compileJobsToScheduleViaDependencies =
894898
computeDependenciesAndGetNeededCompileJobs(DepGraph);
895899

896-
const bool mustConsultRanges = Comp.getEnableSourceRangeDependencies() || Comp.CompareIncrementalSchemes;
900+
const bool mustConsultRanges = Comp.getEnableSourceRangeDependencies() ||
901+
Comp.CompareIncrementalSchemes;
897902

898903
if (!mustConsultRanges)
899-
return compileJobsToScheduleViaDependencies;
904+
return compileJobsToScheduleViaDependencies;
900905

901906
auto jobs = computeRangesAndGetNeededCompileJobs(DepGraph);
902-
llvm::SmallVector<const Job *, 16> &compileJobsToScheduleViaSourceRanges = jobs.first;
903-
llvm::SmallVector<const Job *, 16> &jobsLackingSourceRangeSupplementaryOutputs = jobs.second;
907+
llvm::SmallVector<const Job *, 16> &compileJobsToScheduleViaSourceRanges =
908+
jobs.first;
909+
llvm::SmallVector<const Job *, 16>
910+
&jobsLackingSourceRangeSupplementaryOutputs = jobs.second;
904911

905-
const bool shouldFallBack = decideAndExplainWhetherToFallBackToDependencies(compileJobsToScheduleViaSourceRanges, jobsLackingSourceRangeSupplementaryOutputs);
912+
const bool shouldFallBack =
913+
decideAndExplainWhetherToFallBackToDependencies(
914+
compileJobsToScheduleViaSourceRanges,
915+
jobsLackingSourceRangeSupplementaryOutputs);
906916

907917
Comp.updateJobsForComparison(compileJobsToScheduleViaDependencies,
908918
compileJobsToScheduleViaSourceRanges);
909919
if (shouldFallBack)
910920
Comp.setFallingBackForComparison();
911921

912922
if (!Comp.getEnableSourceRangeDependencies())
913-
return compileJobsToScheduleViaDependencies;
923+
return compileJobsToScheduleViaDependencies;
914924

915925
Comp.setUseSourceRangeDependencies(!shouldFallBack);
916926

@@ -920,38 +930,45 @@ namespace driver {
920930
for (const Job *Cmd : jobsLackingSourceRangeSupplementaryOutputs)
921931
compileJobsToScheduleViaDependencies.push_back(Cmd);
922932
}
923-
return shouldFallBack ? compileJobsToScheduleViaDependencies : compileJobsToScheduleViaSourceRanges;
933+
return shouldFallBack ? compileJobsToScheduleViaDependencies
934+
: compileJobsToScheduleViaSourceRanges;
924935
}
925936

926-
bool decideAndExplainWhetherToFallBackToDependencies(llvm::SmallVector<const Job *, 16> &compileJobsToScheduleViaSourceRanges,
927-
const llvm::SmallVector<const Job *, 16> &jobsLackingSourceRangeSupplementaryOutputs) {
937+
bool decideAndExplainWhetherToFallBackToDependencies(
938+
llvm::SmallVector<const Job *, 16>
939+
&compileJobsToScheduleViaSourceRanges,
940+
const llvm::SmallVector<const Job *, 16>
941+
&jobsLackingSourceRangeSupplementaryOutputs) {
928942
if (!jobsLackingSourceRangeSupplementaryOutputs.empty()) {
929943
if (Comp.getShowIncrementalBuildDecisions()) {
930-
llvm::outs() << "Using dependencies: At least one input ('"
931-
<< llvm::sys::path::filename(jobsLackingSourceRangeSupplementaryOutputs.front()->getFirstSwiftPrimaryInput())
932-
<< "') lacks a supplementary output needed for the source "
933-
"range strategy.\n Maybe dependencies can do better than "
934-
"recompiling every file.\n";
944+
llvm::outs()
945+
<< "Using dependencies: At least one input ('"
946+
<< llvm::sys::path::filename(
947+
jobsLackingSourceRangeSupplementaryOutputs.front()
948+
->getFirstSwiftPrimaryInput())
949+
<< "') lacks a supplementary output needed for the source "
950+
"range strategy.\n Maybe dependencies can do better than "
951+
"recompiling every file.\n";
935952
}
936953
return true;
937-
}
954+
}
938955
// Unless the source-range scheme would compile every file,
939956
// it's likely a better bet.
940-
llvm::SmallPtrSet<const Job*, 16> uniqueJobs;
941-
for (const auto* J: compileJobsToScheduleViaSourceRanges)
957+
llvm::SmallPtrSet<const Job *, 16> uniqueJobs;
958+
for (const auto *J : compileJobsToScheduleViaSourceRanges)
942959
uniqueJobs.insert(J);
943960
if (uniqueJobs.size() < Comp.countSwiftInputs()) {
944961
if (Comp.getShowIncrementalBuildDecisions())
945962
llvm::outs() << "Using ranges\n";
946963
return false;
947964
}
948965
if (Comp.getShowIncrementalBuildDecisions())
949-
llvm::outs() << "Using dependencies: Range strategy would compile every input; dependencies cannot be "
950-
"any worse.";
966+
llvm::outs() << "Using dependencies: Range strategy would compile "
967+
"every input; dependencies cannot be "
968+
"any worse.";
951969
return true;
952970
}
953971

954-
955972
/// Return both the jobs to compile if using ranges, and also any jobs that
956973
/// must be compiled to use ranges in the future (because they were lacking
957974
/// supplementary output files). May include duplicates.
@@ -966,7 +983,7 @@ namespace driver {
966983
const bool dumpCompiledSourceDiffs =
967984
Comp.getArgs().hasArg(options::OPT_driver_dump_compiled_source_diffs);
968985

969-
const auto allSourceRangeInfo =
986+
const auto allSourceRangeInfo =
970987
incremental_ranges::SourceRangeBasedInfo::loadAllInfo(Comp);
971988

972989
incremental_ranges::SourceRangeBasedInfo::dumpAllInfo(
@@ -978,21 +995,21 @@ namespace driver {
978995
// load dependencies for external dependencies and interfacehashes
979996

980997
llvm::SmallVector<const Job *, 16> neededJobs;
981-
for (const Job *Cmd: Comp.getJobs()) {
982-
if ( SourceRangeBasedInfo::shouldScheduleCompileJob(
983-
allSourceRangeInfo, Cmd, [&](Twine why) { noteBuilding(Cmd, true, why.str()); }))
984-
neededJobs.push_back(Cmd);
998+
for (const Job *Cmd : Comp.getJobs()) {
999+
if (SourceRangeBasedInfo::shouldScheduleCompileJob(
1000+
allSourceRangeInfo, Cmd,
1001+
[&](Twine why) { noteBuilding(Cmd, true, why.str()); }))
1002+
neededJobs.push_back(Cmd);
9851003
}
9861004

9871005
llvm::SmallVector<const Job *, 16> jobsLackingSupplementaryOutputs;
988-
for (const Job* Cmd: Comp.getJobs()) {
1006+
for (const Job *Cmd : Comp.getJobs()) {
9891007
auto pri = Cmd->getFirstSwiftPrimaryInput();
9901008
if (pri.empty() || allSourceRangeInfo.count(pri))
9911009
continue;
992-
noteBuilding(
993-
Cmd,
994-
true,
995-
"to create source-range and compiled-source files for the next time when falling back from source-ranges");
1010+
noteBuilding(Cmd, true,
1011+
"to create source-range and compiled-source files for the "
1012+
"next time when falling back from source-ranges");
9961013
jobsLackingSupplementaryOutputs.push_back(Cmd);
9971014
}
9981015

@@ -1941,13 +1958,15 @@ void Compilation::printComparision() const {
19411958
if (!CompareIncrementalSchemes)
19421959
return;
19431960
if (!getIncrementalBuildEnabled())
1944-
llvm::outs() << "*** Comparing incremental strategies is moot: incremental compilation disabled ***\n";
1961+
llvm::outs() << "*** Comparing incremental strategies is moot: incremental "
1962+
"compilation disabled ***\n";
19451963
else if (SourceRangeCompileJobs)
19461964
llvm::outs() << "*** Comparing deps: " << DependencyCompileJobs.size()
19471965
<< ", ranges: " << SourceRangeCompileJobs->size()
19481966
<< ", total: " << countSwiftInputs() << " ***\n";
19491967
else
1950-
llvm::outs() << "*** Comparing incremental strategies is moot: would fall back and run "
1968+
llvm::outs() << "*** Comparing incremental strategies is moot: would fall "
1969+
"back and run "
19511970
<< DependencyCompileJobs.size()
19521971
<< ", total: " << countSwiftInputs() << " ***\n";
19531972
}

0 commit comments

Comments
 (0)