Skip to content

Commit

Permalink
Do not remove LLVM "internal" options (onnx#2475)
Browse files Browse the repository at this point in the history
* - Do not remove LLVM "internal" options such as --debug
- Clean up some header includes and library link dependencies

Signed-off-by: Gong Su <[email protected]>

* Clang format

Signed-off-by: Gong Su <[email protected]>

* Fix general options not showing with --help-hidden|--help-list-hidden

Signed-off-by: Gong Su <[email protected]>

---------

Signed-off-by: Gong Su <[email protected]>
  • Loading branch information
gongsu832 authored Sep 5, 2023
1 parent a602fb7 commit ef535dd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/Compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ add_onnx_mlir_library(OMCompilerUtils
EXCLUDE_FROM_OM_LIBS

DEPENDS
ExternalUtil
ExternalUtil
llc
opt

Expand All @@ -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.
Expand All @@ -193,7 +191,6 @@ add_onnx_mlir_library(OMCompiler

DEPENDS
OMCompilerUtils
ExternalUtil

INCLUDE_DIRS PRIVATE
${FILE_GENERATE_DIR}
Expand All @@ -204,7 +201,6 @@ add_onnx_mlir_library(OMCompiler
EXCLUDE_FROM_OM_LIBS

LINK_LIBS PRIVATE
OMCompilerDialects
OMCompilerUtils
)

Expand Down
8 changes: 7 additions & 1 deletion src/Compiler/CompilerOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,13 @@ std::string getToolPath(
// result in a unknown option error.
void removeUnrelatedOptions(
const std::vector<llvm::cl::OptionCategory *> 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<llvm::cl::OptionCategory *> optCategories(Categories);
optCategories.push_back(&llvm::cl::getGeneralCategory());
llvm::cl::HideUnrelatedOptions(optCategories);

llvm::StringMap<llvm::cl::Option *> &optMap =
llvm::cl::getRegisteredOptions();
Expand Down
1 change: 0 additions & 1 deletion src/Compiler/CompilerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <fstream>
Expand Down
1 change: 0 additions & 1 deletion src/Compiler/OnnxMlirCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ef535dd

Please sign in to comment.