[llvm] e88ac72 - [perf] Fix a data race in the PerfJITEventListener
Eugene Zhulenev via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 29 08:30:43 PDT 2021
Author: Eugene Zhulenev
Date: 2021-06-29T08:30:31-07:00
New Revision: e88ac7295fa298c336cb57d65bdcc72b45dbc0b0
URL: https://github.com/llvm/llvm-project/commit/e88ac7295fa298c336cb57d65bdcc72b45dbc0b0
DIFF: https://github.com/llvm/llvm-project/commit/e88ac7295fa298c336cb57d65bdcc72b45dbc0b0.diff
LOG: [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
Added:
Modified:
llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp b/llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
index d4c715cc59f6..4a236e183c8b 100644
--- a/llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
+++ b/llvm/lib/ExecutionEngine/PerfJITEvents/PerfJITEventListener.cpp
@@ -284,6 +284,9 @@ void PerfJITEventListener::notifyObjectLoaded(
NotifyCode(Name, *AddrOrErr, Size);
}
+ // avoid races with writes
+ std::lock_guard<sys::Mutex> Guard(Mutex);
+
Dumpstream->flush();
}
More information about the llvm-commits
mailing list