[Mlir-commits] [mlir] [mlir-tblgen] Suffix underscore to prevent conflict (PR #166017)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Nov 1 13:11:32 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core
Author: Hsiang-Chieh Tsou (hsjts0u)
<details>
<summary>Changes</summary>
In the case where the property name is value, the generated op def file would have a collision for hash_value.
---
Full diff: https://github.com/llvm/llvm-project/pull/166017.diff
2 Files Affected:
- (modified) mlir/test/mlir-tblgen/op-properties.td (+7-7)
- (modified) mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp (+2-2)
``````````diff
diff --git a/mlir/test/mlir-tblgen/op-properties.td b/mlir/test/mlir-tblgen/op-properties.td
index a9c784cba0b6d..cb9bd3dc868fe 100644
--- a/mlir/test/mlir-tblgen/op-properties.td
+++ b/mlir/test/mlir-tblgen/op-properties.td
@@ -32,7 +32,7 @@ def OpWithProps : NS_Op<"op_with_props"> {
ArrayProp<StringProp>:$strings,
DefaultValuedProp<I32Prop, "0">:$default_int,
OptionalProp<I64Prop>:$optional,
- DefaultI64Array:$intArray
+ DefaultI64Array:$value
);
}
@@ -94,10 +94,10 @@ def OpWithOptionalPropsAndAttrs :
// DECL: ::llvm::ArrayRef<std::string> getStrings()
// DECL: using default_intTy = int32_t;
// DECL: default_intTy default_int = 0;
-// DECL: intArrayTy intArray = ::llvm::SmallVector<int64_t>{};
-// DECL: ::llvm::ArrayRef<int64_t> getIntArray()
+// DECL: valueTy value = ::llvm::SmallVector<int64_t>{};
+// DECL: ::llvm::ArrayRef<int64_t> getValue()
// DECL: return ::llvm::ArrayRef<int64_t>{propStorage}
-// DECL: void setIntArray(::llvm::ArrayRef<int64_t> propValue)
+// DECL: void setValue(::llvm::ArrayRef<int64_t> propValue)
// DECL: propStorage.assign
// DECL-LABEL: class OpWithProps :
// DECL: setString(::llvm::StringRef newString)
@@ -111,14 +111,14 @@ def OpWithOptionalPropsAndAttrs :
// DECL-SAME: ::llvm::ArrayRef<std::string> strings,
// DECL-SAME: /*optional*/int32_t default_int = 0,
// DECL-SAME: /*optional*/std::optional<int64_t> optional = std::nullopt,
-// DECL-SAME: /*optional*/::llvm::ArrayRef<int64_t> intArray = ::llvm::ArrayRef<int64_t>{});
+// DECL-SAME: /*optional*/::llvm::ArrayRef<int64_t> value = ::llvm::ArrayRef<int64_t>{});
// DEFS-LABEL: OpWithProps::computePropertiesHash
-// DEFS: hash_intArray
+// DEFS: hash_value_
// DEFS: using ::llvm::hash_value;
// DEFS-NEXT: return hash_value(::llvm::ArrayRef<int64_t>{propStorage})
// DEFS: hash_value(prop.optional)
-// DEFS: hash_intArray(prop.intArray)
+// DEFS: hash_value_(prop.value)
// -----
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 371864830a3c1..f92a26fb10e61 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -1629,7 +1629,7 @@ void OpEmitter::genPropertiesSupport() {
// Hashing for the property
const char *propHashFmt = R"decl(
- auto hash_{0} = [] (const auto &propStorage) -> llvm::hash_code {
+ auto hash_{0}_ = [] (const auto &propStorage) -> llvm::hash_code {
using ::llvm::hash_value;
return {1};
};
@@ -1655,7 +1655,7 @@ void OpEmitter::genPropertiesSupport() {
if (const auto *namedProperty =
llvm::dyn_cast_if_present<const NamedProperty *>(attrOrProp)) {
if (!namedProperty->prop.getHashPropertyCall().empty()) {
- hashMethod << "\n hash_" << namedProperty->name << "(prop."
+ hashMethod << "\n hash_" << namedProperty->name << "_(prop."
<< namedProperty->name << ")";
} else {
hashMethod << "\n hash_value(prop." << namedProperty->name
``````````
</details>
https://github.com/llvm/llvm-project/pull/166017
More information about the Mlir-commits
mailing list