diff --git a/test/HLSL/opt/help.ll b/test/HLSL/opt/help.ll new file mode 100644 index 0000000000..8dbe168029 --- /dev/null +++ b/test/HLSL/opt/help.ll @@ -0,0 +1,5 @@ +; RUN: opt -help | FileCheck %s + +; Make sure the help message is printed. +; CHECK: -O1 +; CHECK-SAME: - Optimization level 1. Similar to clang -O1 diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 972a266b30..faba610d5f 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -128,6 +128,10 @@ StandardLinkOpts("std-link-opts", cl::desc("Include the standard link time optimizations")); #endif // HLSL Change Ends +// HLSL Change Starts: add help option. +static cl::opt Help("help", cl::desc("Print help")); +// HLSL Change Ends + static cl::opt OptLevelO1("O1", cl::desc("Optimization level 1. Similar to clang -O1")); @@ -383,6 +387,12 @@ int __cdecl main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .bc modular optimizer and analysis printer\n"); + // HLSL Change Starts: add help option. + if (Help) { + cl::PrintHelpMessage(); + return 2; + } + // HLSL Change Ends if (AnalyzeOnly && NoOutput) { errs() << argv[0] << ": analyze mode conflicts with no-output mode.\n";