[PATCH] D104977: [perf] Fix a data race in the PerfJITEventListener

Eugene Zhulenev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 26 07:31:36 PDT 2021


ezhulenev created this revision.
Herald added subscribers: dcaballe, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, hiraditya.
ezhulenev requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer, nicolasvasilache.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104977

Files:
  llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
  utils/bazel/llvm-project-overlay/mlir/BUILD.bazel


Index: utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
===================================================================
--- utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -1497,9 +1497,27 @@
 
 cc_library(
     name = "SparseTensor",
-    srcs = glob(["lib/Dialect/SparseTensor/IR/*.cpp"]),
+    srcs = glob([
+        "lib/Dialect/SparseTensor/IR/*.cpp",
+    ]),
     hdrs = ["include/mlir/Dialect/SparseTensor/IR/SparseTensor.h"],
     includes = ["include"],
+    deps = [
+        ":IR",
+        ":SideEffectInterfaces",
+        ":SparseTensorAttrDefsIncGen",
+        ":SparseTensorOpsIncGen",
+        ":SparseTensorUtils",
+        ":StandardOps",
+        "//llvm:Support",
+    ],
+)
+
+cc_library(
+    name = "SparseTensorUtils",
+    srcs = glob(["lib/Dialect/SparseTensor/Utils/*.cpp"]),
+    hdrs = glob(["include/mlir/Dialect/SparseTensor/Utils/*.h"]),
+    includes = ["include"],
     deps = [
         ":IR",
         ":SideEffectInterfaces",
@@ -1535,17 +1553,6 @@
     ],
 )
 
-cc_library(
-    name = "SparseTensorUtils",
-    srcs = glob(["lib/Dialect/SparseTensor/Utils/*.cpp"]),
-    hdrs = glob(["include/mlir/Dialect/SparseTensor/Utils/*.h"]),
-    includes = ["include"],
-    deps = [
-        ":IR",
-        "//llvm:Support",
-    ],
-)
-
 td_library(
     name = "StdOpsTdFiles",
     srcs = [
Index: llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
===================================================================
--- llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
+++ llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
@@ -284,6 +284,9 @@
     NotifyCode(Name, *AddrOrErr, Size);
   }
 
+  // avoid races with writes
+  std::lock_guard<sys::Mutex> Guard(Mutex);
+
   Dumpstream->flush();
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104977.354677.patch
Type: text/x-patch
Size: 1842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210626/672e7cd6/attachment.bin>


More information about the llvm-commits mailing list