Skip to content

Commit

Permalink
[tools] add -help option for opt. (#7002)
Browse files Browse the repository at this point in the history
Add -help option to opt in opt.cpp.

The -help option for opt in clean llvm3.7 was disabled with 
[disable
-help](d5bb308#diff-1c7e1b16bc72f52ebd811ef2a24aa91fc4df0f9b47c279b75d0bbb0ae1684d0aR1719)

Fixes #5514
  • Loading branch information
python3kgae authored Nov 16, 2024
1 parent ee98b2e commit 72b353a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/HLSL/opt/help.ll
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions tools/opt/opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> Help("help", cl::desc("Print help"));
// HLSL Change Ends

static cl::opt<bool>
OptLevelO1("O1",
cl::desc("Optimization level 1. Similar to clang -O1"));
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 72b353a

Please sign in to comment.