374
374
375
375
using namespace llvm ;
376
376
377
- static const Regex DefaultAliasRegex (
378
- " ^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$" );
379
-
380
377
cl::opt<bool > llvm::PrintPipelinePasses (
381
378
" print-pipeline-passes" ,
382
379
cl::desc (" Print a '-passes' compatible string describing the pipeline "
@@ -618,6 +615,15 @@ static std::optional<OptimizationLevel> parseOptLevel(StringRef S) {
618
615
.Default (std::nullopt);
619
616
}
620
617
618
+ static Expected<OptimizationLevel> parseOptLevelParam (StringRef S) {
619
+ std::optional<OptimizationLevel> OptLevel = parseOptLevel (S);
620
+ if (OptLevel)
621
+ return *OptLevel;
622
+ return make_error<StringError>(
623
+ formatv (" invalid optimization level '{}'" , S).str (),
624
+ inconvertibleErrorCode ());
625
+ }
626
+
621
627
Expected<bool > PassBuilder::parseSinglePassOption (StringRef Params,
622
628
StringRef OptionName,
623
629
StringRef PassName) {
@@ -1507,13 +1513,6 @@ Expected<bool> parseVirtRegRewriterPassOptions(StringRef Params) {
1507
1513
1508
1514
} // namespace
1509
1515
1510
- // / Tests whether a pass name starts with a valid prefix for a default pipeline
1511
- // / alias.
1512
- static bool startsWithDefaultPipelineAliasPrefix (StringRef Name) {
1513
- return Name.starts_with (" default" ) || Name.starts_with (" thinlto" ) ||
1514
- Name.starts_with (" lto" );
1515
- }
1516
-
1517
1516
// / Tests whether registered callbacks will accept a given pass name.
1518
1517
// /
1519
1518
// / When parsing a pipeline text, the type of the outermost pipeline may be
@@ -1535,10 +1534,6 @@ static bool callbacksAcceptPassName(StringRef Name, CallbacksT &Callbacks) {
1535
1534
1536
1535
template <typename CallbacksT>
1537
1536
static bool isModulePassName (StringRef Name, CallbacksT &Callbacks) {
1538
- // Manually handle aliases for pre-configured pipeline fragments.
1539
- if (startsWithDefaultPipelineAliasPrefix (Name))
1540
- return DefaultAliasRegex.match (Name);
1541
-
1542
1537
StringRef NameNoBracket = Name.take_until ([](char C) { return C == ' <' ; });
1543
1538
1544
1539
// Explicitly handle pass manager names.
@@ -1737,6 +1732,15 @@ PassBuilder::parsePipelineText(StringRef Text) {
1737
1732
return {std::move (ResultPipeline)};
1738
1733
}
1739
1734
1735
+ static void setupOptionsForPipelineAlias (PipelineTuningOptions &PTO,
1736
+ OptimizationLevel L) {
1737
+ // This is consistent with old pass manager invoked via opt, but
1738
+ // inconsistent with clang. Clang doesn't enable loop vectorization
1739
+ // but does enable slp vectorization at Oz.
1740
+ PTO.LoopVectorization = L.getSpeedupLevel () > 1 && L != OptimizationLevel::Oz;
1741
+ PTO.SLPVectorization = L.getSpeedupLevel () > 1 && L != OptimizationLevel::Oz;
1742
+ }
1743
+
1740
1744
Error PassBuilder::parseModulePass (ModulePassManager &MPM,
1741
1745
const PipelineElement &E) {
1742
1746
auto &Name = E.Name ;
@@ -1789,47 +1793,6 @@ Error PassBuilder::parseModulePass(ModulePassManager &MPM,
1789
1793
;
1790
1794
}
1791
1795
1792
- // Manually handle aliases for pre-configured pipeline fragments.
1793
- if (startsWithDefaultPipelineAliasPrefix (Name)) {
1794
- SmallVector<StringRef, 3 > Matches;
1795
- if (!DefaultAliasRegex.match (Name, &Matches))
1796
- return make_error<StringError>(
1797
- formatv (" unknown default pipeline alias '{}'" , Name).str (),
1798
- inconvertibleErrorCode ());
1799
-
1800
- assert (Matches.size () == 3 && " Must capture two matched strings!" );
1801
-
1802
- OptimizationLevel L = *parseOptLevel (Matches[2 ]);
1803
-
1804
- // This is consistent with old pass manager invoked via opt, but
1805
- // inconsistent with clang. Clang doesn't enable loop vectorization
1806
- // but does enable slp vectorization at Oz.
1807
- PTO.LoopVectorization =
1808
- L.getSpeedupLevel () > 1 && L != OptimizationLevel::Oz;
1809
- PTO.SLPVectorization =
1810
- L.getSpeedupLevel () > 1 && L != OptimizationLevel::Oz;
1811
-
1812
- if (Matches[1 ] == " default" ) {
1813
- MPM.addPass (buildPerModuleDefaultPipeline (L));
1814
- } else if (Matches[1 ] == " thinlto-pre-link" ) {
1815
- MPM.addPass (buildThinLTOPreLinkDefaultPipeline (L));
1816
- } else if (Matches[1 ] == " thinlto" ) {
1817
- MPM.addPass (buildThinLTODefaultPipeline (L, nullptr ));
1818
- } else if (Matches[1 ] == " lto-pre-link" ) {
1819
- if (PTO.UnifiedLTO )
1820
- // When UnifiedLTO is enabled, use the ThinLTO pre-link pipeline. This
1821
- // avoids compile-time performance regressions and keeps the pre-link
1822
- // LTO pipeline "unified" for both LTO modes.
1823
- MPM.addPass (buildThinLTOPreLinkDefaultPipeline (L));
1824
- else
1825
- MPM.addPass (buildLTOPreLinkDefaultPipeline (L));
1826
- } else {
1827
- assert (Matches[1 ] == " lto" && " Not one of the matched options!" );
1828
- MPM.addPass (buildLTODefaultPipeline (L, nullptr ));
1829
- }
1830
- return Error::success ();
1831
- }
1832
-
1833
1796
// Finally expand the basic registered passes from the .inc file.
1834
1797
#define MODULE_PASS (NAME, CREATE_PASS ) \
1835
1798
if (Name == NAME) { \
0 commit comments