[Mlir-commits] [mlir] [mlir-python] Fix duplicate EnumAttr builder registration across dialects. (PR #187191)

Jacques Pienaar llvmlistbot at llvm.org
Wed Mar 18 22:57:47 PDT 2026


================
@@ -97,14 +97,19 @@ bool PyGlobals::loadDialectModule(std::string_view dialectNamespace) {
 }
 
 void PyGlobals::registerAttributeBuilder(const std::string &attributeKind,
-                                         nb::callable pyFunc, bool replace) {
+                                         nb::callable pyFunc, bool replace,
+                                         bool allow_existing) {
   nb::ft_lock_guard lock(mutex);
   nb::object &found = attributeBuilderMap[attributeKind];
-  if (found && !replace) {
-    throw std::runtime_error(
-        nanobind::detail::join("Attribute builder for '", attributeKind,
-                               "' is already registered with func: ",
-                               nb::cast<std::string>(nb::str(found))));
+  if (found) {
+    if (allow_existing)
----------------
jpienaar wrote:

WDYT about LDBG's whether skipped or replaced for folks debugging.?

https://github.com/llvm/llvm-project/pull/187191


More information about the Mlir-commits mailing list