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.
Depends on: http://reviews.llvm.org/D19298
Using the for-loop and pattern matching Magic seems weird. Can the paddings be zero filled?