[Mlir-commits] [mlir] Avoid copies in getChecked (PR #147721)
Alexandru Lorinti
llvmlistbot at llvm.org
Fri Jul 18 04:23:02 PDT 2025
https://github.com/AlexandruLorinti updated https://github.com/llvm/llvm-project/pull/147721
>From 0daee71cb9e74370f400aaf0c95de6639788d9af Mon Sep 17 00:00:00 2001
From: Alexandru Lorinti <alexandru.lorinti at intel.com>
Date: Wed, 9 Jul 2025 16:12:20 +0300
Subject: [PATCH 1/2] avoid copies
---
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
index dbae2143b920a..3140f12c0b7e8 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -495,7 +495,7 @@ void DefGen::emitCheckedBuilder() {
MethodBody &body = m->body().indent();
auto scope = body.scope("return Base::getChecked(emitError, context", ");");
for (const auto ¶m : params)
- body << ", " << param.getName();
+ body << ", std::move(" << param.getName() << ")";
}
static SmallVector<MethodParameter>
>From 1c0face930c6235ea69d5cb90a98f78af1996265 Mon Sep 17 00:00:00 2001
From: Alexandru Lorinti <alexandru.lorinti at intel.com>
Date: Fri, 18 Jul 2025 05:35:47 +0300
Subject: [PATCH 2/2] updating tblgen test
---
mlir/test/mlir-tblgen/attrdefs.td | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mlir/test/mlir-tblgen/attrdefs.td b/mlir/test/mlir-tblgen/attrdefs.td
index d47411d6e860a..a809611fd0aec 100644
--- a/mlir/test/mlir-tblgen/attrdefs.td
+++ b/mlir/test/mlir-tblgen/attrdefs.td
@@ -115,6 +115,11 @@ def B_CompoundAttrA : TestAttr<"CompoundA"> {
// DEF: return new (allocator.allocate<CompoundAAttrStorage>())
// DEF-SAME: CompoundAAttrStorage(std::move(widthOfSomething), std::move(exampleTdType), std::move(apFloat), std::move(dims), std::move(inner));
+// DEF: CompoundAAttr CompoundAAttr::getChecked(
+// DEF-SAME: int widthOfSomething, ::test::SimpleTypeA exampleTdType, ::llvm::APFloat apFloat, ::llvm::ArrayRef<int> dims, ::mlir::Type inner
+// DEF-SAME: )
+// DEF-NEXT: return Base::getChecked(emitError, context, std::move(widthOfSomething), std::move(exampleTdType), std::move(apFloat), std::move(dims), std::move(inner));
+
// DEF: ::mlir::Type CompoundAAttr::getInner() const {
// DEF-NEXT: return getImpl()->inner;
}
More information about the Mlir-commits
mailing list