@@ -108,7 +108,6 @@ Compilation::Compilation(DiagnosticEngine &Diags,
108108 llvm::sys::TimePoint<> StartTime,
109109 llvm::sys::TimePoint<> LastBuildTime,
110110 size_t FilelistThreshold,
111- unsigned NumberOfParallelCommands,
112111 bool EnableIncrementalBuild,
113112 bool EnableBatchMode,
114113 unsigned BatchSeed,
@@ -127,7 +126,6 @@ Compilation::Compilation(DiagnosticEngine &Diags,
127126 ArgsHash(ArgsHash),
128127 BuildStartTime(StartTime),
129128 LastBuildTime(LastBuildTime),
130- NumberOfParallelCommands(NumberOfParallelCommands),
131129 SkipTaskExecution(SkipTaskExecution),
132130 EnableIncrementalBuild(EnableIncrementalBuild),
133131 OutputCompilationRecordForModuleOnlyBuild(
@@ -619,14 +617,9 @@ namespace driver {
619617 }
620618
621619 public:
622- PerformJobsState (Compilation &Comp)
623- : Comp(Comp),
624- ActualIncrementalTracer (Comp.Stats.get()) {
625- if (Comp.SkipTaskExecution )
626- TQ.reset (new DummyTaskQueue (Comp.NumberOfParallelCommands ));
627- else
628- TQ.reset (new TaskQueue (Comp.NumberOfParallelCommands ,
629- Comp.Stats .get ()));
620+ PerformJobsState (Compilation &Comp, std::unique_ptr<TaskQueue> &&TaskQueue)
621+ : Comp(Comp), ActualIncrementalTracer(Comp.Stats.get()),
622+ TQ (std::move(TaskQueue)) {
630623 if (Comp.ShowIncrementalBuildDecisions || Comp.Stats )
631624 IncrementalTracer = &ActualIncrementalTracer;
632625 }
@@ -889,7 +882,7 @@ namespace driver {
889882 return ;
890883 }
891884
892- size_t NumPartitions = Comp. NumberOfParallelCommands ;
885+ size_t NumPartitions = TQ-> getNumberOfParallelTasks () ;
893886 CommandSetVector Batchable, NonBatchable;
894887 std::vector<const Job *> Batches;
895888 bool PretendTheCommandLineIsTooLongOnce =
@@ -1220,8 +1213,9 @@ static bool writeFilelistIfNecessary(const Job *job, const ArgList &args,
12201213 return ok;
12211214}
12221215
1223- int Compilation::performJobsImpl (bool &abnormalExit) {
1224- PerformJobsState State (*this );
1216+ int Compilation::performJobsImpl (bool &abnormalExit,
1217+ std::unique_ptr<TaskQueue> &&TQ) {
1218+ PerformJobsState State (*this , std::move (TQ));
12251219
12261220 State.scheduleInitialJobs ();
12271221 State.scheduleAdditionalJobs ();
@@ -1320,7 +1314,7 @@ static bool writeAllSourcesFile(DiagnosticEngine &diags, StringRef path,
13201314 return true ;
13211315}
13221316
1323- int Compilation::performJobs () {
1317+ int Compilation::performJobs (std::unique_ptr<TaskQueue> &&TQ ) {
13241318 if (AllSourceFilesPath)
13251319 if (!writeAllSourcesFile (Diags, AllSourceFilesPath, getInputFiles ()))
13261320 return EXIT_FAILURE;
@@ -1334,12 +1328,12 @@ int Compilation::performJobs() {
13341328 return performSingleCommand (Jobs.front ().get ());
13351329 }
13361330
1337- if (!TaskQueue::supportsParallelExecution () && NumberOfParallelCommands > 1 ) {
1331+ if (!TaskQueue::supportsParallelExecution () && TQ-> getNumberOfParallelTasks () > 1 ) {
13381332 Diags.diagnose (SourceLoc (), diag::warning_parallel_execution_not_supported);
13391333 }
13401334
13411335 bool abnormalExit;
1342- int result = performJobsImpl (abnormalExit);
1336+ int result = performJobsImpl (abnormalExit, std::move (TQ) );
13431337
13441338 if (!SaveTemps) {
13451339 for (const auto &pathPair : TempFilePaths) {
0 commit comments