@@ -231,7 +231,7 @@ namespace driver {
231
231
DriverTimers;
232
232
233
233
void noteBuilding (const Job *cmd, StringRef reason) {
234
- if (!Comp.ShowIncrementalBuildDecisions )
234
+ if (!Comp.getShowIncrementalBuildDecisions () )
235
235
return ;
236
236
if (ScheduledCommands.count (cmd))
237
237
return ;
@@ -254,15 +254,15 @@ namespace driver {
254
254
// / its inputs are in FinishedCommands.
255
255
void scheduleCommandIfNecessaryAndPossible (const Job *Cmd) {
256
256
if (ScheduledCommands.count (Cmd)) {
257
- if (Comp.ShowJobLifecycle ) {
257
+ if (Comp.getShowJobLifecycle () ) {
258
258
llvm::outs () << " Already scheduled: " << LogJob (Cmd) << " \n " ;
259
259
}
260
260
return ;
261
261
}
262
262
263
263
if (auto Blocking = findUnfinishedJob (Cmd->getInputs ())) {
264
264
BlockingCommands[Blocking].push_back (Cmd);
265
- if (Comp.ShowJobLifecycle ) {
265
+ if (Comp.getShowJobLifecycle () ) {
266
266
llvm::outs () << " Blocked by: " << LogJob (Blocking)
267
267
<< " , now blocking jobs: "
268
268
<< LogJobArray (BlockingCommands[Blocking]) << " \n " ;
@@ -283,28 +283,28 @@ namespace driver {
283
283
void addPendingJobToTaskQueue (const Job *Cmd) {
284
284
// FIXME: Failing here should not take down the whole process.
285
285
bool success =
286
- writeFilelistIfNecessary (Cmd, * Comp.TranslatedArgs . get (), Comp.Diags );
286
+ writeFilelistIfNecessary (Cmd, Comp.getArgs (), Comp.getDiags () );
287
287
assert (success && " failed to write filelist" );
288
288
(void )success;
289
289
290
290
assert (Cmd->getExtraEnvironment ().empty () &&
291
291
" not implemented for compilations with multiple jobs" );
292
- if (Comp.ShowJobLifecycle )
292
+ if (Comp.getShowJobLifecycle () )
293
293
llvm::outs () << " Added to TaskQueue: " << LogJob (Cmd) << " \n " ;
294
294
TQ->addTask (Cmd->getExecutable (), Cmd->getArgumentsForTaskExecution (),
295
295
llvm::None, (void *)Cmd);
296
296
}
297
297
298
298
// / When a task finishes, check other Jobs that may be blocked.
299
299
void markFinished (const Job *Cmd, bool Skipped=false ) {
300
- if (Comp.ShowJobLifecycle ) {
300
+ if (Comp.getShowJobLifecycle () ) {
301
301
llvm::outs () << " Job "
302
302
<< (Skipped ? " skipped" : " finished" )
303
303
<< " : " << LogJob (Cmd) << " \n " ;
304
304
}
305
305
FinishedCommands.insert (Cmd);
306
- if (Comp.Stats ) {
307
- auto &D = Comp. Stats ->getDriverCounters ();
306
+ if (auto *Stats = Comp.getStatsReporter () ) {
307
+ auto &D = Stats->getDriverCounters ();
308
308
if (Skipped)
309
309
D.NumDriverJobsSkipped ++;
310
310
else
@@ -313,7 +313,7 @@ namespace driver {
313
313
auto BlockedIter = BlockingCommands.find (Cmd);
314
314
if (BlockedIter != BlockingCommands.end ()) {
315
315
auto AllBlocked = std::move (BlockedIter->second );
316
- if (Comp.ShowJobLifecycle ) {
316
+ if (Comp.getShowJobLifecycle () ) {
317
317
llvm::outs () << " Scheduling maybe-unblocked jobs: "
318
318
<< LogJobArray (AllBlocked) << " \n " ;
319
319
}
@@ -333,7 +333,7 @@ namespace driver {
333
333
// TODO: properly handle task began.
334
334
const Job *BeganCmd = (const Job *)Context;
335
335
336
- if (Comp.ShowDriverTimeCompilation ) {
336
+ if (Comp.getShowDriverTimeCompilation () ) {
337
337
llvm::SmallString<128 > TimerName;
338
338
llvm::raw_svector_ostream OS (TimerName);
339
339
OS << LogJob (BeganCmd);
@@ -345,7 +345,7 @@ namespace driver {
345
345
DriverTimers[BeganCmd]->startTimer ();
346
346
}
347
347
348
- switch (Comp.Level ) {
348
+ switch (Comp.getOutputLevel () ) {
349
349
case OutputLevel::Normal:
350
350
break ;
351
351
// For command line or verbose output, print out each command as it
@@ -369,10 +369,10 @@ namespace driver {
369
369
// / disable incremental logic and schedule all existing deferred commands.
370
370
void
371
371
dependencyLoadFailed (StringRef DependenciesFile, bool Warn=true ) {
372
- if (Warn && Comp.ShowIncrementalBuildDecisions )
373
- Comp.Diags .diagnose (SourceLoc (),
374
- diag::warn_unable_to_load_dependencies,
375
- DependenciesFile);
372
+ if (Warn && Comp.getShowIncrementalBuildDecisions () )
373
+ Comp.getDiags () .diagnose (SourceLoc (),
374
+ diag::warn_unable_to_load_dependencies,
375
+ DependenciesFile);
376
376
Comp.disableIncrementalBuild ();
377
377
for (const Job *Cmd : DeferredCommands)
378
378
scheduleCommandIfNecessaryAndPossible (Cmd);
@@ -497,11 +497,11 @@ namespace driver {
497
497
TaskFinishedResponse
498
498
unpackAndFinishBatch (int ReturnCode, StringRef Output,
499
499
StringRef Errors, const BatchJob *B) {
500
- if (Comp.ShowJobLifecycle )
500
+ if (Comp.getShowJobLifecycle () )
501
501
llvm::outs () << " Batch job finished: " << LogJob (B) << " \n " ;
502
502
auto res = TaskFinishedResponse::ContinueExecution;
503
503
for (const Job *J : B->getCombinedJobs ()) {
504
- if (Comp.ShowJobLifecycle )
504
+ if (Comp.getShowJobLifecycle () )
505
505
llvm::outs () << " ==> Unpacked batch constituent finished: "
506
506
<< LogJob (J) << " \n " ;
507
507
auto r = taskFinished (
@@ -546,11 +546,11 @@ namespace driver {
546
546
547
547
if (Pid != llvm::sys::ProcessInfo::InvalidPid) {
548
548
549
- if (Comp.ShowDriverTimeCompilation ) {
549
+ if (Comp.getShowDriverTimeCompilation () ) {
550
550
DriverTimers[FinishedCmd]->stopTimer ();
551
551
}
552
552
553
- switch (Comp.Level ) {
553
+ switch (Comp.getOutputLevel () ) {
554
554
case OutputLevel::PrintJobs:
555
555
// Only print the jobs, not the outputs
556
556
break ;
@@ -592,17 +592,18 @@ namespace driver {
592
592
593
593
if (!isa<CompileJobAction>(FinishedCmd->getSource ()) ||
594
594
ReturnCode != EXIT_FAILURE) {
595
- Comp.Diags .diagnose (SourceLoc (), diag::error_command_failed,
596
- FinishedCmd->getSource ().getClassName (),
597
- ReturnCode);
595
+ Comp.getDiags () .diagnose (SourceLoc (), diag::error_command_failed,
596
+ FinishedCmd->getSource ().getClassName (),
597
+ ReturnCode);
598
598
}
599
599
600
600
// See how ContinueBuildingAfterErrors gets set up in Driver.cpp for
601
601
// more info.
602
- assert ((Comp.ContinueBuildingAfterErrors || !Comp.EnableBatchMode ) &&
602
+ assert ((Comp.getContinueBuildingAfterErrors () ||
603
+ !Comp.getBatchModeEnabled ()) &&
603
604
" batch mode diagnostics require ContinueBuildingAfterErrors" );
604
605
605
- return Comp.ContinueBuildingAfterErrors ?
606
+ return Comp.getContinueBuildingAfterErrors () ?
606
607
TaskFinishedResponse::ContinueExecution :
607
608
TaskFinishedResponse::StopExecution;
608
609
}
@@ -626,11 +627,11 @@ namespace driver {
626
627
TaskProcessInformation ProcInfo) {
627
628
const Job *SignalledCmd = (const Job *)Context;
628
629
629
- if (Comp.ShowDriverTimeCompilation ) {
630
+ if (Comp.getShowDriverTimeCompilation () ) {
630
631
DriverTimers[SignalledCmd]->stopTimer ();
631
632
}
632
633
633
- if (Comp.Level == OutputLevel::Parseable) {
634
+ if (Comp.getOutputLevel () == OutputLevel::Parseable) {
634
635
// Parseable output was requested.
635
636
SignalledCmd->forEachContainedJobAndPID (Pid, [&](const Job *J,
636
637
Job::PID P) {
@@ -644,17 +645,19 @@ namespace driver {
644
645
llvm::errs () << Output;
645
646
}
646
647
if (!ErrorMsg.empty ())
647
- Comp.Diags .diagnose (SourceLoc (), diag::error_unable_to_execute_command,
648
- ErrorMsg);
648
+ Comp.getDiags ().diagnose (SourceLoc (),
649
+ diag::error_unable_to_execute_command,
650
+ ErrorMsg);
649
651
650
652
if (Signal.hasValue ()) {
651
- Comp.Diags .diagnose (SourceLoc (), diag::error_command_signalled,
652
- SignalledCmd->getSource ().getClassName (),
653
- Signal.getValue ());
653
+ Comp.getDiags () .diagnose (SourceLoc (), diag::error_command_signalled,
654
+ SignalledCmd->getSource ().getClassName (),
655
+ Signal.getValue ());
654
656
} else {
655
- Comp.Diags .diagnose (SourceLoc (),
656
- diag::error_command_signalled_without_signal_number,
657
- SignalledCmd->getSource ().getClassName ());
657
+ Comp.getDiags ()
658
+ .diagnose (SourceLoc (),
659
+ diag::error_command_signalled_without_signal_number,
660
+ SignalledCmd->getSource ().getClassName ());
658
661
}
659
662
660
663
// Since the task signalled, unconditionally set result to -2.
@@ -666,9 +669,9 @@ namespace driver {
666
669
667
670
public:
668
671
PerformJobsState (Compilation &Comp, std::unique_ptr<TaskQueue> &&TaskQueue)
669
- : Comp(Comp), ActualIncrementalTracer(Comp.Stats.get ()),
672
+ : Comp(Comp), ActualIncrementalTracer(Comp.getStatsReporter ()),
670
673
TQ (std::move(TaskQueue)) {
671
- if (Comp.ShowIncrementalBuildDecisions || Comp.Stats )
674
+ if (Comp.getShowIncrementalBuildDecisions () || Comp.getStatsReporter () )
672
675
IncrementalTracer = &ActualIncrementalTracer;
673
676
}
674
677
@@ -747,7 +750,7 @@ namespace driver {
747
750
for (StringRef dependency : DepGraph.getExternalDependencies ()) {
748
751
llvm::sys::fs::file_status depStatus;
749
752
if (!llvm::sys::fs::status (dependency, depStatus))
750
- if (depStatus.getLastModificationTime () < Comp.LastBuildTime )
753
+ if (depStatus.getLastModificationTime () < Comp.getLastBuildTime () )
751
754
continue ;
752
755
753
756
// If the dependency has been modified since the oldest built file,
@@ -775,7 +778,7 @@ namespace driver {
775
778
template <typename Container>
776
779
void transferJobsToTaskQueue (Container &Cmds, StringRef Kind) {
777
780
for (const Job *Cmd : Cmds) {
778
- if (Comp.ShowJobLifecycle )
781
+ if (Comp.getShowJobLifecycle () )
779
782
llvm::outs () << " Adding " << Kind
780
783
<< " job to task queue: "
781
784
<< LogJob (Cmd) << " \n " ;
@@ -791,11 +794,11 @@ namespace driver {
791
794
CommandSetVector &NonBatchable) {
792
795
for (const Job *Cmd : PendingExecution) {
793
796
if (Comp.getToolChain ().jobIsBatchable (Comp, Cmd)) {
794
- if (Comp.ShowJobLifecycle )
797
+ if (Comp.getShowJobLifecycle () )
795
798
llvm::outs () << " Batchable: " << LogJob (Cmd) << " \n " ;
796
799
Batchable.insert (Cmd);
797
800
} else {
798
- if (Comp.ShowJobLifecycle )
801
+ if (Comp.getShowJobLifecycle () )
799
802
llvm::outs () << " Not batchable: " << LogJob (Cmd) << " \n " ;
800
803
NonBatchable.insert (Cmd);
801
804
}
@@ -810,7 +813,7 @@ namespace driver {
810
813
std::vector<const Job *> const &Batch) {
811
814
if (Batch.empty ())
812
815
return ;
813
- if (Comp.ShowJobLifecycle )
816
+ if (Comp.getShowJobLifecycle () )
814
817
llvm::outs () << " Forming batch job from "
815
818
<< Batch.size () << " constituents\n " ;
816
819
auto const &TC = Comp.getToolChain ();
@@ -838,8 +841,8 @@ namespace driver {
838
841
size_t FillCount = TargetSize + ((P < Remainder) ? 1 : 0 );
839
842
std::fill_n (std::back_inserter (PartitionIndex), FillCount, P);
840
843
}
841
- if (Comp.BatchSeed != 0 ) {
842
- std::minstd_rand gen (Comp.BatchSeed );
844
+ if (Comp.getBatchSeed () != 0 ) {
845
+ std::minstd_rand gen (Comp.getBatchSeed () );
843
846
std::shuffle (PartitionIndex.begin (), PartitionIndex.end (), gen);
844
847
}
845
848
assert (PartitionIndex.size () == NumJobs);
@@ -851,7 +854,7 @@ namespace driver {
851
854
// / nonzero value, pseudo-randomly (but determinstically and nearly-evenly).
852
855
void partitionIntoBatches (std::vector<const Job *> Batchable,
853
856
BatchPartition &Partition) {
854
- if (Comp.ShowJobLifecycle ) {
857
+ if (Comp.getShowJobLifecycle () ) {
855
858
llvm::outs () << " Found " << Batchable.size () << " batchable jobs\n " ;
856
859
llvm::outs () << " Forming into " << Partition.size () << " batches\n " ;
857
860
}
@@ -865,14 +868,14 @@ namespace driver {
865
868
assert (Idx < Partition.size ());
866
869
std::vector<const Job*> &P = Partition[Idx];
867
870
if (P.empty () || TC.jobsAreBatchCombinable (Comp, P[0 ], Cmd)) {
868
- if (Comp.ShowJobLifecycle )
871
+ if (Comp.getShowJobLifecycle () )
869
872
llvm::outs () << " Adding " << LogJob (Cmd)
870
873
<< " to batch " << Idx << ' \n ' ;
871
874
P.push_back (Cmd);
872
875
} else {
873
876
// Strange but theoretically possible that we have a batchable job
874
877
// that's not combinable with others; tack a new batch on for it.
875
- if (Comp.ShowJobLifecycle )
878
+ if (Comp.getShowJobLifecycle () )
876
879
llvm::outs () << " Adding " << LogJob (Cmd)
877
880
<< " to new batch " << Partition.size () << ' \n ' ;
878
881
Partition.push_back (std::vector<const Job*>());
@@ -930,8 +933,8 @@ namespace driver {
930
933
return ;
931
934
}
932
935
933
- size_t NumPartitions = (Comp.BatchCount .hasValue () ?
934
- Comp.BatchCount .getValue () :
936
+ size_t NumPartitions = (Comp.getBatchCount () .hasValue () ?
937
+ Comp.getBatchCount () .getValue () :
935
938
TQ->getNumberOfParallelTasks ());
936
939
CommandSetVector Batchable, NonBatchable;
937
940
std::vector<const Job *> Batches;
@@ -984,8 +987,9 @@ namespace driver {
984
987
// exit / signal (or else a poll failed); unfortunately the task
985
988
// causing it was dropped on the floor and we have no way to recover
986
989
// it here, so we report a very poor, generic error.
987
- Comp.Diags .diagnose (SourceLoc (), diag::error_unable_to_execute_command,
988
- " <unknown>" );
990
+ Comp.getDiags ().diagnose (SourceLoc (),
991
+ diag::error_unable_to_execute_command,
992
+ " <unknown>" );
989
993
Result = -2 ;
990
994
AnyAbnormalExit = true ;
991
995
return ;
@@ -1008,7 +1012,7 @@ namespace driver {
1008
1012
// If we got here, all the queued and pending work we know about is
1009
1013
// done; mark anything still in deferred state as skipped.
1010
1014
for (const Job *Cmd : DeferredCommands) {
1011
- if (Comp.Level == OutputLevel::Parseable) {
1015
+ if (Comp.getOutputLevel () == OutputLevel::Parseable) {
1012
1016
// Provide output indicating this command was skipped if parseable
1013
1017
// output was requested.
1014
1018
parseable_output::emitSkippedMessage (llvm::errs (), *Cmd);
@@ -1104,7 +1108,7 @@ namespace driver {
1104
1108
1105
1109
int getResult () {
1106
1110
if (Result == 0 )
1107
- Result = Comp.Diags .hadAnyError ();
1111
+ Result = Comp.getDiags () .hadAnyError ();
1108
1112
return Result;
1109
1113
}
1110
1114
0 commit comments