[Mlir-commits] [mlir] [mlir-python] Fix duplicate EnumAttr builder registration across dialects. (PR #187191)
Maksim Levental
llvmlistbot at llvm.org
Wed Mar 18 23:15:23 PDT 2026
================
@@ -58,11 +58,14 @@ class MLIR_PYTHON_API_EXPORTED PyGlobals {
bool loadDialectModule(std::string_view dialectNamespace);
/// Adds a user-friendly Attribute builder.
- /// Raises an exception if the mapping already exists and replace == false.
+ /// Raises an exception if the mapping already exists and replace == false
+ /// and allow_existing == false.
+ /// Silently skips registration if allow_existing == true and the mapping
+ /// already exists (first registration wins).
----------------
makslevental wrote:
Yes an no. If a user by hand registers an attribute builder then yes it's under their control. But primarily this mechanism is being to gracefully handle overlapping registrations emitted by tablegen (such as the aforementioned FastFlags attr). If you look at the checked in TD lit test you'll that all such attributes are now emitted with the registration call having `allow_existing=True`.
https://github.com/llvm/llvm-project/pull/187191
More information about the Mlir-commits
mailing list