From 5c716c46b5741e7d0cb26222d3c74e8685374ff1 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 6 Nov 2024 13:31:59 -0500 Subject: [PATCH 1/2] [tools] add -help option for opt. Add -help option to opt in opt.cpp. The -help option for opt in clean llvm3.7 was disabled with https://github.com/microsoft/DirectXShaderCompiler/commit/d5bb3089cf20456d70941b2b00febd7f7dde4a53#diff-1c7e1b16bc72f52ebd811ef2a24aa91fc4df0f9b47c279b75d0bbb0ae1684d0aR1719 Fixes #5514 --- test/HLSL/opt/help.ll | 5 +++++ tools/opt/opt.cpp | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 test/HLSL/opt/help.ll 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..a7e9c98959 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"; From 7d60335701b247ea7bbf4288e3aee52cab800d49 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 7 Nov 2024 18:54:12 +0000 Subject: [PATCH 2/2] chore: autopublish 2024-11-07T18:54:11Z --- tools/opt/opt.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index a7e9c98959..faba610d5f 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -387,12 +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. + // HLSL Change Starts: add help option. if (Help) { - cl::PrintHelpMessage(); - return 2; + cl::PrintHelpMessage(); + return 2; } -// HLSL Change Ends + // HLSL Change Ends if (AnalyzeOnly && NoOutput) { errs() << argv[0] << ": analyze mode conflicts with no-output mode.\n";