[Mlir-commits] [mlir] Use static function to replace lamda function (PR #127333)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Feb 15 07:33:12 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Leon Lu (gfvvz)
<details>
<summary>Changes</summary>
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
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");
``````````
</details>
https://github.com/llvm/llvm-project/pull/127333
More information about the Mlir-commits
mailing list