This is an archive of the discontinued LLVM Phabricator instance.

[profile] Clang support for memory-mapping profile counters
Needs ReviewPublic

Authored by vsk on Apr 19 2016, 3:49 PM.

Details

Reviewers
davidxl
Summary

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 clang support required to create instrumented programs which memory-map their counters directly onto a raw profile.

More details

This patch teaches clang to page-align the __llvm_prf_counts section (just on Darwin, initially). Because clang only knows the host system's page size -- not the target system's -- this is a best-effort attempt. If the instrumented program detects that the counters section has the wrong alignment, it will disable the memory-mapped counters feature.

I can add support for other platforms and linkers in follow-up patches.

Depends on: http://reviews.llvm.org/D19293 (llvm)

Diff Detail

Event Timeline

vsk updated this revision to Diff 54285.Apr 19 2016, 3:49 PM
vsk retitled this revision from to [profile] Clang support for memory-mapping profile counters.
vsk updated this object.
vsk added a reviewer: davidxl.
vsk added a subscriber: cfe-commits.