[llvm] 0cf624c - [TimeProfiler] Reset variable to nullptr
Shoaib Meenai via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 31 16:15:41 PDT 2021
Author: Shoaib Meenai
Date: 2021-10-31T16:14:30-07:00
New Revision: 0cf624cad7a0afbac638835cba279dd42adcc39d
URL: https://github.com/llvm/llvm-project/commit/0cf624cad7a0afbac638835cba279dd42adcc39d
DIFF: https://github.com/llvm/llvm-project/commit/0cf624cad7a0afbac638835cba279dd42adcc39d.diff
LOG: [TimeProfiler] Reset variable to nullptr
Otherwise we'll hit a spurious assert failure when we reset and then
reinitialize TimeProfiler on the same thread, as can happen when e.g.
using LLD as a library and running it multiple times in the same
process.
Makes `lld/test/MachO/time-trace.s` pass with `LLD_IN_TEST=2`, which
runs the linker twice in the same process and exposed the issue.
Reviewed By: MaskRay, mehdi_amini
Differential Revision: https://reviews.llvm.org/D112880
Added:
Modified:
llvm/lib/Support/TimeProfiler.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp
index a9fd185ce8f67..2b094a4983a08 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -271,6 +271,7 @@ void llvm::timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
// Called from main thread.
void llvm::timeTraceProfilerCleanup() {
delete TimeTraceProfilerInstance;
+ TimeTraceProfilerInstance = nullptr;
std::lock_guard<std::mutex> Lock(Mu);
for (auto *TTP : *ThreadTimeTraceProfilerInstances)
delete TTP;
More information about the llvm-commits
mailing list