summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/profile/InstrProfilingBuffer.c
Commit message (Collapse)AuthorAgeFilesLines
* [profile] Support online merging with continuous sync modeVedant Kumar2019-11-181-5/+1
| | | | | | | | | | | | | | | Make it possible to use online profile merging ("%m" mode) with continuous sync ("%c" mode). To implement this, the merged profile is locked in the runtime initialization step and either a) filled out for the first time or b) checked for compatibility. Then, the profile can simply be mmap()'d with MAP_SHARED set. With the mmap() in place, counter updates from every process which uses an image are mapped onto the same set of physical pages assigned by the filesystem cache. After the mmap() is set up, the profile is unlocked. Differential Revision: https://reviews.llvm.org/D69586
* [profile] Add a mode to continuously sync counter updates to a fileVedant Kumar2019-10-311-4/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [PGO] Reduce IO in profile dumping with mergingXinliang David Li2017-06-281-2/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D34709 llvm-svn: 306561
* [PGO] Refactor file/buffer writer callback interfaces /NFCXinliang David Li2017-06-271-4/+13
| | | | | | | | | | Introduces a 'owner' struct to include the overridable write method and the write context in C. This allows easy introdution of new member API to help reduce profile merge time in the follow up patch. llvm-svn: 306432
* Reapply r268840: [profile] Simplify value profile writingXinliang David Li2016-05-101-2/+2
| | | | | | | Revert r268864 that reverted 268840 after underlying problem is fixed for arm bot. llvm-svn: 268992
* Revert "[profile] Simplify value profile writing"Renato Golin2016-05-071-2/+2
| | | | | | | | This reverts commit r268840, as it breaks Thumb2 self-hosting. There is something unstable in the profiling for Thumb2 that needs to be sorted out before we continue implementing these changes to the profiler. See PR27667. llvm-svn: 268864
* [profile] Simplify value profile writingXinliang David Li2016-05-071-2/+2
| | | | | | | | With this patch, value data are longer pre-collected before writing. The code is simplified and requires less heap space for dumping. llvm-svn: 268840
* [PGO] internal API name cleanups (for better consistency)Xinliang David Li2016-03-061-4/+4
| | | | llvm-svn: 262788
* [profile] Compute number of data entries correctlyVedant Kumar2016-02-261-4/+11
| | | | | | | | | | | | | | | | Compiler-rt miscalculates the number of entries in the __llvm_prf_data section on i386 Darwin. This results in a number of test failures (which we started catching after r261344). The fix we attempted earlier is insufficient (r261683). It caused some tests to start passing again, but that hid the fact that we drop some data entries. This patch should fix the real problem. It fixes the way we compute DataSize by taking into account the way the Darwin linker lays out __llvm_prf_data. Differential Revision: http://reviews.llvm.org/D17623 llvm-svn: 261957
* [PGO] Move buffer write callback to a common fileXinliang David Li2015-12-221-19/+2
| | | | | | This is a NFC refactoring enabling code sharing by file writer. llvm-svn: 256264
* [PGO] cleanup: unify prefix for portability macrosXinliang David Li2015-12-161-5/+4
| | | | llvm-svn: 255748
* Fix a bug introduced in cleanupXinliang David Li2015-11-231-1/+1
| | | | llvm-svn: 253847
* [PGO] Compiler-rt cleanup -- introduces macros for various macrosXinliang David Li2015-11-231-8/+7
| | | | | | | This makes code more readable and be made more portable in the future. There is no functional change. llvm-svn: 253845
* [PGO] Implement a more robust/readable Writer callback interfaceXinliang David Li2015-11-211-8/+15
| | | | | | | | | | | | (patch suggested by silvas) With this patch, the IO information is wrapped in struct ProfDataIOVec, and interface of writerCallback takes a vector of IOVec and a pointer to writer context pointer. Differential Revision: http://reviews.llvm.org/D14859 llvm-svn: 253764
* [PGO] Minor cleanups (from review feedback)Xinliang David Li2015-11-191-3/+3
| | | | | | | | 1. fix naming problem of file/buffer writer 2. change BufferOrFile to WriterCtx 3. move writer and writerctx together llvm-svn: 253545
* [PGO] Refactor File and Buffer API profile writing codeXinliang David Li2015-11-181-63/+16
| | | | | | | | | With this change, Buffer API and File API implementations are unified. Differential Revision: http://reviews.llvm.org/D14692 llvm-svn: 253500
* [PGO] Runtime support for value profiling.Betul Buyukkurt2015-11-181-2/+5
| | | | | | | | This change adds extends the data structures and adds in the routines for handling runtime calls for value profiling. The profile data format is modified and the version number is incremented. llvm-svn: 253483
* [PGO] Ensure profile section symbols are created (linux)Xinliang David Li2015-11-131-0/+4
| | | | | | | | | | | | | - This is to handle a corner case where profile lib is linked in but non of the modules are instrumented (On linux, since we avoided the overhead to emit runtime hook use functions so this is the side effect of that size optimization). - Added a profile runtime test case to cover all scenarios of shared library builds. Differential Revision: http://reviews.llvm.org/D14468 llvm-svn: 253098
* Use struct type instead of raw array for raw profile header (NFC)Xinliang David Li2015-10-161-10/+10
| | | | | | | | | | This patch introduces a well defined header struct to represent raw profile header instead of using raw array. Previously the raw array is used in two different files and is very error prone when header structure is re-organized. This is a small cleanup with NFC. llvm-svn: 250561
* profile: Add low level versions of profile buffer functionsJustin Bogner2014-12-091-4/+39
| | | | | | | | | | | | On Darwin, compiler_rt uses magic linker symbols to find the profile counters in the __DATA segment. This is a reasonable method for normal, hosted, userspace programs. However programs with custom memory layouts, such as the kernel, will need to tell compiler_rt explicitly where to find these sections. Patch by Lawrence D'Anna. Thanks! llvm-svn: 223840
* profile: Avoid name collisions between instrumentation and runtimeJustin Bogner2014-09-041-6/+6
| | | | | | | | | | | | The naming scheme we're using for counters in profile data shares a prefix with some fixed names we use for the runtime, notably __llvm_profile_data_begin and _end. Embarrassingly, this means a function called begin() can't be instrumented. This modifies the runtime names so as not to collide with the instrumentation. llvm-svn: 217166
* InstrProf: Fix shared object profilingDuncan P. N. Exon Smith2014-05-161-1/+10
| | | | | | | | | | | | | | | | | | Change the API of the instrumented profiling library to work with shared objects. - Most things are now declared hidden, so that each executable gets its own copy. - Initialization hooks up a linked list of writers. - The raw format with shared objects that are profiled consists of a concatenated series of profiles. llvm-profdata knows how to deal with that since r208938. <rdar://problem/16918688> llvm-svn: 208940
* profile: Fix the build with gcc 4.9Reid Kleckner2014-05-011-9/+8
| | | | | | | | | | GCC -pedantic warns that the initialization of Header is not constant: InstrProfilingFile.c:31:5: error: initializer element is not computable at load time [-Werror] LLVM defaults to enabling -pedantic. If this warning is unhelpful, we can consider revisiting that decision. llvm-svn: 207784
* Avoid GCC's "cast from pointer to integer of different size" warning.David Blaikie2014-03-211-2/+2
| | | | | | | | This is a bit of a stab in the dark as I'm not sure I've got these source files compiling correctly locally. (and the warning only reproduces on a 32bit build anyway) llvm-svn: 204521
* InstrProf: Unify logic in two profile writersDuncan P. N. Exon Smith2014-03-211-6/+10
| | | | | | <rdar://problem/15943240> llvm-svn: 204500
* InstrProf: Write the __llvm_profile_write_buffer()Duncan P. N. Exon Smith2014-03-211-2/+45
| | | | | | | | | | Write __llvm_profile_write_buffer(), which uses the same logic as __llvm_profile_write_file(), but writes directly to a provided `char*` buffer instead. <rdar://problem/15943240> llvm-svn: 204499
* InstrProf: If libc is available, use it; no functionality changeDuncan P. N. Exon Smith2014-03-211-41/+1
| | | | | | | | | | | | | It was misguided to plan to rely on __llvm_profile_write_buffer() in __llvm_profile_write_file(). It's less complex to duplicate the writing logic than to mmap the file. Since it's here to stay, move `FILE*`-based writing logic into InstrProfilingFile.c. <rdar://problem/15943240> llvm-svn: 204498
* InstrProf: Reorganize files; no functionality changeDuncan P. N. Exon Smith2014-03-211-0/+54
Move functions around to prepare for some other changes. - Merge InstrProfilingExtras.h with InstrProfiling.h. There's no benefit to having these split. - Rename InstrProfilingExtras.c to InstrProfilingFile.c. - Split actual buffer writing code out of InstrProfiling.c into InstrProfilingBuffer.c. - Drive-by corrections of a couple of header comments. <rdar://problem/15943240> llvm-svn: 204497
OpenPOWER on IntegriCloud