diff --git a/mlir/include/mlir/Pass/PassRegistry.h b/mlir/include/mlir/Pass/PassRegistry.h --- a/mlir/include/mlir/Pass/PassRegistry.h +++ b/mlir/include/mlir/Pass/PassRegistry.h @@ -257,6 +257,8 @@ std::unique_ptr impl; llvm::cl::opt passPipeline; + + llvm::cl::alias passPipelineAlias; }; /// This class implements a command-line parser specifically for MLIR pass diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp --- a/mlir/lib/Pass/PassRegistry.cpp +++ b/mlir/lib/Pass/PassRegistry.cpp @@ -764,7 +764,7 @@ /// The name for the command line option used for parsing the textual pass /// pipeline. -static constexpr StringLiteral passPipelineArg = "pass-pipeline"; +#define PASS_PIPELINE_ARG "pass-pipeline" /// Adds command line option for each registered pass or pass pipeline, as well /// as textual pass pipelines. @@ -896,8 +896,11 @@ : impl(std::make_unique( arg, description, /*passNamesOnly=*/false)), passPipeline( - StringRef(passPipelineArg), - llvm::cl::desc("Textual description of the pass pipeline to run")) {} + PASS_PIPELINE_ARG, + llvm::cl::desc("Textual description of the pass pipeline to run")), + passPipelineAlias("p", llvm::cl::desc("Alias for -" PASS_PIPELINE_ARG), + llvm::cl::aliasopt(passPipeline), + llvm::cl::DefaultOption) {} PassPipelineCLParser::~PassPipelineCLParser() = default; /// Returns true if this parser contains any valid options to add. @@ -919,7 +922,7 @@ if (passPipeline.getNumOccurrences()) { if (impl->passList.getNumOccurrences()) return errorHandler( - "'-" + passPipelineArg + + "'-" PASS_PIPELINE_ARG "' option can't be used with individual pass options"); std::string errMsg; llvm::raw_string_ostream os(errMsg); diff --git a/mlir/test/mlir-opt/commandline.mlir b/mlir/test/mlir-opt/commandline.mlir --- a/mlir/test/mlir-opt/commandline.mlir +++ b/mlir/test/mlir-opt/commandline.mlir @@ -40,3 +40,6 @@ // CHECK-NEXT: transform // CHECK-NEXT: vector // CHECK-NEXT: x86vector + +// RUN: mlir-opt --help-hidden | FileCheck %s -check-prefix=CHECK-HELP +// CHECK-HELP: -p - Alias for -pass-pipeline