Skip to content

Commit f97f04e

Browse files
authored
[mlir] Fixing a regression that '-D' option of llvm-tblgen is unregistered. (#91329)
PR #89664 introduced a regression that it unregistered llvm-tblgen option `-D` for macros. The test `TestOps.cpp` failed due to passing a macros to llvm-tblgen. It caused our internal build to fail because we append `-DLOCAL_NAME` into `LLVM_TABLEGEN_FLANGS` in `llvm/lib/cmake/llvm/TableGen.cmake` as ``` list(APPEND LLVM_TABLEGEN_FLAGS "-DLOCAL_NAME") ``` And in `./llvm/lib/Target/PowerPC/PPC.td`, we check it for some downstream code as: ``` ... #ifdef LOCAL_NAME ... #endif ``` Now we got error message from mlir-src-sharder as ``` mlir-src-sharder -op-shard-index=1 -DLOCAL_NAME llvm-project/mlir/test/lib/Dialect/Test/TestOps.cpp --write-if-changed -o tools/mlir/test/lib/Dialect/Test/TestOps.1.cpp -d tools/mlir/test/lib/Dialect/Test/TestOps.1.cpp.d mlir-src-sharder: Unknown command line argument '-DLOCAL_NAME'. Try: 'llvm-project/build/bin/mlir-src-sharder --help' mlir-src-sharder: Did you mean '-I'? ``` This PR is to fix the regression.
1 parent 40b322b commit f97f04e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mlir/tools/mlir-src-sharder/mlir-src-sharder.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ int main(int argc, char **argv) {
6262
"write-if-changed",
6363
llvm::cl::desc("Only write to the output file if it changed"));
6464

65+
// `ResetCommandLineParser` at the above unregistered the "D" option
66+
// of `llvm-tblgen`, which caused `TestOps.cpp` to fail due to
67+
// "Unknnown command line argument '-D...`" when a macros name is
68+
// present. The following is a workaround to re-register it again.
69+
llvm::cl::list<std::string> MacroNames(
70+
"D",
71+
llvm::cl::desc(
72+
"Name of the macro to be defined -- ignored by mlir-src-sharder"),
73+
llvm::cl::value_desc("macro name"), llvm::cl::Prefix);
74+
6575
llvm::InitLLVM y(argc, argv);
6676
llvm::cl::ParseCommandLineOptions(argc, argv);
6777

0 commit comments

Comments
 (0)