From ef535ddd918f6c5833423eb0e39e89a41911f5f9 Mon Sep 17 00:00:00 2001 From: gongsu832 Date: Tue, 5 Sep 2023 17:58:02 -0400 Subject: [PATCH] Do not remove LLVM "internal" options (#2475) * - Do not remove LLVM "internal" options such as --debug - Clean up some header includes and library link dependencies Signed-off-by: Gong Su * Clang format Signed-off-by: Gong Su * Fix general options not showing with --help-hidden|--help-list-hidden Signed-off-by: Gong Su --------- Signed-off-by: Gong Su --- src/Compiler/CMakeLists.txt | 6 +----- src/Compiler/CompilerOptions.cpp | 8 +++++++- src/Compiler/CompilerUtils.cpp | 1 - src/Compiler/OnnxMlirCompiler.cpp | 1 - 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Compiler/CMakeLists.txt b/src/Compiler/CMakeLists.txt index 33abd59397..1b086237be 100644 --- a/src/Compiler/CMakeLists.txt +++ b/src/Compiler/CMakeLists.txt @@ -152,7 +152,7 @@ add_onnx_mlir_library(OMCompilerUtils EXCLUDE_FROM_OM_LIBS DEPENDS - ExternalUtil + ExternalUtil llc opt @@ -163,12 +163,10 @@ add_onnx_mlir_library(OMCompilerUtils ${ONNX_MLIR_SRC_ROOT}/include LINK_LIBS PUBLIC - ${OMLibs} OMCompilerDialects OMCompilerPasses OMAccelerator OMVersion - MLIRIR # Link LLVM libraries necessary to query which target architectures # are configured. @@ -193,7 +191,6 @@ add_onnx_mlir_library(OMCompiler DEPENDS OMCompilerUtils - ExternalUtil INCLUDE_DIRS PRIVATE ${FILE_GENERATE_DIR} @@ -204,7 +201,6 @@ add_onnx_mlir_library(OMCompiler EXCLUDE_FROM_OM_LIBS LINK_LIBS PRIVATE - OMCompilerDialects OMCompilerUtils ) diff --git a/src/Compiler/CompilerOptions.cpp b/src/Compiler/CompilerOptions.cpp index e0dfe37a0f..2d6e78964b 100644 --- a/src/Compiler/CompilerOptions.cpp +++ b/src/Compiler/CompilerOptions.cpp @@ -1010,7 +1010,13 @@ std::string getToolPath( // result in a unknown option error. void removeUnrelatedOptions( const std::vector Categories) { - llvm::cl::HideUnrelatedOptions(Categories); + // Do not remove LLVM "internal" options such as --debug + // that do not have a category (and therefore placed + // under the general category). So we add the general + // category to the list of not-really-hidden options. + std::vector optCategories(Categories); + optCategories.push_back(&llvm::cl::getGeneralCategory()); + llvm::cl::HideUnrelatedOptions(optCategories); llvm::StringMap &optMap = llvm::cl::getRegisteredOptions(); diff --git a/src/Compiler/CompilerUtils.cpp b/src/Compiler/CompilerUtils.cpp index 44c9dbefa0..284e717b35 100644 --- a/src/Compiler/CompilerUtils.cpp +++ b/src/Compiler/CompilerUtils.cpp @@ -39,7 +39,6 @@ #include "src/Compiler/CompilerOptions.hpp" #include "src/Compiler/CompilerPasses.hpp" #include "src/Compiler/HeapReporter.hpp" -#include "src/Dialect/ONNX/ONNXDialect.hpp" #include "src/Version/Version.hpp" #include diff --git a/src/Compiler/OnnxMlirCompiler.cpp b/src/Compiler/OnnxMlirCompiler.cpp index 2cd345c214..a1345e7c49 100644 --- a/src/Compiler/OnnxMlirCompiler.cpp +++ b/src/Compiler/OnnxMlirCompiler.cpp @@ -10,7 +10,6 @@ //===----------------------------------------------------------------------===// #include "include/OnnxMlirCompiler.h" -#include "src/Compiler/CompilerDialects.hpp" #include "src/Compiler/CompilerOptions.hpp" #include "src/Compiler/CompilerUtils.hpp" #include "llvm/Support/FileSystem.h"