Skip to content

Commit 0cf624c

Browse files
committed
[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
1 parent 0f6d720 commit 0cf624c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llvm/lib/Support/TimeProfiler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ void llvm::timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
271271
// Called from main thread.
272272
void llvm::timeTraceProfilerCleanup() {
273273
delete TimeTraceProfilerInstance;
274+
TimeTraceProfilerInstance = nullptr;
274275
std::lock_guard<std::mutex> Lock(Mu);
275276
for (auto *TTP : *ThreadTimeTraceProfilerInstances)
276277
delete TTP;

0 commit comments

Comments
 (0)