Skip to content

Commit

Permalink
[llvm-reduce] Display all relevant options in -help
Browse files Browse the repository at this point in the history
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
  • Loading branch information
markuslavin committed Feb 2, 2022
1 parent be20ee6 commit 0d36d84
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
4 changes: 3 additions & 1 deletion llvm/tools/llvm-reduce/DeltaManager.cpp
Expand Up @@ -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) \
Expand Down
12 changes: 8 additions & 4 deletions llvm/tools/llvm-reduce/deltas/Delta.cpp
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions llvm/tools/llvm-reduce/llvm-reduce.cpp
Expand Up @@ -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 };

Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0d36d84

Please sign in to comment.