[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
This commit is contained in:
Markus Lavin 2022-02-02 09:31:29 +01:00
parent be20ee67e5
commit 0d36d84de5
3 changed files with 24 additions and 18 deletions

View File

@ -37,10 +37,12 @@
using namespace llvm;
extern cl::OptionCategory LLVMReduceOptions;
static cl::opt<std::string>
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) \

View File

@ -26,25 +26,29 @@
using namespace llvm;
extern cl::OptionCategory LLVMReduceOptions;
static cl::opt<bool> 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<unsigned int> 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<bool> 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<unsigned> 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

View File

@ -36,44 +36,44 @@
using namespace llvm;
static cl::OptionCategory Options("llvm-reduce options");
cl::OptionCategory LLVMReduceOptions("llvm-reduce options");
static cl::opt<bool> Help("h", cl::desc("Alias for -help"), cl::Hidden,
cl::cat(Options));
cl::cat(LLVMReduceOptions));
static cl::opt<bool> Version("v", cl::desc("Alias for -version"), cl::Hidden,
cl::cat(Options));
cl::cat(LLVMReduceOptions));
static cl::opt<bool>
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<std::string> InputFilename(cl::Positional, cl::Required,
cl::desc("<input llvm ll/bc file>"),
cl::cat(Options));
cl::cat(LLVMReduceOptions));
static cl::opt<std::string>
TestFilename("test", cl::Required,
cl::desc("Name of the interesting-ness test to be run"),
cl::cat(Options));
cl::cat(LLVMReduceOptions));
static cl::list<std::string>
TestArguments("test-arg", cl::ZeroOrMore,
cl::desc("Arguments passed onto the interesting-ness test"),
cl::cat(Options));
cl::cat(LLVMReduceOptions));
static cl::opt<std::string> 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<bool>
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<InputLanguages>
cl::init(InputLanguages::None),
cl::values(clEnumValN(InputLanguages::IR, "ir", ""),
clEnumValN(InputLanguages::MIR, "mir", "")),
cl::cat(Options));
cl::cat(LLVMReduceOptions));
static cl::opt<std::string> TargetTriple("mtriple",
cl::desc("Set the target triple"),
cl::cat(Options));
cl::cat(LLVMReduceOptions));
static cl::opt<int>
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<LLVMTargetMachine> 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;