[Mlir-commits] [mlir] Use static function to replace lamda function (PR #127333)
Leon Lu
llvmlistbot at llvm.org
Sat Feb 15 07:38:10 PST 2025
https://github.com/gfvvz updated https://github.com/llvm/llvm-project/pull/127333
>From 037b698a7a5e7d46e40b89fb3059694319d7b39d Mon Sep 17 00:00:00 2001
From: Leon Lu <gfvvz at 163.com>
Date: Sat, 15 Feb 2025 23:27:46 +0800
Subject: [PATCH] Use static function to replace lamda function
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 <gfvvz at 163.com>
---
mlir/include/mlir/IR/OperationSupport.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index d4035d14ab746..222519f5bc630 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -997,13 +997,15 @@ 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");
More information about the Mlir-commits
mailing list