From fd012bb002cf1576ddd1f9b56ddb2140fbc515b8 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Tue, 15 Oct 2013 01:15:59 +0200 Subject: [PATCH 1/3] Hide obsucre LLVM flags on versions that support it. The idea is to hide any flags that an end user is unlikely to need so that the -help output gets clearer. Some of the flags are also downright confusing, as they seem similar to unrelated D concepts. The hidden flags are still available using -help-hidden. Unfortunately, this is only possible on LLVM 3.3+. --- driver/main.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/driver/main.cpp b/driver/main.cpp index 1197e84b263..e55177b1087 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -141,6 +141,59 @@ static void initFromString(char*& dest, const cl::opt& src) { } } + +#if LDC_LLVM_VER >= 303 +static void hide(llvm::StringMap& map, const char* name) { + // Check if option exists first for resilience against LLVM changes + // between versions. + if (map.count(name)) + map[name]->setHiddenFlag(cl::Hidden); +} + +/// Removes command line options exposed from within LLVM that are unlikely +/// to be useful for end users from the -help output. +static void hideLLVMOptions() { + llvm::StringMap map; + cl::getRegisteredOptions(map); + hide(map, "bounds-checking-single-trap"); + hide(map, "disable-spill-fusing"); + hide(map, "enable-correct-eh-support"); + hide(map, "enable-load-pre"); + hide(map, "enable-objc-arc-opts"); + hide(map, "enable-tbaa"); + hide(map, "fatal-assembler-warnings"); + hide(map, "internalize-public-api-file"); + hide(map, "internalize-public-api-list"); + hide(map, "join-liveintervals"); + hide(map, "limit-float-precision"); + hide(map, "mc-x86-disable-arith-relaxation"); + hide(map, "pre-RA-sched"); + hide(map, "print-after-all"); + hide(map, "print-before-all"); + hide(map, "print-machineinstrs"); + hide(map, "profile-estimator-loop-weight"); + hide(map, "profile-estimator-loop-weight"); + hide(map, "profile-file"); + hide(map, "profile-info-file"); + hide(map, "profile-verifier-noassert"); + hide(map, "regalloc"); + hide(map, "shrink-wrap"); + hide(map, "spiller"); + hide(map, "stats"); + hide(map, "strip-debug"); + hide(map, "struct-path-tbaa"); + hide(map, "time-passes"); + hide(map, "unit-at-a-time"); + hide(map, "verify-dom-info"); + hide(map, "verify-loop-info"); + hide(map, "verify-regalloc"); + hide(map, "verify-region-info"); + hide(map, "verify-scev"); + hide(map, "x86-early-ifcvt"); + hide(map, "x86-use-vzeroupper"); +} +#endif + int main(int argc, char **argv); /// Parses switches from the command line, any response files and the global @@ -195,6 +248,9 @@ static void parseCommandLine(int argc, char **argv, Strings &sourceFiles, bool & // Handle fixed-up arguments! cl::SetVersionPrinter(&printVersion); +#if LDC_LLVM_VER >= 303 + hideLLVMOptions(); +#endif cl::ParseCommandLineOptions(final_args.size(), const_cast(&final_args[0]), "LDC - the LLVM D compiler\n" #if LDC_LLVM_VER < 302 From 28cd8b0ad2630d92004f56c5748295bcbd98b687 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Tue, 15 Oct 2013 01:24:45 +0200 Subject: [PATCH 2/3] Capitalize option decriptions. --- driver/cl_options.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/driver/cl_options.cpp b/driver/cl_options.cpp index 023be21fb45..feba795ead5 100644 --- a/driver/cl_options.cpp +++ b/driver/cl_options.cpp @@ -28,7 +28,7 @@ cl::list fileList( cl::Positional, cl::desc("files")); cl::list runargs("run", - cl::desc("program args..."), + cl::desc("Runs the resulting program, passing the remaining arguments to it"), cl::Positional, cl::PositionalEatsArgs); @@ -165,11 +165,11 @@ cl::opt ddocFile("Df", // Json options static cl::opt doJson("X", - cl::desc("generate JSON file"), + cl::desc("Generate JSON file"), cl::location(global.params.doXGeneration)); cl::opt jsonFile("Xf", - cl::desc("write JSON file to "), + cl::desc("Write JSON file to "), cl::value_desc("filename"), cl::Prefix); @@ -206,7 +206,7 @@ static cl::list stringImportPaths("J", cl::Prefix); static cl::opt addMain("main", - cl::desc("add empty main() (e.g. for unittesting)"), + cl::desc("Add empty main() (e.g. for unittesting)"), cl::ZeroOrMore, cl::location(global.params.addMain)); From 7ca329e77ef410c53563efc6ffa3adee6e137329 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Tue, 15 Oct 2013 01:44:21 +0200 Subject: [PATCH 3/3] More accurate description for "-vv". Still not happy with it, but I feel it is still better than just "very verbose". --- gen/logger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen/logger.cpp b/gen/logger.cpp index aeeab3f214d..67a323b5cc5 100644 --- a/gen/logger.cpp +++ b/gen/logger.cpp @@ -50,7 +50,7 @@ namespace Logger static std::string indent_str; llvm::cl::opt _enabled("vv", - llvm::cl::desc("Very verbose"), + llvm::cl::desc("Print front-end/glue code debug log"), llvm::cl::ZeroOrMore); void indent()