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) {
15241524 return ClearVirtRegs;
15251525}
15261526
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+
15271562} // namespace
15281563
15291564// / 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(
276276 return buildLTODefaultPipeline (L, nullptr );
277277 },
278278 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" )
279286
280287#undef MODULE_PASS_WITH_PARAMS
281288
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 88; RUN: not opt -passes="lto-pre-link<foo>" < %s 2>&1 | FileCheck %s --check-prefix=INVALID-OPT-LEVEL
99; RUN: not opt -passes="lto" < %s 2>&1 | FileCheck %s --check-prefix=MISSING-OPT-LEVEL
1010; 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
1113
1214; MISSING-OPT-LEVEL: invalid optimization level ''
1315; 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