[all-commits] [llvm/llvm-project] 8f4626: [profile] Don't dump counters when forking and don...

calixteman via All-commits all-commits at lists.llvm.org
Mon Feb 24 01:38:53 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 8f46269f0c1cc93b080931fd9dfeffc4d364004b
      https://github.com/llvm/llvm-project/commit/8f46269f0c1cc93b080931fd9dfeffc4d364004b
  Author: Calixte Denizet <calixte.denizet at gmail.com>
  Date:   2020-02-24 (Mon, 24 Feb 2020)

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

  Log Message:
  -----------
  [profile] Don't dump counters when forking and don't reset when calling exec** functions

Summary:
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.

Reviewers: marco-c

Reviewed By: marco-c

Subscribers: hiraditya, cfe-commits, #sanitizers, llvm-commits, sylvestre.ledru

Tags: #clang, #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D74953




More information about the All-commits mailing list