Skip to content

Commit 0d36d84

Browse files
committed
[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
1 parent be20ee6 commit 0d36d84

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

llvm/tools/llvm-reduce/DeltaManager.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@
3737

3838
using namespace llvm;
3939

40+
extern cl::OptionCategory LLVMReduceOptions;
4041
static cl::opt<std::string>
4142
DeltaPasses("delta-passes",
4243
cl::desc("Delta passes to run, separated by commas. By "
43-
"default, run all delta passes."));
44+
"default, run all delta passes."),
45+
cl::cat(LLVMReduceOptions));
4446

4547
#define DELTA_PASSES \
4648
DELTA_PASS("special-globals", reduceSpecialGlobalsDeltaPass) \

llvm/tools/llvm-reduce/deltas/Delta.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,29 @@
2626

2727
using namespace llvm;
2828

29+
extern cl::OptionCategory LLVMReduceOptions;
30+
2931
static cl::opt<bool> AbortOnInvalidReduction(
3032
"abort-on-invalid-reduction",
31-
cl::desc("Abort if any reduction results in invalid IR"));
33+
cl::desc("Abort if any reduction results in invalid IR"),
34+
cl::cat(LLVMReduceOptions));
3235

3336
static cl::opt<unsigned int> StartingGranularityLevel(
3437
"starting-granularity-level",
35-
cl::desc("Number of times to divide chunks prior to first test"));
38+
cl::desc("Number of times to divide chunks prior to first test"),
39+
cl::cat(LLVMReduceOptions));
3640

3741
static cl::opt<bool> TmpFilesAsBitcode(
3842
"write-tmp-files-as-bitcode",
3943
cl::desc("Write temporary files as bitcode, instead of textual IR"),
40-
cl::init(false));
44+
cl::init(false), cl::cat(LLVMReduceOptions));
4145

4246
#ifdef LLVM_ENABLE_THREADS
4347
static cl::opt<unsigned> NumJobs(
4448
"j",
4549
cl::desc("Maximum number of threads to use to process chunks. Set to 1 to "
4650
"disables parallelism."),
47-
cl::init(1));
51+
cl::init(1), cl::cat(LLVMReduceOptions));
4852
#else
4953
unsigned NumJobs = 1;
5054
#endif

llvm/tools/llvm-reduce/llvm-reduce.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,44 +36,44 @@
3636

3737
using namespace llvm;
3838

39-
static cl::OptionCategory Options("llvm-reduce options");
39+
cl::OptionCategory LLVMReduceOptions("llvm-reduce options");
4040

4141
static cl::opt<bool> Help("h", cl::desc("Alias for -help"), cl::Hidden,
42-
cl::cat(Options));
42+
cl::cat(LLVMReduceOptions));
4343
static cl::opt<bool> Version("v", cl::desc("Alias for -version"), cl::Hidden,
44-
cl::cat(Options));
44+
cl::cat(LLVMReduceOptions));
4545

4646
static cl::opt<bool>
4747
PrintDeltaPasses("print-delta-passes",
4848
cl::desc("Print list of delta passes, passable to "
4949
"--delta-passes as a comma separated list"),
50-
cl::cat(Options));
50+
cl::cat(LLVMReduceOptions));
5151

5252
static cl::opt<std::string> InputFilename(cl::Positional, cl::Required,
5353
cl::desc("<input llvm ll/bc file>"),
54-
cl::cat(Options));
54+
cl::cat(LLVMReduceOptions));
5555

5656
static cl::opt<std::string>
5757
TestFilename("test", cl::Required,
5858
cl::desc("Name of the interesting-ness test to be run"),
59-
cl::cat(Options));
59+
cl::cat(LLVMReduceOptions));
6060

6161
static cl::list<std::string>
6262
TestArguments("test-arg", cl::ZeroOrMore,
6363
cl::desc("Arguments passed onto the interesting-ness test"),
64-
cl::cat(Options));
64+
cl::cat(LLVMReduceOptions));
6565

6666
static cl::opt<std::string> OutputFilename(
6767
"output", cl::desc("Specify the output file. default: reduced.ll|mir"));
6868
static cl::alias OutputFileAlias("o", cl::desc("Alias for -output"),
6969
cl::aliasopt(OutputFilename),
70-
cl::cat(Options));
70+
cl::cat(LLVMReduceOptions));
7171

7272
static cl::opt<bool>
7373
ReplaceInput("in-place",
7474
cl::desc("WARNING: This option will replace your input file "
7575
"with the reduced version!"),
76-
cl::cat(Options));
76+
cl::cat(LLVMReduceOptions));
7777

7878
enum class InputLanguages { None, IR, MIR };
7979

@@ -83,17 +83,17 @@ static cl::opt<InputLanguages>
8383
cl::init(InputLanguages::None),
8484
cl::values(clEnumValN(InputLanguages::IR, "ir", ""),
8585
clEnumValN(InputLanguages::MIR, "mir", "")),
86-
cl::cat(Options));
86+
cl::cat(LLVMReduceOptions));
8787

8888
static cl::opt<std::string> TargetTriple("mtriple",
8989
cl::desc("Set the target triple"),
90-
cl::cat(Options));
90+
cl::cat(LLVMReduceOptions));
9191

9292
static cl::opt<int>
9393
MaxPassIterations("max-pass-iterations",
9494
cl::desc("Maximum number of times to run the full set "
9595
"of delta passes (default=1)"),
96-
cl::init(1), cl::cat(Options));
96+
cl::init(1), cl::cat(LLVMReduceOptions));
9797

9898
static codegen::RegisterCodeGenFlags CGF;
9999

@@ -135,7 +135,7 @@ static std::unique_ptr<LLVMTargetMachine> createTargetMachine() {
135135
int main(int Argc, char **Argv) {
136136
InitLLVM X(Argc, Argv);
137137

138-
cl::HideUnrelatedOptions({&Options, &getColorCategory()});
138+
cl::HideUnrelatedOptions({&LLVMReduceOptions, &getColorCategory()});
139139
cl::ParseCommandLineOptions(Argc, Argv, "LLVM automatic testcase reducer.\n");
140140

141141
bool ReduceModeMIR = false;

0 commit comments

Comments
 (0)