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

Maksim Levental llvmlistbot at llvm.org
Wed Mar 18 23:31:52 PDT 2026


================
@@ -94,7 +99,11 @@ static bool emitAttributeBuilder(const EnumInfo &enumInfo, raw_ostream &os) {
     return false;
 
   int64_t bitwidth = enumInfo.getBitwidth();
-  os << formatv("@register_attribute_builder(\"{0}\")\n",
+  // These builders may be emitted by multiple dialect enum_gen files when
+  // dialects share enum definitions via .td includes. Use allow_existing=True
+  // so that the first loaded dialect registers the builder and subsequent
+  // loads silently skip (first-registration wins).
----------------
makslevental wrote:

Hmmm I thought I was some doc or doc string that recommends this. I'll try to find it.

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


More information about the Mlir-commits mailing list