Re-land [Support] Extend TimeProfiler to support multiple threads
authorRussell Gallop <russell.gallop@sony.com>
Fri, 3 Jan 2020 16:04:19 +0000 (16:04 +0000)
committerRussell Gallop <russell.gallop@sony.com>
Mon, 27 Jan 2020 13:01:49 +0000 (13:01 +0000)
commit77e6bb3cbad26f0a95be5c427fa7f87833d5843e
treee219932e77fb46d2229999c71eb0a5f77dd2663a
parent9a952fd462774e79d8dc514d71bf43ea0ca7f429
Re-land [Support] Extend TimeProfiler to support multiple threads

This makes TimeTraceProfilerInstance thread local. Added
timeTraceProfilerFinishThread() which moves the thread local instance to
a global vector of instances. timeTraceProfilerWrite() then writes
recorded data from all instances.

Threads are identified based on their thread ids. Totals are reported
with artificial thread ids higher than the real ones.

This fixes the previous version to work with __thread as well as
thread_local.

Differential Revision: https://reviews.llvm.org/D71059
llvm/include/llvm/Support/TimeProfiler.h
llvm/lib/Support/TimeProfiler.cpp