Skip to content

[MLIR] Use static function to replace lambda function #127333

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

Closed
wants to merge 2 commits into from
Closed

Conversation

gfvvz
Copy link

@gfvvz gfvvz commented Feb 15, 2025

Use static function to replace lamda function due to the lamda function's lifetime issue, which may be report an compilation error when use this template.

Copy link

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.

@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Feb 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 15, 2025

@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: Leon Lu (gfvvz)

Changes

Use static function to replace lamda function due to the lamda function's lifetime issue, which may be report an compilation error when use this template.


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

1 Files Affected:

  • (modified) mlir/include/mlir/IR/OperationSupport.h (+4-3)
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index d4035d14ab746..6bb38eb0246f0 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -997,13 +997,14 @@ struct OperationState {
     if (!properties) {
       T *p = new T{};
       properties = p;
-      propertiesDeleter = [](OpaqueProperties prop) {
+      static auto deleter = [](OpaqueProperties prop) {
         delete prop.as<const T *>();
       };
-      propertiesSetter = [](OpaqueProperties new_prop,
-                            const OpaqueProperties prop) {
+      propertiesDeleter = deleter;
+      static auto setter = [](OpaqueProperties new_prop, const OpaqueProperties prop) {
         *new_prop.as<T *>() = *prop.as<const T *>();
       };
+      propertiesSetter = setter;
       propertiesId = TypeID::get<T>();
     }
     assert(propertiesId == TypeID::get<T>() && "Inconsistent properties");

Use static function to replace lamda function due to the lamda function's lifetime issue, which may be report an compilation error when use this template.

Signed-off-by: Leon Lu <[email protected]>
@gfvvz gfvvz changed the title Use static function to replace lamda function [MLIR] Use static function to replace lamda function Feb 15, 2025
@joker-eph joker-eph changed the title [MLIR] Use static function to replace lamda function [MLIR] Use static function to replace lambda function Feb 16, 2025
@joker-eph
Copy link
Collaborator

Seems like a duplicate from #126140 ? (the same comment applies: this looks like a false positive to me: #126600 ); we should instead disable the warning.

@gfvvz
Copy link
Author

gfvvz commented Feb 16, 2025

Seems like a duplicate from #126140 ? (the same comment applies: this looks like a false positive to me: #126600 ); we should instead disable the warning.

OK, I am fine with current temperary fix, and wait for the clang side final fix. Thanks for the infomation.

@gfvvz gfvvz closed this Feb 16, 2025
@gfvvz
Copy link
Author

gfvvz commented Feb 16, 2025

Close this PR since there is temporary fix with latest code base, and wait for clang side's final fix.

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