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 compiler-rt support required to create instrumented programs which memory-map their counters directly onto a raw profile.
More details
The memory-mapped counters feature works by writing out an empty raw profile at program start time, and then setting up an mmap. If this fails, we clean up and fall back to the normal atexit() profile writer.
One complication arises with profile truncation. The atexit() writer is able to truncate profiles every time __llvm_profile_initialize_file() is called. The mmap() writer can't do this because it needs to preserve the profiling data created by shared objects. The solution I picked is to use a lock file to synchronize truncation efforts.
Depends on: http://reviews.llvm.org/D19293
This is another reason there is need to let driver teach the linker to align the combined counter variable section properly. Silently failing like this is not user friendly.