Skip to content

Avoid copies in getChecked #147721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AlexandruLorinti
Copy link

Amending #68067 ; adding std::move to getChecked method as well.

Copy link

github-actions bot commented Jul 9, 2025

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@AlexandruLorinti AlexandruLorinti marked this pull request as ready for review July 9, 2025 13:17
@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Jul 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 9, 2025

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-core

Author: Alexandru Lorinti (AlexandruLorinti)

Changes

Amending #68067 ; adding std::move to getChecked method as well.


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

1 Files Affected:

  • (modified) mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp (+1-1)
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
index d9aa901ee2b28..5f6e7e7d4ab35 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 &param : params)
-    body << ", " << param.getName();
+    body << ", std::move(" << param.getName() << ")";
 }
 
 static SmallVector<MethodParameter>

@joker-eph
Copy link
Collaborator

Hi,

Thanks for the contribution! I would think there would be a tablegen test to update? Otherwise we probably miss coverage.

As I remember it: I couldn't add move to the getChecked() sequence because in assert build we do getChecked() as part of the get(), and that would lead to a use-after-move issue.
But maybe you're only touching one level further in the call-stack?

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