File tree Expand file tree Collapse file tree 4 files changed +54
-0
lines changed Expand file tree Collapse file tree 4 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -1524,6 +1524,41 @@ Expected<bool> parseVirtRegRewriterPassOptions(StringRef Params) {
1524
1524
return ClearVirtRegs;
1525
1525
}
1526
1526
1527
+ struct FatLTOOptions {
1528
+ OptimizationLevel OptLevel;
1529
+ bool ThinLTO = false ;
1530
+ bool EmitSummary = false ;
1531
+ };
1532
+
1533
+ Expected<FatLTOOptions> parseFatLTOOptions (StringRef Params) {
1534
+ FatLTOOptions Result;
1535
+ bool HaveOptLevel = false ;
1536
+ while (!Params.empty ()) {
1537
+ StringRef ParamName;
1538
+ std::tie (ParamName, Params) = Params.split (' ;' );
1539
+
1540
+ if (ParamName == " thinlto" ) {
1541
+ Result.ThinLTO = true ;
1542
+ } else if (ParamName == " emit-summary" ) {
1543
+ Result.EmitSummary = true ;
1544
+ } else if (std::optional<OptimizationLevel> OptLevel =
1545
+ parseOptLevel (ParamName)) {
1546
+ Result.OptLevel = *OptLevel;
1547
+ HaveOptLevel = true ;
1548
+ } else {
1549
+ return make_error<StringError>(
1550
+ formatv (" invalid fatlto-pre-link pass parameter '{}'" , ParamName)
1551
+ .str (),
1552
+ inconvertibleErrorCode ());
1553
+ }
1554
+ }
1555
+ if (!HaveOptLevel)
1556
+ return make_error<StringError>(
1557
+ " missing optimization level for fatlto-pre-link pipeline" ,
1558
+ inconvertibleErrorCode ());
1559
+ return Result;
1560
+ }
1561
+
1527
1562
} // namespace
1528
1563
1529
1564
// / Tests whether registered callbacks will accept a given pass name.
Original file line number Diff line number Diff line change @@ -276,6 +276,13 @@ MODULE_PASS_WITH_PARAMS(
276
276
return buildLTODefaultPipeline (L, nullptr );
277
277
},
278
278
parseOptLevelParam, " O0;O1;O2;O3;Os;Oz" )
279
+ MODULE_PASS_WITH_PARAMS (
280
+ " fatlto-pre-link" , " " , [&](FatLTOOptions Opts) {
281
+ setupOptionsForPipelineAlias (PTO, Opts.OptLevel );
282
+ return buildFatLTODefaultPipeline (Opts.OptLevel , Opts.ThinLTO ,
283
+ Opts.EmitSummary );
284
+ },
285
+ parseFatLTOOptions, " O0;O1;O2;O3;Os;Oz;thinlto;emit-summary" )
279
286
280
287
#undef MODULE_PASS_WITH_PARAMS
281
288
Original file line number Diff line number Diff line change
1
+ ; RUN: opt -debug-pass-manager -passes='fatlto-pre-link<O2>' -disable-output %s 2>&1 | FileCheck %s
2
+ ; RUN: opt -debug-pass-manager -passes='fatlto-pre-link<O2;thinlto>' -disable-output %s 2>&1 | FileCheck %s --check-prefixes=CHECK,THINLTO
3
+
4
+ ; CHECK: Running pass: EmbedBitcodePass on [module]
5
+ ; THINLTO: Running analysis: ModuleSummaryIndexAnalysis on [module]
6
+ ; CHECK-NEXT: Running pass: FatLtoCleanup on [module]
7
+ ; CHECK-NEXT: Running pass: LowerTypeTestsPass on [module]
Original file line number Diff line number Diff line change 8
8
; RUN: not opt -passes="lto-pre-link<foo>" < %s 2>&1 | FileCheck %s --check-prefix=INVALID-OPT-LEVEL
9
9
; RUN: not opt -passes="lto" < %s 2>&1 | FileCheck %s --check-prefix=MISSING-OPT-LEVEL
10
10
; RUN: not opt -passes="lto<foo>" < %s 2>&1 | FileCheck %s --check-prefix=INVALID-OPT-LEVEL
11
+ ; RUN: not opt -passes="fatlto-pre-link" < %s 2>&1 | FileCheck %s --check-prefix=FATLTO-MISSING-OPT-LEVEL
12
+ ; RUN: not opt -passes="fatlto-pre-link<foo>" < %s 2>&1 | FileCheck %s --check-prefix=FATLTO-INVALID-PARAMS
11
13
12
14
; MISSING-OPT-LEVEL: invalid optimization level ''
13
15
; INVALID-OPT-LEVEL: invalid optimization level 'foo'
16
+
17
+ ; FATLTO-MISSING-OPT-LEVEL: missing optimization level for fatlto-pre-link pipeline
18
+ ; FATLTO-INVALID-PARAMS: invalid fatlto-pre-link pass parameter 'foo'
You can’t perform that action at this time.
0 commit comments