Skip to content

Commit 72b353a

Browse files
authored
[tools] add -help option for opt. (microsoft#7002)
Add -help option to opt in opt.cpp. The -help option for opt in clean llvm3.7 was disabled with [disable -help](microsoft@d5bb308#diff-1c7e1b16bc72f52ebd811ef2a24aa91fc4df0f9b47c279b75d0bbb0ae1684d0aR1719) Fixes microsoft#5514
1 parent ee98b2e commit 72b353a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

test/HLSL/opt/help.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
; RUN: opt -help | FileCheck %s
2+
3+
; Make sure the help message is printed.
4+
; CHECK: -O1
5+
; CHECK-SAME: - Optimization level 1. Similar to clang -O1

tools/opt/opt.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ StandardLinkOpts("std-link-opts",
128128
cl::desc("Include the standard link time optimizations"));
129129
#endif // HLSL Change Ends
130130

131+
// HLSL Change Starts: add help option.
132+
static cl::opt<bool> Help("help", cl::desc("Print help"));
133+
// HLSL Change Ends
134+
131135
static cl::opt<bool>
132136
OptLevelO1("O1",
133137
cl::desc("Optimization level 1. Similar to clang -O1"));
@@ -383,6 +387,12 @@ int __cdecl main(int argc, char **argv) {
383387

384388
cl::ParseCommandLineOptions(argc, argv,
385389
"llvm .bc -> .bc modular optimizer and analysis printer\n");
390+
// HLSL Change Starts: add help option.
391+
if (Help) {
392+
cl::PrintHelpMessage();
393+
return 2;
394+
}
395+
// HLSL Change Ends
386396

387397
if (AnalyzeOnly && NoOutput) {
388398
errs() << argv[0] << ": analyze mode conflicts with no-output mode.\n";

0 commit comments

Comments
 (0)