From 260c6f5e5f796fbc9eb4b84b60632e48c53a61e5 Mon Sep 17 00:00:00 2001 From: Eugene Zhulenev Date: Sat, 26 Jun 2021 07:34:43 -0700 Subject: [PATCH] [perf] Fix a data race in the PerfJITEventListener Concurrent JIT compilation + PerfJITEventListener triggers tsan error Reviewed By: cota Differential Revision: https://reviews.llvm.org/D104977 --- lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp b/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp index d4c715cc59f..4a236e183c8 100644 --- a/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp +++ b/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp @@ -284,6 +284,9 @@ void PerfJITEventListener::notifyObjectLoaded( NotifyCode(Name, *AddrOrErr, Size); } + // avoid races with writes + std::lock_guard Guard(Mutex); + Dumpstream->flush(); }