1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 10:32:48 +02:00

[llvm][tools] Hide more unrelated LLVM tool options

Differential Revision: https://reviews.llvm.org/D106366
This commit is contained in:
Timm Bäder 2021-07-20 17:10:34 +02:00
parent 864fe23f53
commit e396e90533
14 changed files with 342 additions and 182 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -61,113 +61,121 @@ using namespace llvm;
using namespace llvm::jitlink; using namespace llvm::jitlink;
using namespace llvm::orc; using namespace llvm::orc;
static cl::OptionCategory JITLinkCategory("JITLink Options");
static cl::list<std::string> InputFiles(cl::Positional, cl::OneOrMore, static cl::list<std::string> InputFiles(cl::Positional, cl::OneOrMore,
cl::desc("input files")); cl::desc("input files"),
cl::cat(JITLinkCategory));
static cl::opt<bool> NoExec("noexec", cl::desc("Do not execute loaded code"), static cl::opt<bool> NoExec("noexec", cl::desc("Do not execute loaded code"),
cl::init(false)); cl::init(false), cl::cat(JITLinkCategory));
static cl::list<std::string> static cl::list<std::string>
CheckFiles("check", cl::desc("File containing verifier checks"), CheckFiles("check", cl::desc("File containing verifier checks"),
cl::ZeroOrMore); cl::ZeroOrMore, cl::cat(JITLinkCategory));
static cl::opt<std::string> static cl::opt<std::string>
CheckName("check-name", cl::desc("Name of checks to match against"), 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<std::string> static cl::opt<std::string>
EntryPointName("entry", cl::desc("Symbol to call as main entry point"), EntryPointName("entry", cl::desc("Symbol to call as main entry point"),
cl::init("")); cl::init(""), cl::cat(JITLinkCategory));
static cl::list<std::string> JITLinkDylibs( static cl::list<std::string> JITLinkDylibs(
"jld", cl::desc("Specifies the JITDylib to be used for any subsequent " "jld",
"input file arguments")); cl::desc("Specifies the JITDylib to be used for any subsequent "
"input file arguments"),
cl::cat(JITLinkCategory));
static cl::list<std::string> static cl::list<std::string>
Dylibs("dlopen", cl::desc("Dynamic libraries to load before linking"), Dylibs("dlopen", cl::desc("Dynamic libraries to load before linking"),
cl::ZeroOrMore); cl::ZeroOrMore, cl::cat(JITLinkCategory));
static cl::list<std::string> InputArgv("args", cl::Positional, static cl::list<std::string> InputArgv("args", cl::Positional,
cl::desc("<program arguments>..."), cl::desc("<program arguments>..."),
cl::ZeroOrMore, cl::PositionalEatsArgs); cl::ZeroOrMore, cl::PositionalEatsArgs,
cl::cat(JITLinkCategory));
static cl::opt<bool> static cl::opt<bool>
NoProcessSymbols("no-process-syms", NoProcessSymbols("no-process-syms",
cl::desc("Do not resolve to llvm-jitlink process symbols"), cl::desc("Do not resolve to llvm-jitlink process symbols"),
cl::init(false)); cl::init(false), cl::cat(JITLinkCategory));
static cl::list<std::string> AbsoluteDefs( static cl::list<std::string> AbsoluteDefs(
"define-abs", "define-abs",
cl::desc("Inject absolute symbol definitions (syntax: <name>=<addr>)"), cl::desc("Inject absolute symbol definitions (syntax: <name>=<addr>)"),
cl::ZeroOrMore); cl::ZeroOrMore, cl::cat(JITLinkCategory));
static cl::list<std::string> TestHarnesses("harness", cl::Positional, static cl::list<std::string> TestHarnesses("harness", cl::Positional,
cl::desc("Test harness files"), cl::desc("Test harness files"),
cl::ZeroOrMore, cl::ZeroOrMore,
cl::PositionalEatsArgs); cl::PositionalEatsArgs,
cl::cat(JITLinkCategory));
static cl::opt<bool> ShowInitialExecutionSessionState( static cl::opt<bool> ShowInitialExecutionSessionState(
"show-init-es", "show-init-es",
cl::desc("Print ExecutionSession state before resolving entry point"), cl::desc("Print ExecutionSession state before resolving entry point"),
cl::init(false)); cl::init(false), cl::cat(JITLinkCategory));
static cl::opt<bool> ShowAddrs( static cl::opt<bool> ShowAddrs(
"show-addrs", "show-addrs",
cl::desc("Print registered symbol, section, got and stub addresses"), cl::desc("Print registered symbol, section, got and stub addresses"),
cl::init(false)); cl::init(false), cl::cat(JITLinkCategory));
static cl::opt<bool> ShowLinkGraph( static cl::opt<bool> ShowLinkGraph(
"show-graph", "show-graph",
cl::desc("Print the link graph after fixups have been applied"), cl::desc("Print the link graph after fixups have been applied"),
cl::init(false)); cl::init(false), cl::cat(JITLinkCategory));
static cl::opt<bool> ShowSizes( static cl::opt<bool> ShowSizes(
"show-sizes", "show-sizes",
cl::desc("Show sizes pre- and post-dead stripping, and allocations"), cl::desc("Show sizes pre- and post-dead stripping, and allocations"),
cl::init(false)); cl::init(false), cl::cat(JITLinkCategory));
static cl::opt<bool> ShowTimes("show-times", static cl::opt<bool> ShowTimes("show-times",
cl::desc("Show times for llvm-jitlink phases"), cl::desc("Show times for llvm-jitlink phases"),
cl::init(false)); cl::init(false), cl::cat(JITLinkCategory));
static cl::opt<std::string> SlabAllocateSizeString( static cl::opt<std::string> SlabAllocateSizeString(
"slab-allocate", "slab-allocate",
cl::desc("Allocate from a slab of the given size " cl::desc("Allocate from a slab of the given size "
"(allowable suffixes: Kb, Mb, Gb. default = " "(allowable suffixes: Kb, Mb, Gb. default = "
"Kb)"), "Kb)"),
cl::init("")); cl::init(""), cl::cat(JITLinkCategory));
static cl::opt<uint64_t> SlabAddress( static cl::opt<uint64_t> SlabAddress(
"slab-address", "slab-address",
cl::desc("Set slab target address (requires -slab-allocate and -noexec)"), cl::desc("Set slab target address (requires -slab-allocate and -noexec)"),
cl::init(~0ULL)); cl::init(~0ULL), cl::cat(JITLinkCategory));
static cl::opt<bool> ShowRelocatedSectionContents( static cl::opt<bool> ShowRelocatedSectionContents(
"show-relocated-section-contents", "show-relocated-section-contents",
cl::desc("show section contents after fixups have been applied"), cl::desc("show section contents after fixups have been applied"),
cl::init(false)); cl::init(false), cl::cat(JITLinkCategory));
static cl::opt<bool> PhonyExternals( static cl::opt<bool> PhonyExternals(
"phony-externals", "phony-externals",
cl::desc("resolve all otherwise unresolved externals to null"), cl::desc("resolve all otherwise unresolved externals to null"),
cl::init(false)); cl::init(false), cl::cat(JITLinkCategory));
static cl::opt<std::string> OutOfProcessExecutor( static cl::opt<std::string> OutOfProcessExecutor(
"oop-executor", cl::desc("Launch an out-of-process executor to run code"), "oop-executor", cl::desc("Launch an out-of-process executor to run code"),
cl::ValueOptional); cl::ValueOptional, cl::cat(JITLinkCategory));
static cl::opt<std::string> OutOfProcessExecutorConnect( static cl::opt<std::string> OutOfProcessExecutorConnect(
"oop-executor-connect", "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. // TODO: Default to false if compiler-rt is not built.
static cl::opt<bool> UseOrcRuntime("use-orc-runtime", static cl::opt<bool> UseOrcRuntime("use-orc-runtime",
cl::desc("Do not required/load ORC runtime"), cl::desc("Do not required/load ORC runtime"),
cl::init(true)); cl::init(true), cl::cat(JITLinkCategory));
static cl::opt<std::string> static cl::opt<std::string>
OrcRuntimePath("orc-runtime-path", cl::desc("Add orc runtime to session"), OrcRuntimePath("orc-runtime-path", cl::desc("Add orc runtime to session"),
cl::init("")); cl::init(""), cl::cat(JITLinkCategory));
ExitOnError ExitOnErr; ExitOnError ExitOnErr;
@ -1453,6 +1461,7 @@ int main(int argc, char *argv[]) {
InitializeAllTargetMCs(); InitializeAllTargetMCs();
InitializeAllDisassemblers(); InitializeAllDisassemblers();
cl::HideUnrelatedOptions({&JITLinkCategory, &getColorCategory()});
cl::ParseCommandLineOptions(argc, argv, "llvm jitlink tool"); cl::ParseCommandLineOptions(argc, argv, "llvm jitlink tool");
ExitOnErr.setBanner(std::string(argv[0]) + ": "); ExitOnErr.setBanner(std::string(argv[0]) + ": ");

View File

@ -41,20 +41,25 @@
#include <utility> #include <utility>
using namespace llvm; using namespace llvm;
static cl::OptionCategory LinkCategory("Link Options");
static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore, static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
cl::desc("<input bitcode files>")); cl::desc("<input bitcode files>"),
cl::cat(LinkCategory));
static cl::list<std::string> OverridingInputs( static cl::list<std::string> OverridingInputs(
"override", cl::ZeroOrMore, cl::value_desc("filename"), "override", cl::ZeroOrMore, cl::value_desc("filename"),
cl::desc( 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 // Option to simulate function importing for testing. This enables using
// llvm-link to simulate ThinLTO backend processes. // llvm-link to simulate ThinLTO backend processes.
static cl::list<std::string> Imports( static cl::list<std::string> Imports(
"import", cl::ZeroOrMore, cl::value_desc("function:filename"), "import", cl::ZeroOrMore, cl::value_desc("function:filename"),
cl::desc("Pair of function name and filename, where function should be " 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 // Option to support testing of function importing. The module summary
// must be specified in the case were we request imports via the -import // must be specified in the case were we request imports via the -import
@ -63,53 +68,61 @@ static cl::list<std::string> Imports(
// consistent promotion and renaming of locals. // consistent promotion and renaming of locals.
static cl::opt<std::string> static cl::opt<std::string>
SummaryIndex("summary-index", cl::desc("Module summary index filename"), 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<std::string> OutputFilename("o", static cl::opt<std::string>
cl::desc("Override output filename"), OutputFilename("o", cl::desc("Override output filename"), cl::init("-"),
cl::init("-"), cl::value_desc("filename"), cl::cat(LinkCategory));
cl::value_desc("filename"));
static cl::opt<bool> Internalize("internalize", static cl::opt<bool> Internalize("internalize",
cl::desc("Internalize linked symbols")); cl::desc("Internalize linked symbols"),
cl::cat(LinkCategory));
static cl::opt<bool> static cl::opt<bool>
DisableDITypeMap("disable-debug-info-type-map", 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<bool> OnlyNeeded("only-needed", static cl::opt<bool> OnlyNeeded("only-needed",
cl::desc("Link only needed symbols")); cl::desc("Link only needed symbols"),
cl::cat(LinkCategory));
static cl::opt<bool> Force("f", cl::desc("Enable binary output on terminals")); static cl::opt<bool> Force("f", cl::desc("Enable binary output on terminals"),
cl::cat(LinkCategory));
static cl::opt<bool> DisableLazyLoad("disable-lazy-loading", static cl::opt<bool> DisableLazyLoad("disable-lazy-loading",
cl::desc("Disable lazy module loading")); cl::desc("Disable lazy module loading"),
cl::cat(LinkCategory));
static cl::opt<bool> static cl::opt<bool> OutputAssembly("S",
OutputAssembly("S", cl::desc("Write output as LLVM assembly"), cl::Hidden); cl::desc("Write output as LLVM assembly"),
cl::Hidden, cl::cat(LinkCategory));
static cl::opt<bool> Verbose("v", static cl::opt<bool> Verbose("v",
cl::desc("Print information about actions taken")); cl::desc("Print information about actions taken"),
cl::cat(LinkCategory));
static cl::opt<bool> DumpAsm("d", cl::desc("Print assembly as linked"), static cl::opt<bool> DumpAsm("d", cl::desc("Print assembly as linked"),
cl::Hidden); cl::Hidden, cl::cat(LinkCategory));
static cl::opt<bool> SuppressWarnings("suppress-warnings", static cl::opt<bool> SuppressWarnings("suppress-warnings",
cl::desc("Suppress all linking warnings"), cl::desc("Suppress all linking warnings"),
cl::init(false)); cl::init(false), cl::cat(LinkCategory));
static cl::opt<bool> PreserveBitcodeUseListOrder( static cl::opt<bool> PreserveBitcodeUseListOrder(
"preserve-bc-uselistorder", "preserve-bc-uselistorder",
cl::desc("Preserve use-list order when writing LLVM bitcode."), 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<bool> PreserveAssemblyUseListOrder( static cl::opt<bool> PreserveAssemblyUseListOrder(
"preserve-ll-uselistorder", "preserve-ll-uselistorder",
cl::desc("Preserve use-list order when writing LLVM assembly."), 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<bool> NoVerify("disable-verify", static cl::opt<bool> 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; static ExitOnError ExitOnErr;
@ -434,6 +447,7 @@ int main(int argc, char **argv) {
LLVMContext Context; LLVMContext Context;
Context.setDiagnosticHandler(std::make_unique<LLVMLinkDiagnosticHandler>(), Context.setDiagnosticHandler(std::make_unique<LLVMLinkDiagnosticHandler>(),
true); true);
cl::HideUnrelatedOptions({&LinkCategory, &getColorCategory()});
cl::ParseCommandLineOptions(argc, argv, "llvm linker\n"); cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
if (!DisableDITypeMap) if (!DisableDITypeMap)

View File

@ -64,31 +64,38 @@ using namespace llvm;
static codegen::RegisterCodeGenFlags CGF; static codegen::RegisterCodeGenFlags CGF;
static cl::OptionCategory LTOCategory("LTO Options");
static cl::opt<char> static cl::opt<char>
OptLevel("O", cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] " OptLevel("O",
"(default = '-O2')"), cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
cl::Prefix, cl::ZeroOrMore, cl::init('2')); "(default = '-O2')"),
cl::Prefix, cl::ZeroOrMore, cl::init('2'), cl::cat(LTOCategory));
static cl::opt<bool> static cl::opt<bool>
IndexStats("thinlto-index-stats", IndexStats("thinlto-index-stats",
cl::desc("Print statistic for the index in every input files"), cl::desc("Print statistic for the index in every input files"),
cl::init(false)); cl::init(false), cl::cat(LTOCategory));
static cl::opt<bool> DisableVerify( static cl::opt<bool> DisableVerify(
"disable-verify", cl::init(false), "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<bool> EnableFreestanding( static cl::opt<bool> EnableFreestanding(
"lto-freestanding", cl::init(false), "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<bool> UseDiagnosticHandler( static cl::opt<bool> UseDiagnosticHandler(
"use-diagnostic-handler", cl::init(false), "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<bool> static cl::opt<bool>
ThinLTO("thinlto", cl::init(false), 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 { enum ThinLTOModes {
THINLINK, THINLINK,
@ -114,122 +121,144 @@ cl::opt<ThinLTOModes> ThinLTOMode(
"Emit imports files for distributed backends."), "Emit imports files for distributed backends."),
clEnumValN(THINPROMOTE, "promote", clEnumValN(THINPROMOTE, "promote",
"Perform pre-import promotion (requires -thinlto-index)."), "Perform pre-import promotion (requires -thinlto-index)."),
clEnumValN(THINIMPORT, "import", "Perform both promotion and " clEnumValN(THINIMPORT, "import",
"cross-module importing (requires " "Perform both promotion and "
"-thinlto-index)."), "cross-module importing (requires "
"-thinlto-index)."),
clEnumValN(THININTERNALIZE, "internalize", clEnumValN(THININTERNALIZE, "internalize",
"Perform internalization driven by -exported-symbol " "Perform internalization driven by -exported-symbol "
"(requires -thinlto-index)."), "(requires -thinlto-index)."),
clEnumValN(THINOPT, "optimize", "Perform ThinLTO optimizations."), clEnumValN(THINOPT, "optimize", "Perform ThinLTO optimizations."),
clEnumValN(THINCODEGEN, "codegen", "CodeGen (expected to match llc)"), 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<std::string> static cl::opt<std::string>
ThinLTOIndex("thinlto-index", ThinLTOIndex("thinlto-index",
cl::desc("Provide the index produced by a ThinLink, required " 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<std::string> ThinLTOPrefixReplace( static cl::opt<std::string> ThinLTOPrefixReplace(
"thinlto-prefix-replace", "thinlto-prefix-replace",
cl::desc("Control where files for distributed backends are " cl::desc("Control where files for distributed backends are "
"created. Expects 'oldprefix;newprefix' and if path " "created. Expects 'oldprefix;newprefix' and if path "
"prefix of output file is oldprefix it will be " "prefix of output file is oldprefix it will be "
"replaced with newprefix.")); "replaced with newprefix."),
cl::cat(LTOCategory));
static cl::opt<std::string> ThinLTOModuleId( static cl::opt<std::string> ThinLTOModuleId(
"thinlto-module-id", "thinlto-module-id",
cl::desc("For the module ID for the file to process, useful to " 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<std::string> static cl::opt<std::string> ThinLTOCacheDir("thinlto-cache-dir",
ThinLTOCacheDir("thinlto-cache-dir", cl::desc("Enable ThinLTO caching.")); cl::desc("Enable ThinLTO caching."),
cl::cat(LTOCategory));
static cl::opt<int> static cl::opt<int> ThinLTOCachePruningInterval(
ThinLTOCachePruningInterval("thinlto-cache-pruning-interval", "thinlto-cache-pruning-interval", cl::init(1200),
cl::init(1200), cl::desc("Set ThinLTO cache pruning interval.")); cl::desc("Set ThinLTO cache pruning interval."), cl::cat(LTOCategory));
static cl::opt<uint64_t> ThinLTOCacheMaxSizeBytes( static cl::opt<uint64_t> ThinLTOCacheMaxSizeBytes(
"thinlto-cache-max-size-bytes", "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<int> static cl::opt<int> ThinLTOCacheMaxSizeFiles(
ThinLTOCacheMaxSizeFiles("thinlto-cache-max-size-files", cl::init(1000000), "thinlto-cache-max-size-files", cl::init(1000000),
cl::desc("Set ThinLTO cache pruning directory maximum number of files.")); cl::desc("Set ThinLTO cache pruning directory maximum number of files."),
cl::cat(LTOCategory));
static cl::opt<unsigned> static cl::opt<unsigned> ThinLTOCacheEntryExpiration(
ThinLTOCacheEntryExpiration("thinlto-cache-entry-expiration", cl::init(604800) /* 1w */, "thinlto-cache-entry-expiration", cl::init(604800) /* 1w */,
cl::desc("Set ThinLTO cache entry expiration time.")); cl::desc("Set ThinLTO cache entry expiration time."), cl::cat(LTOCategory));
static cl::opt<std::string> ThinLTOSaveTempsPrefix( static cl::opt<std::string> ThinLTOSaveTempsPrefix(
"thinlto-save-temps", "thinlto-save-temps",
cl::desc("Save ThinLTO temp files using filenames created by adding " 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<std::string> ThinLTOGeneratedObjectsDir( static cl::opt<std::string> ThinLTOGeneratedObjectsDir(
"thinlto-save-objects", "thinlto-save-objects",
cl::desc("Save ThinLTO generated object files using filenames created in " cl::desc("Save ThinLTO generated object files using filenames created in "
"the given directory.")); "the given directory."),
cl::cat(LTOCategory));
static cl::opt<bool> SaveLinkedModuleFile( static cl::opt<bool> SaveLinkedModuleFile(
"save-linked-module", cl::init(false), "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<bool> static cl::opt<bool>
SaveModuleFile("save-merged-module", cl::init(false), 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<std::string> InputFilenames(cl::Positional, cl::OneOrMore, static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
cl::desc("<input bitcode files>")); cl::desc("<input bitcode files>"),
cl::cat(LTOCategory));
static cl::opt<std::string> OutputFilename("o", cl::init(""), static cl::opt<std::string> OutputFilename("o", cl::init(""),
cl::desc("Override output filename"), cl::desc("Override output filename"),
cl::value_desc("filename")); cl::value_desc("filename"),
cl::cat(LTOCategory));
static cl::list<std::string> ExportedSymbols( static cl::list<std::string> ExportedSymbols(
"exported-symbol", "exported-symbol",
cl::desc("List of symbols to export from the resulting object file"), cl::desc("List of symbols to export from the resulting object file"),
cl::ZeroOrMore); cl::ZeroOrMore, cl::cat(LTOCategory));
static cl::list<std::string> static cl::list<std::string>
DSOSymbols("dso-symbol", DSOSymbols("dso-symbol",
cl::desc("Symbol to put in the symtab in the resulting dso"), cl::desc("Symbol to put in the symtab in the resulting dso"),
cl::ZeroOrMore); cl::ZeroOrMore, cl::cat(LTOCategory));
static cl::opt<bool> ListSymbolsOnly( static cl::opt<bool> ListSymbolsOnly(
"list-symbols-only", cl::init(false), "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<bool> ListDependentLibrariesOnly( static cl::opt<bool> ListDependentLibrariesOnly(
"list-dependent-libraries-only", cl::init(false), "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<bool> SetMergedModule( static cl::opt<bool>
"set-merged-module", cl::init(false), SetMergedModule("set-merged-module", cl::init(false),
cl::desc("Use the first input module as the merged module")); cl::desc("Use the first input module as the merged module"),
cl::cat(LTOCategory));
static cl::opt<unsigned> Parallelism("j", cl::Prefix, cl::init(1), static cl::opt<unsigned> 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<bool> RestoreGlobalsLinkage( static cl::opt<bool> RestoreGlobalsLinkage(
"restore-linkage", cl::init(false), "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<bool> CheckHasObjC( static cl::opt<bool> CheckHasObjC(
"check-for-objc", cl::init(false), "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<bool> PrintMachOCPUOnly( static cl::opt<bool> PrintMachOCPUOnly(
"print-macho-cpu-only", cl::init(false), "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<bool> static cl::opt<bool> UseNewPM(
UseNewPM("use-new-pm", "use-new-pm", cl::desc("Run LTO passes using the new pass manager"),
cl::desc("Run LTO passes using the new pass manager"), cl::init(LLVM_ENABLE_NEW_PASS_MANAGER), cl::Hidden, cl::cat(LTOCategory));
cl::init(LLVM_ENABLE_NEW_PASS_MANAGER), cl::Hidden);
static cl::opt<bool> static cl::opt<bool>
DebugPassManager("debug-pass-manager", cl::init(false), cl::Hidden, 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 { namespace {
@ -895,6 +924,7 @@ private:
int main(int argc, char **argv) { int main(int argc, char **argv) {
InitLLVM X(argc, argv); InitLLVM X(argc, argv);
cl::HideUnrelatedOptions({&LTOCategory, &getColorCategory()});
cl::ParseCommandLineOptions(argc, argv, "llvm LTO linker\n"); cl::ParseCommandLineOptions(argc, argv, "llvm LTO linker\n");
if (OptLevel < '0' || OptLevel > '3') if (OptLevel < '0' || OptLevel > '3')

View File

@ -43,26 +43,33 @@ using namespace llvm;
static mc::RegisterMCTargetOptionsFlags MOF; static mc::RegisterMCTargetOptionsFlags MOF;
static cl::opt<std::string> static cl::OptionCategory MCCategory("MC Options");
InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
static cl::opt<std::string> InputFilename(cl::Positional,
cl::desc("<input file>"),
cl::init("-"), cl::cat(MCCategory));
static cl::list<std::string> static cl::list<std::string>
DisassemblerOptions("M", cl::desc("Disassembler options")); DisassemblerOptions("M", cl::desc("Disassembler options"),
cl::cat(MCCategory));
static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"), static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
cl::value_desc("filename"), cl::value_desc("filename"),
cl::init("-")); cl::init("-"), cl::cat(MCCategory));
static cl::opt<std::string> SplitDwarfFile("split-dwarf-file", static cl::opt<std::string> SplitDwarfFile("split-dwarf-file",
cl::desc("DWO output filename"), cl::desc("DWO output filename"),
cl::value_desc("filename")); cl::value_desc("filename"),
cl::cat(MCCategory));
static cl::opt<bool> static cl::opt<bool> ShowEncoding("show-encoding",
ShowEncoding("show-encoding", cl::desc("Show instruction encodings")); cl::desc("Show instruction encodings"),
cl::cat(MCCategory));
static cl::opt<bool> RelaxELFRel( static cl::opt<bool> RelaxELFRel(
"relax-relocations", cl::init(true), "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<DebugCompressionType> CompressDebugSections( static cl::opt<DebugCompressionType> CompressDebugSections(
"compress-debug-sections", cl::ValueOptional, "compress-debug-sections", cl::ValueOptional,
@ -72,29 +79,37 @@ static cl::opt<DebugCompressionType> CompressDebugSections(
clEnumValN(DebugCompressionType::Z, "zlib", clEnumValN(DebugCompressionType::Z, "zlib",
"Use zlib compression"), "Use zlib compression"),
clEnumValN(DebugCompressionType::GNU, "zlib-gnu", clEnumValN(DebugCompressionType::GNU, "zlib-gnu",
"Use zlib-gnu compression (deprecated)"))); "Use zlib-gnu compression (deprecated)")),
cl::cat(MCCategory));
static cl::opt<bool> static cl::opt<bool>
ShowInst("show-inst", cl::desc("Show internal instruction representation")); ShowInst("show-inst", cl::desc("Show internal instruction representation"),
cl::cat(MCCategory));
static cl::opt<bool> static cl::opt<bool>
ShowInstOperands("show-inst-operands", ShowInstOperands("show-inst-operands",
cl::desc("Show instructions operands as parsed")); cl::desc("Show instructions operands as parsed"),
cl::cat(MCCategory));
static cl::opt<unsigned> static cl::opt<unsigned>
OutputAsmVariant("output-asm-variant", OutputAsmVariant("output-asm-variant",
cl::desc("Syntax variant to use for output printing")); cl::desc("Syntax variant to use for output printing"),
cl::cat(MCCategory));
static cl::opt<bool> static cl::opt<bool>
PrintImmHex("print-imm-hex", cl::init(false), PrintImmHex("print-imm-hex", cl::init(false),
cl::desc("Prefer hex format for immediate values")); cl::desc("Prefer hex format for immediate values"),
cl::cat(MCCategory));
static cl::list<std::string> static cl::list<std::string>
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<bool> static cl::opt<bool>
PreserveComments("preserve-comments", PreserveComments("preserve-comments",
cl::desc("Preserve Comments in outputted assembly")); cl::desc("Preserve Comments in outputted assembly"),
cl::cat(MCCategory));
enum OutputFileType { enum OutputFileType {
OFT_Null, OFT_Null,
@ -102,86 +117,101 @@ enum OutputFileType {
OFT_ObjectFile OFT_ObjectFile
}; };
static cl::opt<OutputFileType> static cl::opt<OutputFileType>
FileType("filetype", cl::init(OFT_AssemblyFile), FileType("filetype", cl::init(OFT_AssemblyFile),
cl::desc("Choose an output file type:"), cl::desc("Choose an output file type:"),
cl::values( cl::values(clEnumValN(OFT_AssemblyFile, "asm",
clEnumValN(OFT_AssemblyFile, "asm", "Emit an assembly ('.s') file"),
"Emit an assembly ('.s') file"), clEnumValN(OFT_Null, "null",
clEnumValN(OFT_Null, "null", "Don't emit anything (for timing purposes)"),
"Don't emit anything (for timing purposes)"), clEnumValN(OFT_ObjectFile, "obj",
clEnumValN(OFT_ObjectFile, "obj", "Emit a native object ('.o') file")),
"Emit a native object ('.o') file"))); cl::cat(MCCategory));
static cl::list<std::string> IncludeDirs("I",
cl::desc("Directory of include files"),
cl::value_desc("directory"),
cl::Prefix, cl::cat(MCCategory));
static cl::opt<std::string>
ArchName("arch",
cl::desc("Target arch to assemble for, "
"see -version for available targets"),
cl::cat(MCCategory));
static cl::opt<std::string>
TripleName("triple",
cl::desc("Target triple to assemble for, "
"see -version for available targets"),
cl::cat(MCCategory));
static cl::opt<std::string>
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<std::string> static cl::list<std::string>
IncludeDirs("I", cl::desc("Directory of include files"), MAttrs("mattr", cl::CommaSeparated,
cl::value_desc("directory"), cl::Prefix); cl::desc("Target specific attributes (-mattr=help for details)"),
cl::value_desc("a1,+a2,-a3,..."), cl::cat(MCCategory));
static cl::opt<std::string>
ArchName("arch", cl::desc("Target arch to assemble for, "
"see -version for available targets"));
static cl::opt<std::string>
TripleName("triple", cl::desc("Target triple to assemble for, "
"see -version for available targets"));
static cl::opt<std::string>
MCPU("mcpu",
cl::desc("Target a specific cpu type (-mcpu=help for details)"),
cl::value_desc("cpu-name"),
cl::init(""));
static cl::list<std::string>
MAttrs("mattr",
cl::CommaSeparated,
cl::desc("Target specific attributes (-mattr=help for details)"),
cl::value_desc("a1,+a2,-a3,..."));
static cl::opt<bool> PIC("position-independent", static cl::opt<bool> PIC("position-independent",
cl::desc("Position independent"), cl::init(false)); cl::desc("Position independent"), cl::init(false),
cl::cat(MCCategory));
static cl::opt<bool> static cl::opt<bool>
LargeCodeModel("large-code-model", LargeCodeModel("large-code-model",
cl::desc("Create cfi directives that assume the code might " 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<bool> static cl::opt<bool>
NoInitialTextSection("n", cl::desc("Don't assume assembly file starts " NoInitialTextSection("n",
"in the text section")); cl::desc("Don't assume assembly file starts "
"in the text section"),
cl::cat(MCCategory));
static cl::opt<bool> static cl::opt<bool>
GenDwarfForAssembly("g", cl::desc("Generate dwarf debugging info for assembly " GenDwarfForAssembly("g",
"source files")); cl::desc("Generate dwarf debugging info for assembly "
"source files"),
cl::cat(MCCategory));
static cl::opt<std::string> static cl::opt<std::string>
DebugCompilationDir("fdebug-compilation-dir", DebugCompilationDir("fdebug-compilation-dir",
cl::desc("Specifies the debug info's compilation dir")); cl::desc("Specifies the debug info's compilation dir"),
cl::cat(MCCategory));
static cl::list<std::string> static cl::list<std::string> DebugPrefixMap(
DebugPrefixMap("fdebug-prefix-map", "fdebug-prefix-map", cl::desc("Map file source paths in debug info"),
cl::desc("Map file source paths in debug info"), cl::value_desc("= separated key-value pairs"), cl::cat(MCCategory));
cl::value_desc("= separated key-value pairs"));
static cl::opt<std::string> static cl::opt<std::string> MainFileName(
MainFileName("main-file-name", "main-file-name",
cl::desc("Specifies the name we should consider the input file")); cl::desc("Specifies the name we should consider the input file"),
cl::cat(MCCategory));
static cl::opt<bool> SaveTempLabels("save-temp-labels", static cl::opt<bool> SaveTempLabels("save-temp-labels",
cl::desc("Don't discard temporary labels")); cl::desc("Don't discard temporary labels"),
cl::cat(MCCategory));
static cl::opt<bool> LexMasmIntegers( static cl::opt<bool> LexMasmIntegers(
"masm-integers", "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<bool> LexMasmHexFloats( static cl::opt<bool> LexMasmHexFloats(
"masm-hexfloats", "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<bool> LexMotorolaIntegers( static cl::opt<bool> LexMotorolaIntegers(
"motorola-integers", "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<bool> NoExecStack("no-exec-stack", static cl::opt<bool> 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 { enum ActionType {
AC_AsLex, AC_AsLex,
@ -190,17 +220,16 @@ enum ActionType {
AC_MDisassemble, AC_MDisassemble,
}; };
static cl::opt<ActionType> static cl::opt<ActionType> Action(
Action(cl::desc("Action to perform:"), cl::desc("Action to perform:"), cl::init(AC_Assemble),
cl::init(AC_Assemble), cl::values(clEnumValN(AC_AsLex, "as-lex", "Lex tokens from a .s file"),
cl::values(clEnumValN(AC_AsLex, "as-lex", clEnumValN(AC_Assemble, "assemble",
"Lex tokens from a .s file"), "Assemble a .s file (default)"),
clEnumValN(AC_Assemble, "assemble", clEnumValN(AC_Disassemble, "disassemble",
"Assemble a .s file (default)"), "Disassemble strings of hex bytes"),
clEnumValN(AC_Disassemble, "disassemble", clEnumValN(AC_MDisassemble, "mdis",
"Disassemble strings of hex bytes"), "Marked up disassembly of strings of hex bytes")),
clEnumValN(AC_MDisassemble, "mdis", cl::cat(MCCategory));
"Marked up disassembly of strings of hex bytes")));
static const Target *GetTarget(const char *ProgName) { static const Target *GetTarget(const char *ProgName) {
// Figure out the target triple. // Figure out the target triple.
@ -331,6 +360,7 @@ int main(int argc, char **argv) {
// Register the target printer for --version. // Register the target printer for --version.
cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion); cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
cl::HideUnrelatedOptions({&MCCategory, &getColorCategory()});
cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n"); cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n");
const MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags(); const MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
setDwarfDebugFlags(argc, argv); setDwarfDebugFlags(argc, argv);

View File

@ -21,21 +21,29 @@
using namespace llvm; using namespace llvm;
static cl::OptionCategory ModextractCategory("Modextract Options");
static cl::opt<bool> static cl::opt<bool>
BinaryExtract("b", cl::desc("Whether to perform binary extraction")); BinaryExtract("b", cl::desc("Whether to perform binary extraction"),
cl::cat(ModextractCategory));
static cl::opt<std::string> OutputFilename("o", cl::Required, static cl::opt<std::string> OutputFilename("o", cl::Required,
cl::desc("Output filename"), cl::desc("Output filename"),
cl::value_desc("filename")); cl::value_desc("filename"),
cl::cat(ModextractCategory));
static cl::opt<std::string> static cl::opt<std::string> InputFilename(cl::Positional,
InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-")); cl::desc("<input bitcode>"),
cl::init("-"),
cl::cat(ModextractCategory));
static cl::opt<unsigned> ModuleIndex("n", cl::Required, static cl::opt<unsigned> ModuleIndex("n", cl::Required,
cl::desc("Index of module to extract"), cl::desc("Index of module to extract"),
cl::value_desc("index")); cl::value_desc("index"),
cl::cat(ModextractCategory));
int main(int argc, char **argv) { int main(int argc, char **argv) {
cl::HideUnrelatedOptions({&ModextractCategory, &getColorCategory()});
cl::ParseCommandLineOptions(argc, argv, "Module extractor"); cl::ParseCommandLineOptions(argc, argv, "Module extractor");
ExitOnError ExitOnErr("llvm-modextract: error: "); ExitOnError ExitOnErr("llvm-modextract: error: ");

View File

@ -1430,6 +1430,8 @@ int main(int Argc, const char **Argv) {
InitLLVM X(Argc, Argv); InitLLVM X(Argc, Argv);
ExitOnErr.setBanner("llvm-pdbutil: "); ExitOnErr.setBanner("llvm-pdbutil: ");
cl::HideUnrelatedOptions(
{&opts::TypeCategory, &opts::FilterCategory, &opts::OtherOptions});
cl::ParseCommandLineOptions(Argc, Argv, "LLVM PDB Dumper\n"); cl::ParseCommandLineOptions(Argc, Argv, "LLVM PDB Dumper\n");
if (opts::BytesSubcommand) { if (opts::BytesSubcommand) {

View File

@ -18,16 +18,20 @@
#include "llvm/Support/InitLLVM.h" #include "llvm/Support/InitLLVM.h"
#include "llvm/Support/TargetSelect.h" #include "llvm/Support/TargetSelect.h"
static cl::OptionCategory ProfGenCategory("ProfGen Options");
static cl::list<std::string> PerfTraceFilenames( static cl::list<std::string> PerfTraceFilenames(
"perfscript", cl::value_desc("perfscript"), cl::OneOrMore, "perfscript", cl::value_desc("perfscript"), cl::OneOrMore,
llvm::cl::MiscFlags::CommaSeparated, llvm::cl::MiscFlags::CommaSeparated,
cl::desc("Path of perf-script trace created by Linux perf tool with " 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<std::string> static cl::list<std::string>
BinaryFilenames("binary", cl::value_desc("binary"), cl::OneOrMore, BinaryFilenames("binary", cl::value_desc("binary"), cl::OneOrMore,
llvm::cl::MiscFlags::CommaSeparated, llvm::cl::MiscFlags::CommaSeparated,
cl::desc("Path of profiled binary files")); cl::desc("Path of profiled binary files"),
cl::cat(ProfGenCategory));
extern cl::opt<bool> ShowDisassemblyOnly; extern cl::opt<bool> ShowDisassemblyOnly;
@ -42,6 +46,7 @@ int main(int argc, const char *argv[]) {
InitializeAllTargetMCs(); InitializeAllTargetMCs();
InitializeAllDisassemblers(); InitializeAllDisassemblers();
cl::HideUnrelatedOptions({&ProfGenCategory, &getColorCategory()});
cl::ParseCommandLineOptions(argc, argv, "llvm SPGO profile generator\n"); cl::ParseCommandLineOptions(argc, argv, "llvm SPGO profile generator\n");
// Load binaries and parse perf events and samples // Load binaries and parse perf events and samples