[Mlir-commits] [mlir] [mlir] Return from equals overload (PR #179655)
Ilgar Gamidov
llvmlistbot at llvm.org
Wed Feb 4 09:42:48 PST 2026
https://github.com/braam-76 updated https://github.com/llvm/llvm-project/pull/179655
>From 4be07449ae74e261af4b214f4101f9ec328b085e Mon Sep 17 00:00:00 2001
From: braam-76 <braam67.gamidov at yandex.com>
Date: Wed, 4 Feb 2026 16:14:42 +0300
Subject: [PATCH 1/2] [mlir] Return from equals overload
Closes #91233
mlir/include/mlir/ExecutionEngine/MemRefUtils.h:190:No 'return' statement in non-void function
---
mlir/include/mlir/ExecutionEngine/MemRefUtils.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mlir/include/mlir/ExecutionEngine/MemRefUtils.h b/mlir/include/mlir/ExecutionEngine/MemRefUtils.h
index e9471731afe13..c160a34207b2f 100644
--- a/mlir/include/mlir/ExecutionEngine/MemRefUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/MemRefUtils.h
@@ -186,11 +186,12 @@ class OwningMemRef {
}
OwningMemRef(const OwningMemRef &) = delete;
OwningMemRef &operator=(const OwningMemRef &) = delete;
- OwningMemRef &operator=(const OwningMemRef &&other) {
+ OwningMemRef &operator=(OwningMemRef &&other) {
freeFunc = other.freeFunc;
descriptor = other.descriptor;
other.freeFunc = nullptr;
memset(&other.descriptor, 0, sizeof(other.descriptor));
+ return *this;
}
OwningMemRef(OwningMemRef &&other) { *this = std::move(other); }
>From 5f73a4728283cf3c63c0bc3dc7c29e44a532057d Mon Sep 17 00:00:00 2001
From: braam-76 <braam67.gamidov at yandex.com>
Date: Wed, 4 Feb 2026 20:31:14 +0300
Subject: [PATCH 2/2] [mlir] Added OwningMemRef unit test
Pull request #179655
Closes #91233
mlir/include/mlir/ExecutionEngine/MemRefUtils.h:190:No 'return' statement in non-void function
---
mlir/unittests/ExecutionEngine/CMakeLists.txt | 1 +
.../ExecutionEngine/OwningMemRef.cpp | 25 +++++++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 mlir/unittests/ExecutionEngine/OwningMemRef.cpp
diff --git a/mlir/unittests/ExecutionEngine/CMakeLists.txt b/mlir/unittests/ExecutionEngine/CMakeLists.txt
index b83163e39c014..3e563c65736f5 100644
--- a/mlir/unittests/ExecutionEngine/CMakeLists.txt
+++ b/mlir/unittests/ExecutionEngine/CMakeLists.txt
@@ -9,6 +9,7 @@ add_mlir_unittest(MLIRExecutionEngineTests
DynamicMemRef.cpp
StridedMemRef.cpp
Invoke.cpp
+ OwningMemRef.cpp
)
mlir_target_link_libraries(MLIRExecutionEngineTests
diff --git a/mlir/unittests/ExecutionEngine/OwningMemRef.cpp b/mlir/unittests/ExecutionEngine/OwningMemRef.cpp
new file mode 100644
index 0000000000000..3ce11431a305d
--- /dev/null
+++ b/mlir/unittests/ExecutionEngine/OwningMemRef.cpp
@@ -0,0 +1,25 @@
+//===- StridedMemRef.cpp ----------------------------------------*- C++ -*-===//
+//
+// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/ExecutionEngine/MemRefUtils.h"
+
+#include "gmock/gmock.h"
+
+using namespace ::mlir;
+using namespace ::testing;
+
+TEST(OwningMemRef, assignOverloadChaining) {
+ int64_t mem1Shape[] = {3};
+ int64_t mem2Shape[] = {4};
+
+ OwningMemRef<float, 1> mem1(mem1Shape);
+ OwningMemRef<float, 1> mem2(mem2Shape);
+ OwningMemRef<float, 1> &ref = (mem1 = std::move(mem2));
+
+ EXPECT_EQ(&ref, &mem1);
+}
More information about the Mlir-commits
mailing list