[PATCH] D74953: [profile] Don't dump counters when forking and don't reset when calling exec** functions

calixte via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 21 04:35:39 PST 2020


calixte created this revision.
calixte added a reviewer: marco-c.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, hiraditya.
Herald added projects: clang, Sanitizers, LLVM.

There is no need to write out gcdas when forking because we can just reset the counters in the parent process.
Let say a counter is N before the fork, then fork and this counter is set to 0 in the child process.
In the parent process, the counter is incremented by P and in the child process it's incremented by C.
When dump is ran at exit, parent process will dump N+P for the given counter and the child process will dump 0+C, so when the gcdas are merged the resulting counter will be N+P+C.
About exec** functions, since the current process is replaced by an another one there is no need to reset the counters but just write out the gcdas since the counters are definitely lost.
To avoid to have lists in a bad state, we just lock them during the fork and the flush (if called explicitely) and lock them when an element is added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74953

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/lib/profile/GCDAProfiling.c
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74953.245815.patch
Type: text/x-patch
Size: 12406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200221/7cde62b9/attachment-0001.bin>


More information about the llvm-commits mailing list