[PATCH] D19293: [profile] LLVM support for memory-mapping profile counters

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 15:43:17 PDT 2016


vsk created this revision.
vsk added a reviewer: davidxl.
vsk added a subscriber: llvm-commits.

**Summary**

Using memory-mapped profile counters makes it possible to take snapshots of a running process's profiling information without changing the program. This is useful if the process exits abnormally, or if profiling data needs to be collected periodically.

Add the llvm support required to create instrumented programs which memory-map their counters directly onto a raw profile.

**More details**

This patch bumps the raw profile format version. This format change is needed to record a new field in the profile header: `CounterSectionAlignment`. This parameter specifies the page size the instrumented program worked with. It's needed to determine section offsets in RawInstrProfReader. If the instrumented program has disabled the memory-mapped counters feature, `CounterSectionAlignment=1`.

This patch also adds an `emitCounterPadding` method to the InstrProfiling pass. This padding is needed for compatibility with the Darwin linker, which packs sections together tightly. Without it, the instrumented program could memory-map the contents of unrelated sections into the counters section.

http://reviews.llvm.org/D19293

Files:
  include/llvm/ProfileData/InstrProfData.inc
  include/llvm/ProfileData/InstrProfReader.h
  include/llvm/Transforms/InstrProfiling.h
  lib/ProfileData/InstrProfReader.cpp
  lib/Transforms/Instrumentation/InstrProfiling.cpp
  test/tools/llvm-profdata/Inputs/c-general.profraw
  test/tools/llvm-profdata/raw-32-bits-be.test
  test/tools/llvm-profdata/raw-32-bits-le.test
  test/tools/llvm-profdata/raw-64-bits-be.test
  test/tools/llvm-profdata/raw-64-bits-le.test
  test/tools/llvm-profdata/raw-two-profiles.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19293.54279.patch
Type: text/x-patch
Size: 11896 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160419/15045f78/attachment.bin>


More information about the llvm-commits mailing list