@@ -79,8 +79,7 @@ static void addDefiniteInitialization(SILPassPipelinePlan &P) {
79
79
P.addRawSILInstLowering ();
80
80
}
81
81
82
- static void addMandatoryOptPipeline (SILPassPipelinePlan &P,
83
- const SILOptions &Options) {
82
+ static void addMandatoryOptPipeline (SILPassPipelinePlan &P) {
84
83
P.startPipeline (" Guaranteed Passes" );
85
84
P.addDiagnoseStaticExclusivity ();
86
85
P.addCapturePromotion ();
@@ -99,6 +98,7 @@ static void addMandatoryOptPipeline(SILPassPipelinePlan &P,
99
98
// pass. This will happen when OSSA is no longer eliminated before the
100
99
// optimizer pipeline is run implying we can put a pass that requires OSSA
101
100
// there.
101
+ const auto &Options = P.getOptions ();
102
102
if (Options.EnableMandatorySemanticARCOpts && Options.shouldOptimize ()) {
103
103
P.addSemanticARCOpts ();
104
104
}
@@ -130,7 +130,7 @@ static void addMandatoryOptPipeline(SILPassPipelinePlan &P,
130
130
131
131
SILPassPipelinePlan
132
132
SILPassPipelinePlan::getDiagnosticPassPipeline (const SILOptions &Options) {
133
- SILPassPipelinePlan P;
133
+ SILPassPipelinePlan P (Options) ;
134
134
135
135
if (SILViewSILGenCFG) {
136
136
addCFGPrinterPipeline (P, " SIL View SILGen CFG" );
@@ -145,7 +145,7 @@ SILPassPipelinePlan::getDiagnosticPassPipeline(const SILOptions &Options) {
145
145
}
146
146
147
147
// Otherwise run the rest of diagnostics.
148
- addMandatoryOptPipeline (P, Options );
148
+ addMandatoryOptPipeline (P);
149
149
150
150
if (SILViewGuaranteedCFG) {
151
151
addCFGPrinterPipeline (P, " SIL View Guaranteed CFG" );
@@ -157,8 +157,9 @@ SILPassPipelinePlan::getDiagnosticPassPipeline(const SILOptions &Options) {
157
157
// Ownership Eliminator Pipeline
158
158
// ===----------------------------------------------------------------------===//
159
159
160
- SILPassPipelinePlan SILPassPipelinePlan::getOwnershipEliminatorPassPipeline () {
161
- SILPassPipelinePlan P;
160
+ SILPassPipelinePlan SILPassPipelinePlan::getOwnershipEliminatorPassPipeline (
161
+ const SILOptions &Options) {
162
+ SILPassPipelinePlan P (Options);
162
163
addOwnershipModelEliminatorPipeline (P);
163
164
return P;
164
165
}
@@ -240,8 +241,7 @@ void addHighLevelLoopOptPasses(SILPassPipelinePlan &P) {
240
241
}
241
242
242
243
// Perform classic SSA optimizations.
243
- void addSSAPasses (SILPassPipelinePlan &P, OptimizationLevelKind OpLevel,
244
- bool stopAfterSerialization = false ) {
244
+ void addSSAPasses (SILPassPipelinePlan &P, OptimizationLevelKind OpLevel) {
245
245
// Promote box allocations to stack allocations.
246
246
P.addAllocBoxToStack ();
247
247
@@ -294,7 +294,7 @@ void addSSAPasses(SILPassPipelinePlan &P, OptimizationLevelKind OpLevel,
294
294
// which reduces the ability of the compiler to optimize clients
295
295
// importing this module.
296
296
P.addSerializeSILPass ();
297
- if (stopAfterSerialization )
297
+ if (P. getOptions (). StopOptimizationAfterSerialization )
298
298
return ;
299
299
300
300
// Does inline semantics-functions (except "availability"), but not
@@ -370,6 +370,7 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
370
370
// Get rid of apparently dead functions as soon as possible so that
371
371
// we do not spend time optimizing them.
372
372
P.addDeadFunctionElimination ();
373
+
373
374
// Start by cloning functions from stdlib.
374
375
P.addPerformanceSILLinker ();
375
376
@@ -399,11 +400,10 @@ static void addMidModulePassesStackPromotePassPipeline(SILPassPipelinePlan &P) {
399
400
P.addStackPromotion ();
400
401
}
401
402
402
- static bool addMidLevelPassPipeline (SILPassPipelinePlan &P,
403
- bool stopAfterSerialization) {
403
+ static bool addMidLevelPassPipeline (SILPassPipelinePlan &P) {
404
404
P.startPipeline (" MidLevel" );
405
- addSSAPasses (P, OptimizationLevelKind::MidLevel, stopAfterSerialization );
406
- if (stopAfterSerialization )
405
+ addSSAPasses (P, OptimizationLevelKind::MidLevel);
406
+ if (P. getOptions (). StopOptimizationAfterSerialization )
407
407
return true ;
408
408
409
409
// Specialize partially applied functions with dead arguments as a preparation
@@ -538,8 +538,8 @@ static void addSILDebugInfoGeneratorPipeline(SILPassPipelinePlan &P) {
538
538
// / Mandatory IRGen preparation. It is the caller's job to set the set stage to
539
539
// / "lowered" after running this pipeline.
540
540
SILPassPipelinePlan
541
- SILPassPipelinePlan::getLoweringPassPipeline () {
542
- SILPassPipelinePlan P;
541
+ SILPassPipelinePlan::getLoweringPassPipeline (const SILOptions &Options ) {
542
+ SILPassPipelinePlan P (Options) ;
543
543
P.startPipeline (" Address Lowering" );
544
544
P.addIRGenPrepare ();
545
545
P.addAddressLowering ();
@@ -549,7 +549,7 @@ SILPassPipelinePlan::getLoweringPassPipeline() {
549
549
550
550
SILPassPipelinePlan
551
551
SILPassPipelinePlan::getIRGenPreparePassPipeline (const SILOptions &Options) {
552
- SILPassPipelinePlan P;
552
+ SILPassPipelinePlan P (Options) ;
553
553
P.startPipeline (" IRGen Preparation" );
554
554
// Insert SIL passes to run during IRGen.
555
555
// Hoist generic alloc_stack instructions to the entry block to enable better
@@ -563,7 +563,7 @@ SILPassPipelinePlan::getIRGenPreparePassPipeline(const SILOptions &Options) {
563
563
564
564
SILPassPipelinePlan
565
565
SILPassPipelinePlan::getSILOptPreparePassPipeline (const SILOptions &Options) {
566
- SILPassPipelinePlan P;
566
+ SILPassPipelinePlan P (Options) ;
567
567
568
568
if (Options.DebugSerialization ) {
569
569
addPerfDebugSerializationPipeline (P);
@@ -578,7 +578,7 @@ SILPassPipelinePlan::getSILOptPreparePassPipeline(const SILOptions &Options) {
578
578
579
579
SILPassPipelinePlan
580
580
SILPassPipelinePlan::getPerformancePassPipeline (const SILOptions &Options) {
581
- SILPassPipelinePlan P;
581
+ SILPassPipelinePlan P (Options) ;
582
582
583
583
if (Options.DebugSerialization ) {
584
584
addPerfDebugSerializationPipeline (P);
@@ -594,7 +594,7 @@ SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
594
594
addMidModulePassesStackPromotePassPipeline (P);
595
595
596
596
// Run an iteration of the mid-level SSA passes.
597
- if (addMidLevelPassPipeline (P, Options. StopOptimizationAfterSerialization ))
597
+ if (addMidLevelPassPipeline (P))
598
598
return P;
599
599
600
600
// Perform optimizations that specialize.
@@ -624,8 +624,9 @@ SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
624
624
// Onone Pass Pipeline
625
625
// ===----------------------------------------------------------------------===//
626
626
627
- SILPassPipelinePlan SILPassPipelinePlan::getOnonePassPipeline () {
628
- SILPassPipelinePlan P;
627
+ SILPassPipelinePlan
628
+ SILPassPipelinePlan::getOnonePassPipeline (const SILOptions &Options) {
629
+ SILPassPipelinePlan P (Options);
629
630
630
631
// First specialize user-code.
631
632
P.startPipeline (" Prespecialization" );
@@ -649,8 +650,9 @@ SILPassPipelinePlan SILPassPipelinePlan::getOnonePassPipeline() {
649
650
// Inst Count Pass Pipeline
650
651
// ===----------------------------------------------------------------------===//
651
652
652
- SILPassPipelinePlan SILPassPipelinePlan::getInstCountPassPipeline () {
653
- SILPassPipelinePlan P;
653
+ SILPassPipelinePlan
654
+ SILPassPipelinePlan::getInstCountPassPipeline (const SILOptions &Options) {
655
+ SILPassPipelinePlan P (Options);
654
656
P.startPipeline (" Inst Count" );
655
657
P.addInstCount ();
656
658
return P;
@@ -680,8 +682,9 @@ void SILPassPipelinePlan::addPasses(ArrayRef<PassKind> PassKinds) {
680
682
}
681
683
682
684
SILPassPipelinePlan
683
- SILPassPipelinePlan::getPassPipelineForKinds (ArrayRef<PassKind> PassKinds) {
684
- SILPassPipelinePlan P;
685
+ SILPassPipelinePlan::getPassPipelineForKinds (const SILOptions &Options,
686
+ ArrayRef<PassKind> PassKinds) {
687
+ SILPassPipelinePlan P (Options);
685
688
P.startPipeline (" Pass List Pipeline" );
686
689
P.addPasses (PassKinds);
687
690
return P;
@@ -717,7 +720,8 @@ void SILPassPipelinePlan::print(llvm::raw_ostream &os) {
717
720
}
718
721
719
722
SILPassPipelinePlan
720
- SILPassPipelinePlan::getPassPipelineFromFile (StringRef Filename) {
723
+ SILPassPipelinePlan::getPassPipelineFromFile (const SILOptions &Options,
724
+ StringRef Filename) {
721
725
namespace yaml = llvm::yaml;
722
726
LLVM_DEBUG (llvm::dbgs () << " Parsing Pass Pipeline from " << Filename << " \n " );
723
727
@@ -736,7 +740,7 @@ SILPassPipelinePlan::getPassPipelineFromFile(StringRef Filename) {
736
740
yaml::Node *N = DI->getRoot ();
737
741
assert (N && " Failed to find a root" );
738
742
739
- SILPassPipelinePlan P;
743
+ SILPassPipelinePlan P (Options) ;
740
744
741
745
auto *RootList = cast<yaml::SequenceNode>(N);
742
746
llvm::SmallVector<PassKind, 32 > Passes;
0 commit comments