diff --git a/test/tools/llvm-jitlink/help.test b/test/tools/llvm-jitlink/help.test new file mode 100644 index 00000000000..9eb889b7ee2 --- /dev/null +++ b/test/tools/llvm-jitlink/help.test @@ -0,0 +1,7 @@ +# RUN: llvm-jitlink --help | FileCheck %s --check-prefix HELP --implicit-check-not='{{[Oo]}}ptions:' + +# HELP: OVERVIEW: llvm jitlink tool +# HELP: USAGE +# HELP: Color Options +# HELP: Generic Options +# HELP: JITLink Options diff --git a/test/tools/llvm-link/help.test b/test/tools/llvm-link/help.test new file mode 100644 index 00000000000..356986a4591 --- /dev/null +++ b/test/tools/llvm-link/help.test @@ -0,0 +1,7 @@ +# RUN: llvm-link --help | FileCheck %s --check-prefix HELP --implicit-check-not='{{[Oo]}}ptions:' + +# HELP: OVERVIEW: llvm linker +# HELP: USAGE +# HELP: Color Options +# HELP: Generic Options +# HELP: Link Options diff --git a/test/tools/llvm-lto/help.test b/test/tools/llvm-lto/help.test new file mode 100644 index 00000000000..08f06c850b1 --- /dev/null +++ b/test/tools/llvm-lto/help.test @@ -0,0 +1,7 @@ +# RUN: llvm-lto --help | FileCheck %s --check-prefix HELP --implicit-check-not='{{[Oo]}}ptions:' + +# HELP: OVERVIEW: llvm LTO linker +# HELP: USAGE +# HELP: Color Options +# HELP: Generic Options +# HELP: LTO Options diff --git a/test/tools/llvm-mc/help.test b/test/tools/llvm-mc/help.test new file mode 100644 index 00000000000..62cbdea1115 --- /dev/null +++ b/test/tools/llvm-mc/help.test @@ -0,0 +1,7 @@ +# RUN: llvm-mc --help | FileCheck %s --check-prefix HELP --implicit-check-not='{{[Oo]}}ptions:' + +# HELP: OVERVIEW: llvm machine code playground +# HELP: USAGE +# HELP: Color Options +# HELP: Generic Options +# HELP: MC Options diff --git a/test/tools/llvm-modextract/help.test b/test/tools/llvm-modextract/help.test new file mode 100644 index 00000000000..8865944be23 --- /dev/null +++ b/test/tools/llvm-modextract/help.test @@ -0,0 +1,7 @@ +# RUN: llvm-modextract --help | FileCheck %s --check-prefix HELP --implicit-check-not='{{[Oo]}}ptions:' + +# HELP: OVERVIEW: Module extractor +# HELP: USAGE +# HELP: Color Options +# HELP: Generic Options +# HELP: Modextract Options diff --git a/test/tools/llvm-pdbutil/help.test b/test/tools/llvm-pdbutil/help.test new file mode 100644 index 00000000000..e175488ee6e --- /dev/null +++ b/test/tools/llvm-pdbutil/help.test @@ -0,0 +1,20 @@ +# RUN: llvm-pdbutil --help | FileCheck %s --check-prefix HELP --implicit-check-not='{{[Oo]}}ptions:' + +# HELP: OVERVIEW: LLVM PDB Dumper +# HELP: USAGE +# HELP: SUBCOMMANDS +# HELP: Generic Options + + +# RUN: llvm-pdbutil bytes --help | FileCheck %s --check-prefix BYTES --implicit-check-not='{{[Oo]}}ptions:' + + +# BYTES: OVERVIEW: LLVM PDB Dumper +# BYTES: SUBCOMMAND 'bytes' +# BYTES: USAGE +# BYTES: Dbi Stream Options +# BYTES: Generic Options +# BYTES: MSF File Options +# BYTES: Module Options +# BYTES: PDB Stream Options +# BYTES: Symbol Type Options diff --git a/test/tools/llvm-profgen/help.test b/test/tools/llvm-profgen/help.test new file mode 100644 index 00000000000..b2ffb588741 --- /dev/null +++ b/test/tools/llvm-profgen/help.test @@ -0,0 +1,7 @@ +# RUN: llvm-profgen --help | FileCheck %s --check-prefix HELP --implicit-check-not='{{[Oo]}}ptions:' + +# HELP: OVERVIEW: llvm SPGO profile generator +# HELP: USAGE +# HELP: Color Options +# HELP: Generic Options +# HELP: ProfGen Options diff --git a/tools/llvm-jitlink/llvm-jitlink.cpp b/tools/llvm-jitlink/llvm-jitlink.cpp index 301fecb94ac..645d5aa5745 100644 --- a/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/tools/llvm-jitlink/llvm-jitlink.cpp @@ -61,113 +61,121 @@ using namespace llvm; using namespace llvm::jitlink; using namespace llvm::orc; +static cl::OptionCategory JITLinkCategory("JITLink Options"); + static cl::list InputFiles(cl::Positional, cl::OneOrMore, - cl::desc("input files")); + cl::desc("input files"), + cl::cat(JITLinkCategory)); static cl::opt NoExec("noexec", cl::desc("Do not execute loaded code"), - cl::init(false)); + cl::init(false), cl::cat(JITLinkCategory)); static cl::list CheckFiles("check", cl::desc("File containing verifier checks"), - cl::ZeroOrMore); + cl::ZeroOrMore, cl::cat(JITLinkCategory)); static cl::opt CheckName("check-name", cl::desc("Name of checks to match against"), - cl::init("jitlink-check")); + cl::init("jitlink-check"), cl::cat(JITLinkCategory)); static cl::opt EntryPointName("entry", cl::desc("Symbol to call as main entry point"), - cl::init("")); + cl::init(""), cl::cat(JITLinkCategory)); static cl::list JITLinkDylibs( - "jld", cl::desc("Specifies the JITDylib to be used for any subsequent " - "input file arguments")); + "jld", + cl::desc("Specifies the JITDylib to be used for any subsequent " + "input file arguments"), + cl::cat(JITLinkCategory)); static cl::list Dylibs("dlopen", cl::desc("Dynamic libraries to load before linking"), - cl::ZeroOrMore); + cl::ZeroOrMore, cl::cat(JITLinkCategory)); static cl::list InputArgv("args", cl::Positional, cl::desc("..."), - cl::ZeroOrMore, cl::PositionalEatsArgs); + cl::ZeroOrMore, cl::PositionalEatsArgs, + cl::cat(JITLinkCategory)); static cl::opt NoProcessSymbols("no-process-syms", cl::desc("Do not resolve to llvm-jitlink process symbols"), - cl::init(false)); + cl::init(false), cl::cat(JITLinkCategory)); static cl::list AbsoluteDefs( "define-abs", cl::desc("Inject absolute symbol definitions (syntax: =)"), - cl::ZeroOrMore); + cl::ZeroOrMore, cl::cat(JITLinkCategory)); static cl::list TestHarnesses("harness", cl::Positional, cl::desc("Test harness files"), cl::ZeroOrMore, - cl::PositionalEatsArgs); + cl::PositionalEatsArgs, + cl::cat(JITLinkCategory)); static cl::opt ShowInitialExecutionSessionState( "show-init-es", cl::desc("Print ExecutionSession state before resolving entry point"), - cl::init(false)); + cl::init(false), cl::cat(JITLinkCategory)); static cl::opt ShowAddrs( "show-addrs", cl::desc("Print registered symbol, section, got and stub addresses"), - cl::init(false)); + cl::init(false), cl::cat(JITLinkCategory)); static cl::opt ShowLinkGraph( "show-graph", cl::desc("Print the link graph after fixups have been applied"), - cl::init(false)); + cl::init(false), cl::cat(JITLinkCategory)); static cl::opt ShowSizes( "show-sizes", cl::desc("Show sizes pre- and post-dead stripping, and allocations"), - cl::init(false)); + cl::init(false), cl::cat(JITLinkCategory)); static cl::opt ShowTimes("show-times", cl::desc("Show times for llvm-jitlink phases"), - cl::init(false)); + cl::init(false), cl::cat(JITLinkCategory)); static cl::opt SlabAllocateSizeString( "slab-allocate", cl::desc("Allocate from a slab of the given size " "(allowable suffixes: Kb, Mb, Gb. default = " "Kb)"), - cl::init("")); + cl::init(""), cl::cat(JITLinkCategory)); static cl::opt SlabAddress( "slab-address", cl::desc("Set slab target address (requires -slab-allocate and -noexec)"), - cl::init(~0ULL)); + cl::init(~0ULL), cl::cat(JITLinkCategory)); static cl::opt ShowRelocatedSectionContents( "show-relocated-section-contents", cl::desc("show section contents after fixups have been applied"), - cl::init(false)); + cl::init(false), cl::cat(JITLinkCategory)); static cl::opt PhonyExternals( "phony-externals", cl::desc("resolve all otherwise unresolved externals to null"), - cl::init(false)); + cl::init(false), cl::cat(JITLinkCategory)); static cl::opt OutOfProcessExecutor( "oop-executor", cl::desc("Launch an out-of-process executor to run code"), - cl::ValueOptional); + cl::ValueOptional, cl::cat(JITLinkCategory)); static cl::opt OutOfProcessExecutorConnect( "oop-executor-connect", - cl::desc("Connect to an out-of-process executor via TCP")); + cl::desc("Connect to an out-of-process executor via TCP"), + cl::cat(JITLinkCategory)); // TODO: Default to false if compiler-rt is not built. static cl::opt UseOrcRuntime("use-orc-runtime", cl::desc("Do not required/load ORC runtime"), - cl::init(true)); + cl::init(true), cl::cat(JITLinkCategory)); static cl::opt OrcRuntimePath("orc-runtime-path", cl::desc("Add orc runtime to session"), - cl::init("")); + cl::init(""), cl::cat(JITLinkCategory)); ExitOnError ExitOnErr; @@ -1453,6 +1461,7 @@ int main(int argc, char *argv[]) { InitializeAllTargetMCs(); InitializeAllDisassemblers(); + cl::HideUnrelatedOptions({&JITLinkCategory, &getColorCategory()}); cl::ParseCommandLineOptions(argc, argv, "llvm jitlink tool"); ExitOnErr.setBanner(std::string(argv[0]) + ": "); diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 871b7265e32..9abe8efaa4e 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -41,20 +41,25 @@ #include using namespace llvm; +static cl::OptionCategory LinkCategory("Link Options"); + static cl::list InputFilenames(cl::Positional, cl::OneOrMore, - cl::desc("")); + cl::desc(""), + cl::cat(LinkCategory)); static cl::list OverridingInputs( "override", cl::ZeroOrMore, cl::value_desc("filename"), cl::desc( - "input bitcode file which can override previously defined symbol(s)")); + "input bitcode file which can override previously defined symbol(s)"), + cl::cat(LinkCategory)); // Option to simulate function importing for testing. This enables using // llvm-link to simulate ThinLTO backend processes. static cl::list Imports( "import", cl::ZeroOrMore, cl::value_desc("function:filename"), cl::desc("Pair of function name and filename, where function should be " - "imported from bitcode in filename")); + "imported from bitcode in filename"), + cl::cat(LinkCategory)); // Option to support testing of function importing. The module summary // must be specified in the case were we request imports via the -import @@ -63,53 +68,61 @@ static cl::list Imports( // consistent promotion and renaming of locals. static cl::opt SummaryIndex("summary-index", cl::desc("Module summary index filename"), - cl::init(""), cl::value_desc("filename")); + cl::init(""), cl::value_desc("filename"), + cl::cat(LinkCategory)); -static cl::opt OutputFilename("o", - cl::desc("Override output filename"), - cl::init("-"), - cl::value_desc("filename")); +static cl::opt + OutputFilename("o", cl::desc("Override output filename"), cl::init("-"), + cl::value_desc("filename"), cl::cat(LinkCategory)); static cl::opt Internalize("internalize", - cl::desc("Internalize linked symbols")); + cl::desc("Internalize linked symbols"), + cl::cat(LinkCategory)); static cl::opt DisableDITypeMap("disable-debug-info-type-map", - cl::desc("Don't use a uniquing type map for debug info")); + cl::desc("Don't use a uniquing type map for debug info"), + cl::cat(LinkCategory)); static cl::opt OnlyNeeded("only-needed", - cl::desc("Link only needed symbols")); + cl::desc("Link only needed symbols"), + cl::cat(LinkCategory)); -static cl::opt Force("f", cl::desc("Enable binary output on terminals")); +static cl::opt Force("f", cl::desc("Enable binary output on terminals"), + cl::cat(LinkCategory)); static cl::opt DisableLazyLoad("disable-lazy-loading", - cl::desc("Disable lazy module loading")); + cl::desc("Disable lazy module loading"), + cl::cat(LinkCategory)); -static cl::opt - OutputAssembly("S", cl::desc("Write output as LLVM assembly"), cl::Hidden); +static cl::opt OutputAssembly("S", + cl::desc("Write output as LLVM assembly"), + cl::Hidden, cl::cat(LinkCategory)); static cl::opt Verbose("v", - cl::desc("Print information about actions taken")); + cl::desc("Print information about actions taken"), + cl::cat(LinkCategory)); static cl::opt DumpAsm("d", cl::desc("Print assembly as linked"), - cl::Hidden); + cl::Hidden, cl::cat(LinkCategory)); static cl::opt SuppressWarnings("suppress-warnings", cl::desc("Suppress all linking warnings"), - cl::init(false)); + cl::init(false), cl::cat(LinkCategory)); static cl::opt PreserveBitcodeUseListOrder( "preserve-bc-uselistorder", cl::desc("Preserve use-list order when writing LLVM bitcode."), - cl::init(true), cl::Hidden); + cl::init(true), cl::Hidden, cl::cat(LinkCategory)); static cl::opt PreserveAssemblyUseListOrder( "preserve-ll-uselistorder", cl::desc("Preserve use-list order when writing LLVM assembly."), - cl::init(false), cl::Hidden); + cl::init(false), cl::Hidden, cl::cat(LinkCategory)); static cl::opt NoVerify("disable-verify", - cl::desc("Do not run the verifier"), cl::Hidden); + cl::desc("Do not run the verifier"), cl::Hidden, + cl::cat(LinkCategory)); static ExitOnError ExitOnErr; @@ -434,6 +447,7 @@ int main(int argc, char **argv) { LLVMContext Context; Context.setDiagnosticHandler(std::make_unique(), true); + cl::HideUnrelatedOptions({&LinkCategory, &getColorCategory()}); cl::ParseCommandLineOptions(argc, argv, "llvm linker\n"); if (!DisableDITypeMap) diff --git a/tools/llvm-lto/llvm-lto.cpp b/tools/llvm-lto/llvm-lto.cpp index c58f5c763cc..45bfa84fb82 100644 --- a/tools/llvm-lto/llvm-lto.cpp +++ b/tools/llvm-lto/llvm-lto.cpp @@ -64,31 +64,38 @@ using namespace llvm; static codegen::RegisterCodeGenFlags CGF; +static cl::OptionCategory LTOCategory("LTO Options"); + static cl::opt - OptLevel("O", cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] " - "(default = '-O2')"), - cl::Prefix, cl::ZeroOrMore, cl::init('2')); + OptLevel("O", + cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] " + "(default = '-O2')"), + cl::Prefix, cl::ZeroOrMore, cl::init('2'), cl::cat(LTOCategory)); static cl::opt IndexStats("thinlto-index-stats", cl::desc("Print statistic for the index in every input files"), - cl::init(false)); + cl::init(false), cl::cat(LTOCategory)); static cl::opt DisableVerify( "disable-verify", cl::init(false), - cl::desc("Do not run the verifier during the optimization pipeline")); + cl::desc("Do not run the verifier during the optimization pipeline"), + cl::cat(LTOCategory)); static cl::opt EnableFreestanding( "lto-freestanding", cl::init(false), - cl::desc("Enable Freestanding (disable builtins / TLI) during LTO")); + cl::desc("Enable Freestanding (disable builtins / TLI) during LTO"), + cl::cat(LTOCategory)); static cl::opt UseDiagnosticHandler( "use-diagnostic-handler", cl::init(false), - cl::desc("Use a diagnostic handler to test the handler interface")); + cl::desc("Use a diagnostic handler to test the handler interface"), + cl::cat(LTOCategory)); static cl::opt ThinLTO("thinlto", cl::init(false), - cl::desc("Only write combined global index for ThinLTO backends")); + cl::desc("Only write combined global index for ThinLTO backends"), + cl::cat(LTOCategory)); enum ThinLTOModes { THINLINK, @@ -114,122 +121,144 @@ cl::opt ThinLTOMode( "Emit imports files for distributed backends."), clEnumValN(THINPROMOTE, "promote", "Perform pre-import promotion (requires -thinlto-index)."), - clEnumValN(THINIMPORT, "import", "Perform both promotion and " - "cross-module importing (requires " - "-thinlto-index)."), + clEnumValN(THINIMPORT, "import", + "Perform both promotion and " + "cross-module importing (requires " + "-thinlto-index)."), clEnumValN(THININTERNALIZE, "internalize", "Perform internalization driven by -exported-symbol " "(requires -thinlto-index)."), clEnumValN(THINOPT, "optimize", "Perform ThinLTO optimizations."), clEnumValN(THINCODEGEN, "codegen", "CodeGen (expected to match llc)"), - clEnumValN(THINALL, "run", "Perform ThinLTO end-to-end"))); + clEnumValN(THINALL, "run", "Perform ThinLTO end-to-end")), + cl::cat(LTOCategory)); static cl::opt ThinLTOIndex("thinlto-index", cl::desc("Provide the index produced by a ThinLink, required " - "to perform the promotion and/or importing.")); + "to perform the promotion and/or importing."), + cl::cat(LTOCategory)); static cl::opt ThinLTOPrefixReplace( "thinlto-prefix-replace", cl::desc("Control where files for distributed backends are " "created. Expects 'oldprefix;newprefix' and if path " "prefix of output file is oldprefix it will be " - "replaced with newprefix.")); + "replaced with newprefix."), + cl::cat(LTOCategory)); static cl::opt ThinLTOModuleId( "thinlto-module-id", cl::desc("For the module ID for the file to process, useful to " - "match what is in the index.")); + "match what is in the index."), + cl::cat(LTOCategory)); -static cl::opt - ThinLTOCacheDir("thinlto-cache-dir", cl::desc("Enable ThinLTO caching.")); +static cl::opt ThinLTOCacheDir("thinlto-cache-dir", + cl::desc("Enable ThinLTO caching."), + cl::cat(LTOCategory)); -static cl::opt - ThinLTOCachePruningInterval("thinlto-cache-pruning-interval", - cl::init(1200), cl::desc("Set ThinLTO cache pruning interval.")); +static cl::opt ThinLTOCachePruningInterval( + "thinlto-cache-pruning-interval", cl::init(1200), + cl::desc("Set ThinLTO cache pruning interval."), cl::cat(LTOCategory)); static cl::opt ThinLTOCacheMaxSizeBytes( "thinlto-cache-max-size-bytes", - cl::desc("Set ThinLTO cache pruning directory maximum size in bytes.")); + cl::desc("Set ThinLTO cache pruning directory maximum size in bytes."), + cl::cat(LTOCategory)); -static cl::opt - ThinLTOCacheMaxSizeFiles("thinlto-cache-max-size-files", cl::init(1000000), - cl::desc("Set ThinLTO cache pruning directory maximum number of files.")); +static cl::opt ThinLTOCacheMaxSizeFiles( + "thinlto-cache-max-size-files", cl::init(1000000), + cl::desc("Set ThinLTO cache pruning directory maximum number of files."), + cl::cat(LTOCategory)); -static cl::opt - ThinLTOCacheEntryExpiration("thinlto-cache-entry-expiration", cl::init(604800) /* 1w */, - cl::desc("Set ThinLTO cache entry expiration time.")); +static cl::opt ThinLTOCacheEntryExpiration( + "thinlto-cache-entry-expiration", cl::init(604800) /* 1w */, + cl::desc("Set ThinLTO cache entry expiration time."), cl::cat(LTOCategory)); static cl::opt ThinLTOSaveTempsPrefix( "thinlto-save-temps", cl::desc("Save ThinLTO temp files using filenames created by adding " - "suffixes to the given file path prefix.")); + "suffixes to the given file path prefix."), + cl::cat(LTOCategory)); static cl::opt ThinLTOGeneratedObjectsDir( "thinlto-save-objects", cl::desc("Save ThinLTO generated object files using filenames created in " - "the given directory.")); + "the given directory."), + cl::cat(LTOCategory)); static cl::opt SaveLinkedModuleFile( "save-linked-module", cl::init(false), - cl::desc("Write linked LTO module to file before optimize")); + cl::desc("Write linked LTO module to file before optimize"), + cl::cat(LTOCategory)); static cl::opt SaveModuleFile("save-merged-module", cl::init(false), - cl::desc("Write merged LTO module to file before CodeGen")); + cl::desc("Write merged LTO module to file before CodeGen"), + cl::cat(LTOCategory)); static cl::list InputFilenames(cl::Positional, cl::OneOrMore, - cl::desc("")); + cl::desc(""), + cl::cat(LTOCategory)); static cl::opt OutputFilename("o", cl::init(""), cl::desc("Override output filename"), - cl::value_desc("filename")); + cl::value_desc("filename"), + cl::cat(LTOCategory)); static cl::list ExportedSymbols( "exported-symbol", cl::desc("List of symbols to export from the resulting object file"), - cl::ZeroOrMore); + cl::ZeroOrMore, cl::cat(LTOCategory)); static cl::list DSOSymbols("dso-symbol", cl::desc("Symbol to put in the symtab in the resulting dso"), - cl::ZeroOrMore); + cl::ZeroOrMore, cl::cat(LTOCategory)); static cl::opt ListSymbolsOnly( "list-symbols-only", cl::init(false), - cl::desc("Instead of running LTO, list the symbols in each IR file")); + cl::desc("Instead of running LTO, list the symbols in each IR file"), + cl::cat(LTOCategory)); static cl::opt ListDependentLibrariesOnly( "list-dependent-libraries-only", cl::init(false), - cl::desc("Instead of running LTO, list the dependent libraries in each IR file")); + cl::desc( + "Instead of running LTO, list the dependent libraries in each IR file"), + cl::cat(LTOCategory)); -static cl::opt SetMergedModule( - "set-merged-module", cl::init(false), - cl::desc("Use the first input module as the merged module")); +static cl::opt + SetMergedModule("set-merged-module", cl::init(false), + cl::desc("Use the first input module as the merged module"), + cl::cat(LTOCategory)); static cl::opt Parallelism("j", cl::Prefix, cl::init(1), - cl::desc("Number of backend threads")); + cl::desc("Number of backend threads"), + cl::cat(LTOCategory)); static cl::opt RestoreGlobalsLinkage( "restore-linkage", cl::init(false), - cl::desc("Restore original linkage of globals prior to CodeGen")); + cl::desc("Restore original linkage of globals prior to CodeGen"), + cl::cat(LTOCategory)); static cl::opt CheckHasObjC( "check-for-objc", cl::init(false), - cl::desc("Only check if the module has objective-C defined in it")); + cl::desc("Only check if the module has objective-C defined in it"), + cl::cat(LTOCategory)); static cl::opt PrintMachOCPUOnly( "print-macho-cpu-only", cl::init(false), - cl::desc("Instead of running LTO, print the mach-o cpu in each IR file")); + cl::desc("Instead of running LTO, print the mach-o cpu in each IR file"), + cl::cat(LTOCategory)); -static cl::opt - UseNewPM("use-new-pm", - cl::desc("Run LTO passes using the new pass manager"), - cl::init(LLVM_ENABLE_NEW_PASS_MANAGER), cl::Hidden); +static cl::opt UseNewPM( + "use-new-pm", cl::desc("Run LTO passes using the new pass manager"), + cl::init(LLVM_ENABLE_NEW_PASS_MANAGER), cl::Hidden, cl::cat(LTOCategory)); static cl::opt DebugPassManager("debug-pass-manager", cl::init(false), cl::Hidden, - cl::desc("Print pass management debugging information")); + cl::desc("Print pass management debugging information"), + cl::cat(LTOCategory)); namespace { @@ -895,6 +924,7 @@ private: int main(int argc, char **argv) { InitLLVM X(argc, argv); + cl::HideUnrelatedOptions({<OCategory, &getColorCategory()}); cl::ParseCommandLineOptions(argc, argv, "llvm LTO linker\n"); if (OptLevel < '0' || OptLevel > '3') diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 71940a7d0ae..24c601b7033 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -43,26 +43,33 @@ using namespace llvm; static mc::RegisterMCTargetOptionsFlags MOF; -static cl::opt -InputFilename(cl::Positional, cl::desc(""), cl::init("-")); +static cl::OptionCategory MCCategory("MC Options"); + +static cl::opt InputFilename(cl::Positional, + cl::desc(""), + cl::init("-"), cl::cat(MCCategory)); static cl::list - DisassemblerOptions("M", cl::desc("Disassembler options")); + DisassemblerOptions("M", cl::desc("Disassembler options"), + cl::cat(MCCategory)); static cl::opt OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"), - cl::init("-")); + cl::init("-"), cl::cat(MCCategory)); static cl::opt SplitDwarfFile("split-dwarf-file", cl::desc("DWO output filename"), - cl::value_desc("filename")); + cl::value_desc("filename"), + cl::cat(MCCategory)); -static cl::opt -ShowEncoding("show-encoding", cl::desc("Show instruction encodings")); +static cl::opt ShowEncoding("show-encoding", + cl::desc("Show instruction encodings"), + cl::cat(MCCategory)); static cl::opt RelaxELFRel( "relax-relocations", cl::init(true), - cl::desc("Emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL")); + cl::desc("Emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL"), + cl::cat(MCCategory)); static cl::opt CompressDebugSections( "compress-debug-sections", cl::ValueOptional, @@ -72,29 +79,37 @@ static cl::opt CompressDebugSections( clEnumValN(DebugCompressionType::Z, "zlib", "Use zlib compression"), clEnumValN(DebugCompressionType::GNU, "zlib-gnu", - "Use zlib-gnu compression (deprecated)"))); + "Use zlib-gnu compression (deprecated)")), + cl::cat(MCCategory)); static cl::opt -ShowInst("show-inst", cl::desc("Show internal instruction representation")); + ShowInst("show-inst", cl::desc("Show internal instruction representation"), + cl::cat(MCCategory)); static cl::opt -ShowInstOperands("show-inst-operands", - cl::desc("Show instructions operands as parsed")); + ShowInstOperands("show-inst-operands", + cl::desc("Show instructions operands as parsed"), + cl::cat(MCCategory)); static cl::opt -OutputAsmVariant("output-asm-variant", - cl::desc("Syntax variant to use for output printing")); + OutputAsmVariant("output-asm-variant", + cl::desc("Syntax variant to use for output printing"), + cl::cat(MCCategory)); static cl::opt -PrintImmHex("print-imm-hex", cl::init(false), - cl::desc("Prefer hex format for immediate values")); + PrintImmHex("print-imm-hex", cl::init(false), + cl::desc("Prefer hex format for immediate values"), + cl::cat(MCCategory)); static cl::list -DefineSymbol("defsym", cl::desc("Defines a symbol to be an integer constant")); + DefineSymbol("defsym", + cl::desc("Defines a symbol to be an integer constant"), + cl::cat(MCCategory)); static cl::opt PreserveComments("preserve-comments", - cl::desc("Preserve Comments in outputted assembly")); + cl::desc("Preserve Comments in outputted assembly"), + cl::cat(MCCategory)); enum OutputFileType { OFT_Null, @@ -102,86 +117,101 @@ enum OutputFileType { OFT_ObjectFile }; static cl::opt -FileType("filetype", cl::init(OFT_AssemblyFile), - cl::desc("Choose an output file type:"), - cl::values( - clEnumValN(OFT_AssemblyFile, "asm", - "Emit an assembly ('.s') file"), - clEnumValN(OFT_Null, "null", - "Don't emit anything (for timing purposes)"), - clEnumValN(OFT_ObjectFile, "obj", - "Emit a native object ('.o') file"))); + FileType("filetype", cl::init(OFT_AssemblyFile), + cl::desc("Choose an output file type:"), + cl::values(clEnumValN(OFT_AssemblyFile, "asm", + "Emit an assembly ('.s') file"), + clEnumValN(OFT_Null, "null", + "Don't emit anything (for timing purposes)"), + clEnumValN(OFT_ObjectFile, "obj", + "Emit a native object ('.o') file")), + cl::cat(MCCategory)); + +static cl::list IncludeDirs("I", + cl::desc("Directory of include files"), + cl::value_desc("directory"), + cl::Prefix, cl::cat(MCCategory)); + +static cl::opt + ArchName("arch", + cl::desc("Target arch to assemble for, " + "see -version for available targets"), + cl::cat(MCCategory)); + +static cl::opt + TripleName("triple", + cl::desc("Target triple to assemble for, " + "see -version for available targets"), + cl::cat(MCCategory)); + +static cl::opt + MCPU("mcpu", + cl::desc("Target a specific cpu type (-mcpu=help for details)"), + cl::value_desc("cpu-name"), cl::init(""), cl::cat(MCCategory)); static cl::list -IncludeDirs("I", cl::desc("Directory of include files"), - cl::value_desc("directory"), cl::Prefix); - -static cl::opt -ArchName("arch", cl::desc("Target arch to assemble for, " - "see -version for available targets")); - -static cl::opt -TripleName("triple", cl::desc("Target triple to assemble for, " - "see -version for available targets")); - -static cl::opt -MCPU("mcpu", - cl::desc("Target a specific cpu type (-mcpu=help for details)"), - cl::value_desc("cpu-name"), - cl::init("")); - -static cl::list -MAttrs("mattr", - cl::CommaSeparated, - cl::desc("Target specific attributes (-mattr=help for details)"), - cl::value_desc("a1,+a2,-a3,...")); + MAttrs("mattr", cl::CommaSeparated, + cl::desc("Target specific attributes (-mattr=help for details)"), + cl::value_desc("a1,+a2,-a3,..."), cl::cat(MCCategory)); static cl::opt PIC("position-independent", - cl::desc("Position independent"), cl::init(false)); + cl::desc("Position independent"), cl::init(false), + cl::cat(MCCategory)); static cl::opt LargeCodeModel("large-code-model", cl::desc("Create cfi directives that assume the code might " - "be more than 2gb away")); + "be more than 2gb away"), + cl::cat(MCCategory)); static cl::opt -NoInitialTextSection("n", cl::desc("Don't assume assembly file starts " - "in the text section")); + NoInitialTextSection("n", + cl::desc("Don't assume assembly file starts " + "in the text section"), + cl::cat(MCCategory)); static cl::opt -GenDwarfForAssembly("g", cl::desc("Generate dwarf debugging info for assembly " - "source files")); + GenDwarfForAssembly("g", + cl::desc("Generate dwarf debugging info for assembly " + "source files"), + cl::cat(MCCategory)); static cl::opt -DebugCompilationDir("fdebug-compilation-dir", - cl::desc("Specifies the debug info's compilation dir")); + DebugCompilationDir("fdebug-compilation-dir", + cl::desc("Specifies the debug info's compilation dir"), + cl::cat(MCCategory)); -static cl::list -DebugPrefixMap("fdebug-prefix-map", - cl::desc("Map file source paths in debug info"), - cl::value_desc("= separated key-value pairs")); +static cl::list DebugPrefixMap( + "fdebug-prefix-map", cl::desc("Map file source paths in debug info"), + cl::value_desc("= separated key-value pairs"), cl::cat(MCCategory)); -static cl::opt -MainFileName("main-file-name", - cl::desc("Specifies the name we should consider the input file")); +static cl::opt MainFileName( + "main-file-name", + cl::desc("Specifies the name we should consider the input file"), + cl::cat(MCCategory)); static cl::opt SaveTempLabels("save-temp-labels", - cl::desc("Don't discard temporary labels")); + cl::desc("Don't discard temporary labels"), + cl::cat(MCCategory)); static cl::opt LexMasmIntegers( "masm-integers", - cl::desc("Enable binary and hex masm integers (0b110 and 0ABCh)")); + cl::desc("Enable binary and hex masm integers (0b110 and 0ABCh)"), + cl::cat(MCCategory)); static cl::opt LexMasmHexFloats( "masm-hexfloats", - cl::desc("Enable MASM-style hex float initializers (3F800000r)")); + cl::desc("Enable MASM-style hex float initializers (3F800000r)"), + cl::cat(MCCategory)); static cl::opt LexMotorolaIntegers( "motorola-integers", - cl::desc("Enable binary and hex Motorola integers (%110 and $ABC)")); + cl::desc("Enable binary and hex Motorola integers (%110 and $ABC)"), + cl::cat(MCCategory)); static cl::opt NoExecStack("no-exec-stack", - cl::desc("File doesn't need an exec stack")); + cl::desc("File doesn't need an exec stack"), + cl::cat(MCCategory)); enum ActionType { AC_AsLex, @@ -190,17 +220,16 @@ enum ActionType { AC_MDisassemble, }; -static cl::opt -Action(cl::desc("Action to perform:"), - cl::init(AC_Assemble), - cl::values(clEnumValN(AC_AsLex, "as-lex", - "Lex tokens from a .s file"), - clEnumValN(AC_Assemble, "assemble", - "Assemble a .s file (default)"), - clEnumValN(AC_Disassemble, "disassemble", - "Disassemble strings of hex bytes"), - clEnumValN(AC_MDisassemble, "mdis", - "Marked up disassembly of strings of hex bytes"))); +static cl::opt Action( + cl::desc("Action to perform:"), cl::init(AC_Assemble), + cl::values(clEnumValN(AC_AsLex, "as-lex", "Lex tokens from a .s file"), + clEnumValN(AC_Assemble, "assemble", + "Assemble a .s file (default)"), + clEnumValN(AC_Disassemble, "disassemble", + "Disassemble strings of hex bytes"), + clEnumValN(AC_MDisassemble, "mdis", + "Marked up disassembly of strings of hex bytes")), + cl::cat(MCCategory)); static const Target *GetTarget(const char *ProgName) { // Figure out the target triple. @@ -331,6 +360,7 @@ int main(int argc, char **argv) { // Register the target printer for --version. cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion); + cl::HideUnrelatedOptions({&MCCategory, &getColorCategory()}); cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n"); const MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags(); setDwarfDebugFlags(argc, argv); diff --git a/tools/llvm-modextract/llvm-modextract.cpp b/tools/llvm-modextract/llvm-modextract.cpp index 7c409962584..9a44cbf68d0 100644 --- a/tools/llvm-modextract/llvm-modextract.cpp +++ b/tools/llvm-modextract/llvm-modextract.cpp @@ -21,21 +21,29 @@ using namespace llvm; +static cl::OptionCategory ModextractCategory("Modextract Options"); + static cl::opt - BinaryExtract("b", cl::desc("Whether to perform binary extraction")); + BinaryExtract("b", cl::desc("Whether to perform binary extraction"), + cl::cat(ModextractCategory)); static cl::opt OutputFilename("o", cl::Required, cl::desc("Output filename"), - cl::value_desc("filename")); + cl::value_desc("filename"), + cl::cat(ModextractCategory)); -static cl::opt - InputFilename(cl::Positional, cl::desc(""), cl::init("-")); +static cl::opt InputFilename(cl::Positional, + cl::desc(""), + cl::init("-"), + cl::cat(ModextractCategory)); static cl::opt ModuleIndex("n", cl::Required, cl::desc("Index of module to extract"), - cl::value_desc("index")); + cl::value_desc("index"), + cl::cat(ModextractCategory)); int main(int argc, char **argv) { + cl::HideUnrelatedOptions({&ModextractCategory, &getColorCategory()}); cl::ParseCommandLineOptions(argc, argv, "Module extractor"); ExitOnError ExitOnErr("llvm-modextract: error: "); diff --git a/tools/llvm-pdbutil/llvm-pdbutil.cpp b/tools/llvm-pdbutil/llvm-pdbutil.cpp index c250f3997f1..b152ebd6dcc 100644 --- a/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -1430,6 +1430,8 @@ int main(int Argc, const char **Argv) { InitLLVM X(Argc, Argv); ExitOnErr.setBanner("llvm-pdbutil: "); + cl::HideUnrelatedOptions( + {&opts::TypeCategory, &opts::FilterCategory, &opts::OtherOptions}); cl::ParseCommandLineOptions(Argc, Argv, "LLVM PDB Dumper\n"); if (opts::BytesSubcommand) { diff --git a/tools/llvm-profgen/llvm-profgen.cpp b/tools/llvm-profgen/llvm-profgen.cpp index 081f1bb4fcf..8ea0156aee0 100644 --- a/tools/llvm-profgen/llvm-profgen.cpp +++ b/tools/llvm-profgen/llvm-profgen.cpp @@ -18,16 +18,20 @@ #include "llvm/Support/InitLLVM.h" #include "llvm/Support/TargetSelect.h" +static cl::OptionCategory ProfGenCategory("ProfGen Options"); + static cl::list PerfTraceFilenames( "perfscript", cl::value_desc("perfscript"), cl::OneOrMore, llvm::cl::MiscFlags::CommaSeparated, cl::desc("Path of perf-script trace created by Linux perf tool with " - "`script` command(the raw perf.data should be profiled with -b)")); + "`script` command(the raw perf.data should be profiled with -b)"), + cl::cat(ProfGenCategory)); static cl::list BinaryFilenames("binary", cl::value_desc("binary"), cl::OneOrMore, llvm::cl::MiscFlags::CommaSeparated, - cl::desc("Path of profiled binary files")); + cl::desc("Path of profiled binary files"), + cl::cat(ProfGenCategory)); extern cl::opt ShowDisassemblyOnly; @@ -42,6 +46,7 @@ int main(int argc, const char *argv[]) { InitializeAllTargetMCs(); InitializeAllDisassemblers(); + cl::HideUnrelatedOptions({&ProfGenCategory, &getColorCategory()}); cl::ParseCommandLineOptions(argc, argv, "llvm SPGO profile generator\n"); // Load binaries and parse perf events and samples