Skip to content

Conversation

chelini
Copy link
Contributor

@chelini chelini commented Nov 25, 2024

The comment is misleading because attributes do not have elidePrintingDefaultValue bit. It appears that elidePrintingDefaultValue was never merged upstream (see: https://reviews.llvm.org/D135398 ), but the comment was likely introduced by mistake in a later revision (https://reviews.llvm.org/D135993.).

@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Nov 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 25, 2024

@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: lorenzo chelini (chelini)

Changes

The comment is misleading because attributes do not have elidePrintingDefaultValue bit. It appears that elidePrintingDefaultValue was never merged upstream (see: https://reviews.llvm.org/D135398 ), but the comment was likely introduced by mistake in a later revision (https://reviews.llvm.org/D135993.).


Full diff: https://github.com/llvm/llvm-project/pull/117564.diff

1 Files Affected:

  • (modified) mlir/tools/mlir-tblgen/OpFormatGen.cpp (+5-4)
diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index 8d2e15a941370c..03929eaaf55ff1 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -2033,8 +2033,8 @@ static void genPropDictPrinter(OperationFormat &fmt, Operator &op,
   for (const NamedAttribute *namedAttr : fmt.usedAttributes)
     body << "  elidedProps.push_back(\"" << namedAttr->name << "\");\n";
 
-  // Add code to check attributes for equality with the default value
-  // for attributes with the elidePrintingDefaultValue bit set.
+  // Add code to check attributes for equality with their default values.
+  // Default-valued attributes will not be printed when their value matches the default.
   for (const NamedAttribute &namedAttr : op.getAttributes()) {
     const Attribute &attr = namedAttr.attr;
     if (!attr.isDerivedAttr() && attr.hasDefaultValue()) {
@@ -2080,8 +2080,9 @@ static void genAttrDictPrinter(OperationFormat &fmt, Operator &op,
     body << "  elidedAttrs.push_back(\"" << key << "\");\n";
   for (const NamedAttribute *attr : fmt.usedAttributes)
     body << "  elidedAttrs.push_back(\"" << attr->name << "\");\n";
-  // Add code to check attributes for equality with the default value
-  // for attributes with the elidePrintingDefaultValue bit set.
+  
+  // Add code to check attributes for equality with their default values.
+  // Default-valued attributes will not be printed when their value matches the default.
   for (const NamedAttribute &namedAttr : op.getAttributes()) {
     const Attribute &attr = namedAttr.attr;
     if (!attr.isDerivedAttr() && attr.hasDefaultValue()) {

Copy link

github-actions bot commented Nov 25, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

chelini and others added 2 commits November 25, 2024 15:48
The comment is misleading because attributes do not have
`elidePrintingDefaultValue` bit. It appears that `elidePrintingDefaultValue`
was never merged upstream (see: https://reviews.llvm.org/D135398 ), but the
comment was likely introduced by mistake in a later revision
(https://reviews.llvm.org/D135993.).
@chelini chelini force-pushed the lchelini/mlir/improve-comment branch from e5a29ce to f7097b2 Compare November 25, 2024 14:49
@chelini chelini merged commit c9e606b into llvm:main Nov 25, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants