[Mlir-commits] [mlir] [mlir] Fixing a regression that '-D' option of llvm-tblgen is unregistered. (PR #91329)

Daniel Chen llvmlistbot at llvm.org
Tue May 7 07:01:28 PDT 2024


https://github.com/DanielCChen created https://github.com/llvm/llvm-project/pull/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. 
This PR is to fix the regression. 

>From c0b08da56609dc9f2cb539a49ce7f77d5fe7ae71 Mon Sep 17 00:00:00 2001
From: cdchen-ca <cdchen at ca.ibm.com>
Date: Tue, 7 May 2024 09:56:24 -0400
Subject: [PATCH] [mlir] Fixing a regression that '-D' option of llvm-tblgen is
 unregistered.

---
 mlir/tools/mlir-src-sharder/mlir-src-sharder.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/mlir/tools/mlir-src-sharder/mlir-src-sharder.cpp b/mlir/tools/mlir-src-sharder/mlir-src-sharder.cpp
index dc1e2939c7d25..c29455f00c2f0 100644
--- a/mlir/tools/mlir-src-sharder/mlir-src-sharder.cpp
+++ b/mlir/tools/mlir-src-sharder/mlir-src-sharder.cpp
@@ -62,6 +62,14 @@ int main(int argc, char **argv) {
       "write-if-changed",
       llvm::cl::desc("Only write to the output file if it changed"));
 
+  // `ResetCommandLineParser` at the above unregistered the "D" option
+  // of `llvm-tblgen`, which caused `TestOps.cpp` to fail due to
+  // "Unknnown command line argument '-D...`" when a macros name is
+  // present. The following is a workaround to re-register it again.
+  llvm::cl::list<std::string> MacroNames(
+      "D", llvm::cl::desc("Name of the macro to be defined"),
+      llvm::cl::value_desc("macro name"), llvm::cl::Prefix);
+
   llvm::InitLLVM y(argc, argv);
   llvm::cl::ParseCommandLineOptions(argc, argv);
 



More information about the Mlir-commits mailing list