[PATCH] D112880: [TimeProfiler] Reset variable to nullptr
Shoaib Meenai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 30 16:56:01 PDT 2021
smeenai created this revision.
smeenai added reviewers: broadwaylamb, russell.gallop, MaskRay, mehdi_amini.
Herald added subscribers: dexonsmith, hiraditya.
smeenai requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D112880
Files:
llvm/lib/Support/TimeProfiler.cpp
Index: llvm/lib/Support/TimeProfiler.cpp
===================================================================
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -271,6 +271,7 @@
// Called from main thread.
void llvm::timeTraceProfilerCleanup() {
delete TimeTraceProfilerInstance;
+ TimeTraceProfilerInstance = nullptr;
std::lock_guard<std::mutex> Lock(Mu);
for (auto *TTP : *ThreadTimeTraceProfilerInstances)
delete TTP;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112880.383629.patch
Type: text/x-patch
Size: 465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211030/3886f0bf/attachment.bin>
More information about the llvm-commits
mailing list