@@ -875,42 +875,52 @@ namespace driver {
875
875
void scheduleFirstRoundJobsForIncrementalCompilation (
876
876
DependencyGraphT &DepGraph) {
877
877
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))
880
881
compileJobsToSchedule.insert (Cmd);
881
882
for (const Job *Cmd : Comp.getJobs ()) {
882
- if (Cmd->getFirstSwiftPrimaryInput ().empty () || compileJobsToSchedule.count (Cmd))
883
+ if (Cmd->getFirstSwiftPrimaryInput ().empty () ||
884
+ compileJobsToSchedule.count (Cmd))
883
885
scheduleCommandIfNecessaryAndPossible (Cmd);
884
886
else
885
887
DeferredCommands.insert (Cmd);
886
888
}
887
889
}
888
890
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.
890
893
template <typename DependencyGraphT>
891
- llvm::SmallVector<const Job*, 16 >
892
- computeFirstRoundCompileJobsForIncrementalCompilation (DependencyGraphT &DepGraph) {
894
+ llvm::SmallVector<const Job *, 16 >
895
+ computeFirstRoundCompileJobsForIncrementalCompilation (
896
+ DependencyGraphT &DepGraph) {
893
897
auto compileJobsToScheduleViaDependencies =
894
898
computeDependenciesAndGetNeededCompileJobs (DepGraph);
895
899
896
- const bool mustConsultRanges = Comp.getEnableSourceRangeDependencies () || Comp.CompareIncrementalSchemes ;
900
+ const bool mustConsultRanges = Comp.getEnableSourceRangeDependencies () ||
901
+ Comp.CompareIncrementalSchemes ;
897
902
898
903
if (!mustConsultRanges)
899
- return compileJobsToScheduleViaDependencies;
904
+ return compileJobsToScheduleViaDependencies;
900
905
901
906
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 ;
904
911
905
- const bool shouldFallBack = decideAndExplainWhetherToFallBackToDependencies (compileJobsToScheduleViaSourceRanges, jobsLackingSourceRangeSupplementaryOutputs);
912
+ const bool shouldFallBack =
913
+ decideAndExplainWhetherToFallBackToDependencies (
914
+ compileJobsToScheduleViaSourceRanges,
915
+ jobsLackingSourceRangeSupplementaryOutputs);
906
916
907
917
Comp.updateJobsForComparison (compileJobsToScheduleViaDependencies,
908
918
compileJobsToScheduleViaSourceRanges);
909
919
if (shouldFallBack)
910
920
Comp.setFallingBackForComparison ();
911
921
912
922
if (!Comp.getEnableSourceRangeDependencies ())
913
- return compileJobsToScheduleViaDependencies;
923
+ return compileJobsToScheduleViaDependencies;
914
924
915
925
Comp.setUseSourceRangeDependencies (!shouldFallBack);
916
926
@@ -920,38 +930,45 @@ namespace driver {
920
930
for (const Job *Cmd : jobsLackingSourceRangeSupplementaryOutputs)
921
931
compileJobsToScheduleViaDependencies.push_back (Cmd);
922
932
}
923
- return shouldFallBack ? compileJobsToScheduleViaDependencies : compileJobsToScheduleViaSourceRanges;
933
+ return shouldFallBack ? compileJobsToScheduleViaDependencies
934
+ : compileJobsToScheduleViaSourceRanges;
924
935
}
925
936
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) {
928
942
if (!jobsLackingSourceRangeSupplementaryOutputs.empty ()) {
929
943
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 " ;
935
952
}
936
953
return true ;
937
- }
954
+ }
938
955
// Unless the source-range scheme would compile every file,
939
956
// 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)
942
959
uniqueJobs.insert (J);
943
960
if (uniqueJobs.size () < Comp.countSwiftInputs ()) {
944
961
if (Comp.getShowIncrementalBuildDecisions ())
945
962
llvm::outs () << " Using ranges\n " ;
946
963
return false ;
947
964
}
948
965
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." ;
951
969
return true ;
952
970
}
953
971
954
-
955
972
// / Return both the jobs to compile if using ranges, and also any jobs that
956
973
// / must be compiled to use ranges in the future (because they were lacking
957
974
// / supplementary output files). May include duplicates.
@@ -966,7 +983,7 @@ namespace driver {
966
983
const bool dumpCompiledSourceDiffs =
967
984
Comp.getArgs ().hasArg (options::OPT_driver_dump_compiled_source_diffs);
968
985
969
- const auto allSourceRangeInfo =
986
+ const auto allSourceRangeInfo =
970
987
incremental_ranges::SourceRangeBasedInfo::loadAllInfo (Comp);
971
988
972
989
incremental_ranges::SourceRangeBasedInfo::dumpAllInfo (
@@ -978,21 +995,21 @@ namespace driver {
978
995
// load dependencies for external dependencies and interfacehashes
979
996
980
997
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);
985
1003
}
986
1004
987
1005
llvm::SmallVector<const Job *, 16 > jobsLackingSupplementaryOutputs;
988
- for (const Job* Cmd: Comp.getJobs ()) {
1006
+ for (const Job * Cmd : Comp.getJobs ()) {
989
1007
auto pri = Cmd->getFirstSwiftPrimaryInput ();
990
1008
if (pri.empty () || allSourceRangeInfo.count (pri))
991
1009
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" );
996
1013
jobsLackingSupplementaryOutputs.push_back (Cmd);
997
1014
}
998
1015
@@ -1941,13 +1958,15 @@ void Compilation::printComparision() const {
1941
1958
if (!CompareIncrementalSchemes)
1942
1959
return ;
1943
1960
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 " ;
1945
1963
else if (SourceRangeCompileJobs)
1946
1964
llvm::outs () << " *** Comparing deps: " << DependencyCompileJobs.size ()
1947
1965
<< " , ranges: " << SourceRangeCompileJobs->size ()
1948
1966
<< " , total: " << countSwiftInputs () << " ***\n " ;
1949
1967
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 "
1951
1970
<< DependencyCompileJobs.size ()
1952
1971
<< " , total: " << countSwiftInputs () << " ***\n " ;
1953
1972
}
0 commit comments