Skip to content

Conversation

joeyye-work
Copy link
Contributor

transform::PrintOp::build(OpBuilder &builder, OperationState &result, StringRef name) does not set name correctly. Calling PrintOp::build(builder, result, "whatever name") is going to end up with a PrintOp with no name.

This patch fixes it by replicating the approach from tablegen created code. Refer to build/mlir/include/mlir/Dialect/Transform/IR/TransformOps.cpp.inc

@llvmbot llvmbot added the mlir label Sep 21, 2023
@ftynse ftynse self-requested a review September 25, 2023 07:53
@llvmbot
Copy link
Member

llvmbot commented Sep 25, 2023

@llvm/pr-subscribers-mlir

Changes

transform::PrintOp::build(OpBuilder &builder, OperationState &result, StringRef name) does not set name correctly. Calling PrintOp::build(builder, result, "whatever name") is going to end up with a PrintOp with no name.

This patch fixes it by replicating the approach from tablegen created code. Refer to build/mlir/include/mlir/Dialect/Transform/IR/TransformOps.cpp.inc


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

1 Files Affected:

  • (modified) mlir/lib/Dialect/Transform/IR/TransformOps.cpp (+2-4)
diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
index 23284e14461d8f2..9bcec7ce27365bb 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
@@ -2311,10 +2311,8 @@ void transform::SequenceOp::build(OpBuilder &builder, OperationState &state,
 
 void transform::PrintOp::build(OpBuilder &builder, OperationState &result,
                                StringRef name) {
-  if (!name.empty()) {
-    result.addAttribute(PrintOp::getNameAttrName(result.name),
-                        builder.getStrArrayAttr(name));
-  }
+  if (!name.empty())
+    result.getOrAddProperties<Properties>().name = builder.getStringAttr(name);
 }
 
 void transform::PrintOp::build(OpBuilder &builder, OperationState &result,

@ftynse ftynse merged commit 214ce4d into llvm:main Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants