From 0d36d84de5f8182bd9c1628cb6cf4cd47d248c9e Mon Sep 17 00:00:00 2001 From: Markus Lavin Date: Wed, 2 Feb 2022 09:31:29 +0100 Subject: [PATCH] [llvm-reduce] Display all relevant options in -help Previously the options category given to cl::HideUnrelatedOptions was local to llvm-reduce.cpp and as a result only options declared in that file were visible in the -help options listing. This was a bit unfortunate since there were several useful options declared in other files. This patch addresses that. Differential Revision: https://reviews.llvm.org/D118682 --- llvm/tools/llvm-reduce/DeltaManager.cpp | 4 +++- llvm/tools/llvm-reduce/deltas/Delta.cpp | 12 ++++++++---- llvm/tools/llvm-reduce/llvm-reduce.cpp | 26 ++++++++++++------------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/llvm/tools/llvm-reduce/DeltaManager.cpp b/llvm/tools/llvm-reduce/DeltaManager.cpp index 4d646a7c861d..4abdf384aa00 100644 --- a/llvm/tools/llvm-reduce/DeltaManager.cpp +++ b/llvm/tools/llvm-reduce/DeltaManager.cpp @@ -37,10 +37,12 @@ using namespace llvm; +extern cl::OptionCategory LLVMReduceOptions; static cl::opt DeltaPasses("delta-passes", cl::desc("Delta passes to run, separated by commas. By " - "default, run all delta passes.")); + "default, run all delta passes."), + cl::cat(LLVMReduceOptions)); #define DELTA_PASSES \ DELTA_PASS("special-globals", reduceSpecialGlobalsDeltaPass) \ diff --git a/llvm/tools/llvm-reduce/deltas/Delta.cpp b/llvm/tools/llvm-reduce/deltas/Delta.cpp index 1bab82f823c0..d48052742f93 100644 --- a/llvm/tools/llvm-reduce/deltas/Delta.cpp +++ b/llvm/tools/llvm-reduce/deltas/Delta.cpp @@ -26,25 +26,29 @@ using namespace llvm; +extern cl::OptionCategory LLVMReduceOptions; + static cl::opt AbortOnInvalidReduction( "abort-on-invalid-reduction", - cl::desc("Abort if any reduction results in invalid IR")); + cl::desc("Abort if any reduction results in invalid IR"), + cl::cat(LLVMReduceOptions)); static cl::opt StartingGranularityLevel( "starting-granularity-level", - cl::desc("Number of times to divide chunks prior to first test")); + cl::desc("Number of times to divide chunks prior to first test"), + cl::cat(LLVMReduceOptions)); static cl::opt TmpFilesAsBitcode( "write-tmp-files-as-bitcode", cl::desc("Write temporary files as bitcode, instead of textual IR"), - cl::init(false)); + cl::init(false), cl::cat(LLVMReduceOptions)); #ifdef LLVM_ENABLE_THREADS static cl::opt NumJobs( "j", cl::desc("Maximum number of threads to use to process chunks. Set to 1 to " "disables parallelism."), - cl::init(1)); + cl::init(1), cl::cat(LLVMReduceOptions)); #else unsigned NumJobs = 1; #endif diff --git a/llvm/tools/llvm-reduce/llvm-reduce.cpp b/llvm/tools/llvm-reduce/llvm-reduce.cpp index 59cc055a0870..abcd4c695386 100644 --- a/llvm/tools/llvm-reduce/llvm-reduce.cpp +++ b/llvm/tools/llvm-reduce/llvm-reduce.cpp @@ -36,44 +36,44 @@ using namespace llvm; -static cl::OptionCategory Options("llvm-reduce options"); +cl::OptionCategory LLVMReduceOptions("llvm-reduce options"); static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden, - cl::cat(Options)); + cl::cat(LLVMReduceOptions)); static cl::opt Version("v", cl::desc("Alias for -version"), cl::Hidden, - cl::cat(Options)); + cl::cat(LLVMReduceOptions)); static cl::opt PrintDeltaPasses("print-delta-passes", cl::desc("Print list of delta passes, passable to " "--delta-passes as a comma separated list"), - cl::cat(Options)); + cl::cat(LLVMReduceOptions)); static cl::opt InputFilename(cl::Positional, cl::Required, cl::desc(""), - cl::cat(Options)); + cl::cat(LLVMReduceOptions)); static cl::opt TestFilename("test", cl::Required, cl::desc("Name of the interesting-ness test to be run"), - cl::cat(Options)); + cl::cat(LLVMReduceOptions)); static cl::list TestArguments("test-arg", cl::ZeroOrMore, cl::desc("Arguments passed onto the interesting-ness test"), - cl::cat(Options)); + cl::cat(LLVMReduceOptions)); static cl::opt OutputFilename( "output", cl::desc("Specify the output file. default: reduced.ll|mir")); static cl::alias OutputFileAlias("o", cl::desc("Alias for -output"), cl::aliasopt(OutputFilename), - cl::cat(Options)); + cl::cat(LLVMReduceOptions)); static cl::opt ReplaceInput("in-place", cl::desc("WARNING: This option will replace your input file " "with the reduced version!"), - cl::cat(Options)); + cl::cat(LLVMReduceOptions)); enum class InputLanguages { None, IR, MIR }; @@ -83,17 +83,17 @@ static cl::opt cl::init(InputLanguages::None), cl::values(clEnumValN(InputLanguages::IR, "ir", ""), clEnumValN(InputLanguages::MIR, "mir", "")), - cl::cat(Options)); + cl::cat(LLVMReduceOptions)); static cl::opt TargetTriple("mtriple", cl::desc("Set the target triple"), - cl::cat(Options)); + cl::cat(LLVMReduceOptions)); static cl::opt MaxPassIterations("max-pass-iterations", cl::desc("Maximum number of times to run the full set " "of delta passes (default=1)"), - cl::init(1), cl::cat(Options)); + cl::init(1), cl::cat(LLVMReduceOptions)); static codegen::RegisterCodeGenFlags CGF; @@ -135,7 +135,7 @@ static std::unique_ptr createTargetMachine() { int main(int Argc, char **Argv) { InitLLVM X(Argc, Argv); - cl::HideUnrelatedOptions({&Options, &getColorCategory()}); + cl::HideUnrelatedOptions({&LLVMReduceOptions, &getColorCategory()}); cl::ParseCommandLineOptions(Argc, Argv, "LLVM automatic testcase reducer.\n"); bool ReduceModeMIR = false;