[all-commits] [llvm/llvm-project] ade776: [profile] Clean up stale raw profiles in instrprof...

Vedant Kumar via All-commits all-commits at lists.llvm.org
Thu Oct 31 16:08:37 PDT 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: ade776b5845384bb45fcd2f7919d80f4101971a7
      https://github.com/llvm/llvm-project/commit/ade776b5845384bb45fcd2f7919d80f4101971a7
  Author: Vedant Kumar <vsk at apple.com>
  Date:   2019-10-31 (Thu, 31 Oct 2019)

  Changed paths:
    M compiler-rt/test/profile/instrprof-write-file.c

  Log Message:
  -----------
  [profile] Clean up stale raw profiles in instrprof-write-file.c


  Commit: d889d1efefe9f97507e3eafa85a2e3939df9750f
      https://github.com/llvm/llvm-project/commit/d889d1efefe9f97507e3eafa85a2e3939df9750f
  Author: Vedant Kumar <vsk at apple.com>
  Date:   2019-10-31 (Thu, 31 Oct 2019)

  Changed paths:
    M clang/docs/SourceBasedCodeCoverage.rst
    M clang/lib/Driver/ToolChains/Darwin.cpp
    M clang/test/Driver/darwin-ld.c
    M compiler-rt/lib/profile/InstrProfData.inc
    M compiler-rt/lib/profile/InstrProfiling.h
    M compiler-rt/lib/profile/InstrProfilingBuffer.c
    M compiler-rt/lib/profile/InstrProfilingFile.c
    M compiler-rt/lib/profile/InstrProfilingPort.h
    M compiler-rt/lib/profile/InstrProfilingRuntime.cpp
    M compiler-rt/lib/profile/InstrProfilingWriter.c
    A compiler-rt/test/profile/ContinuousSyncMode/basic.c
    A compiler-rt/test/profile/ContinuousSyncMode/darwin-proof-of-concept.c
    A compiler-rt/test/profile/ContinuousSyncMode/lit.local.cfg.py
    A compiler-rt/test/profile/ContinuousSyncMode/multiple-DSOs.c
    A compiler-rt/test/profile/ContinuousSyncMode/pid-substitution.c
    A compiler-rt/test/profile/ContinuousSyncMode/set-file-object.c
    A compiler-rt/test/profile/ContinuousSyncMode/set-filename.c
    M llvm/include/llvm/ProfileData/InstrProfData.inc
    M llvm/lib/ProfileData/InstrProfReader.cpp
    M llvm/test/tools/llvm-profdata/Inputs/c-general.profraw
    M llvm/test/tools/llvm-profdata/c-general.test
    M llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test
    M llvm/test/tools/llvm-profdata/raw-32-bits-be.test
    M llvm/test/tools/llvm-profdata/raw-32-bits-le.test
    M llvm/test/tools/llvm-profdata/raw-64-bits-be.test
    M llvm/test/tools/llvm-profdata/raw-64-bits-le.test
    M llvm/test/tools/llvm-profdata/raw-two-profiles.test

  Log Message:
  -----------
  [profile] Add a mode to continuously sync counter updates to a file

Add support for continuously syncing profile counter updates to a file.

The motivation for this is that programs do not always exit cleanly. On
iOS, for example, programs are usually killed via a signal from the OS.
Running atexit() handlers after catching a signal is unreliable, so some
method for progressively writing out profile data is necessary.

The approach taken here is to mmap() the `__llvm_prf_cnts` section onto
a raw profile. To do this, the linker must page-align the counter and
data sections, and the runtime must ensure that counters are mapped to a
page-aligned offset within a raw profile.

Continuous mode is (for the moment) incompatible with the online merging
mode. This limitation is lifted in https://reviews.llvm.org/D69586.

Continuous mode is also (for the moment) incompatible with value
profiling, as I'm not sure whether there is interest in this and the
implementation may be tricky.

As I have not been able to test extensively on non-Darwin platforms,
only Darwin support is included for the moment. However, continuous mode
may "just work" without modification on Linux and some UNIX-likes. AIUI
the default value for the GNU linker's `--section-alignment` flag is set
to the page size on many systems. This appears to be true for LLD as
well, as its `no_nmagic` option is on by default. Continuous mode will
not "just work" on Fuchsia or Windows, as it's not possible to mmap() a
section on these platforms. There is a proposal to add a layer of
indirection to the profile instrumentation to support these platforms.

rdar://54210980

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


Compare: https://github.com/llvm/llvm-project/compare/9370a741581f...d889d1efefe9


More information about the All-commits mailing list