[clang] Added erase() to fix memory leak of mlir/unittests/IR/InterfaceTest.cpp (PR #65583)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 7 01:50:54 PDT 2023
https://github.com/wenzhi-cui created https://github.com/llvm/llvm-project/pull/65583:
None
>From 76107e6a14ca1f496d29bc2f7cb752f39f2665bf Mon Sep 17 00:00:00 2001
From: wenzhi-cui <wcui at google.com>
Date: Thu, 7 Sep 2023 11:13:45 +0800
Subject: [PATCH 1/2] Fix AtomicInterfacesTdFiles missing deps/typos in Bazel
---
.../llvm-project-overlay/mlir/BUILD.bazel | 36 +++++++++++--------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index c9aa819a8f8cbbd..12a8f192e2047f5 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -7,14 +7,14 @@
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
-load(":tblgen.bzl", "gentbl_cc_library", "td_library")
-load(":linalggen.bzl", "genlinalg")
load(
":build_defs.bzl",
"cc_headers_only",
"if_cuda_available",
"mlir_c_api_cc_library",
)
+load(":linalggen.bzl", "genlinalg")
+load(":tblgen.bzl", "gentbl_cc_library", "td_library")
package(
default_visibility = ["//visibility:public"],
@@ -8841,7 +8841,10 @@ td_library(
name = "AtomicInterfacesTdFiles",
srcs = ["include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.td"],
includes = ["include"],
- deps = [":OpBaseTdFiles"],
+ deps = [
+ ":ControlFlowInterfacesTdFiles",
+ ":OpBaseTdFiles",
+ ],
)
gentbl_cc_library(
@@ -8858,7 +8861,9 @@ gentbl_cc_library(
],
tblgen = ":mlir-tblgen",
td_file = "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.td",
- deps = [":AtomicInterfacesTdFiles"],
+ deps = [
+ ":AtomicInterfacesTdFiles",
+ ],
)
cc_library(
@@ -8867,8 +8872,9 @@ cc_library(
hdrs = ["include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.h"],
includes = ["include"],
deps = [
- ":IR",
":AtomicInterfacesIncGen",
+ ":ControlFlowInterfaces",
+ ":IR",
"//llvm:Support",
],
)
@@ -8905,8 +8911,8 @@ td_library(
],
includes = ["include"],
deps = [
- ":OpBaseTdFiles",
":AtomicInterfacesTdFiles",
+ ":OpBaseTdFiles",
],
)
@@ -9026,14 +9032,15 @@ cc_library(
],
exclude =
[
- "include/mlir/Dialect/OpenACCMPCommonInterfaces/AtomicInterfaces.h",
+ "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.h",
],
),
includes = ["include"],
textual_hdrs = [
- "include/mlir/Dialect/OpenACCMPCommonInterfaces/AtomicInterfaces.h",
+ "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.h",
],
deps = [
+ ":AtomicInterfacesIncGen",
":AtomicInterfaces",
":ControlFlowInterfaces",
":IR",
@@ -9073,21 +9080,19 @@ gentbl_cc_library(
td_library(
name = "OpenMPOpsTdFiles",
srcs = [
+ "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.td",
"include/mlir/Dialect/OpenMP/OmpCommon.td",
"include/mlir/Dialect/OpenMP/OpenMPOps.td",
"include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td",
"include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td",
- "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.td",
],
deps = [
+ ":AtomicInterfacesTdFiles",
":LLVMOpsTdFiles",
":OpBaseTdFiles",
- ":AtomicInterfacesTdFiles",
],
)
-
-
gentbl_cc_library(
name = "OpenMPOpsIncGen",
tbl_outs = [
@@ -9194,15 +9199,16 @@ cc_library(
exclude =
[
"include/mlir/Dialect/OpenMP/OpenMPInterfaces.h",
- "include/mlir/Dialect/OpenACCMPCommonInterfaces/AtomicInterfaces.h",
+ "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.h",
],
),
includes = ["include"],
textual_hdrs = [
"include/mlir/Dialect/OpenMP/OpenMPInterfaces.h",
- "include/mlir/Dialect/OpenACCMPCommonInterfaces/AtomicInterfaces.h",
+ "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.h",
],
deps = [
+ ":AtomicInterfacesIncGen",
":AtomicInterfaces",
":ControlFlowInterfaces",
":FuncDialect",
@@ -9878,8 +9884,8 @@ cc_library(
":FuncDialect",
":FunctionInterfaces",
":GPUDialect",
- ":IndexDialect",
":IR",
+ ":IndexDialect",
":LinalgDialect",
":LinalgMatchOpsIncGen",
":LinalgTransformEnumsIncGen",
>From f6a98ae66a9eacca769053360fa6a9880ddd79cb Mon Sep 17 00:00:00 2001
From: wenzhi-cui <wcui at google.com>
Date: Thu, 7 Sep 2023 16:47:20 +0800
Subject: [PATCH 2/2] Add erase test op to avoid memory leak
---
mlir/unittests/IR/InterfaceTest.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/mlir/unittests/IR/InterfaceTest.cpp b/mlir/unittests/IR/InterfaceTest.cpp
index 2be9e70dd59e8f1..621a1c5fa18f3f8 100644
--- a/mlir/unittests/IR/InterfaceTest.cpp
+++ b/mlir/unittests/IR/InterfaceTest.cpp
@@ -68,4 +68,5 @@ TEST(InterfaceTest, TestCustomClassOf) {
EXPECT_TRUE(isa<TestOptionallyImplementedOpInterface>(*op));
op.setImplementsInterface(false);
EXPECT_FALSE(isa<TestOptionallyImplementedOpInterface>(*op));
+ op.erase();
}
More information about the cfe-commits
mailing list