As discussed in D145428, the memprof_init_is_running check can be moved
to the end of the initialization routine to avoid intercepting
allocations during initialization. Also, the memprof_init_done flag can
be removed and replaced with memprof_inited. Finally, memprof_inited can
also be moved to the end of the method.
Tested on the existing check-memprof tests; memprof profile collection
succeeded on a large internal workload.
@tejohnson
I stepped through the code for ThreadStart and identified potential allocation calls. I found that:
So perhaps this comment is stale? Either way, I think even if there is an allocation call, intercepting it isn't worthwhile. Do you have any concerns based on this comment?
[1] https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/memprof/memprof_thread.cpp#L79
[2] https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/memprof/memprof_thread.cpp#L60
[3] https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/memprof/memprof_thread.cpp#L48
[4] https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cpp#L147