summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/profile/InstrProfilingWriter.c
Commit message (Collapse)AuthorAgeFilesLines
* [profile] Avoid allocating a page on the stack, NFCVedant Kumar2019-12-111-14/+12
| | | | | | | | | | | | | | | | | | | | | When writing out a profile, avoid allocating a page on the stack for the purpose of writing out zeroes, as some embedded environments do not have enough stack space to accomodate this. Instead, use a small, fixed-size zero buffer that can be written repeatedly. For a synthetic file with >100,000 functions, I did not measure a significant difference in profile write times. We are removing a page-length zero-fill `memset()` in favor of several smaller buffered `fwrite()` calls: in practice, I am not sure there is much of a difference. The performance impact is only expected to affect the continuous sync mode (%c) -- zero padding is less than 8 bytes in all other cases. rdar://57810014 Differential Revision: https://reviews.llvm.org/D71323
* Reland "[CMake] Support installation of InstrProfData.inc"Petr Hosek2019-11-221-2/+2
| | | | | | | | | | | This header fragment is useful on its own for any consumer that wants to use custom instruction profile runtime with the LLVM instrumentation. The concrete use case is in Fuchsia's kernel where we want to use instruction profile instrumentation, but we cannot use the compiler-rt runtime because it's not designed for use in the kernel environment. This change allows installing this header as part of compiler-rt. Differential Revision: https://reviews.llvm.org/D64532
* Revert "[CMake] Support installation of InstrProfData.inc"Petr Hosek2019-11-221-2/+2
| | | | | This reverts commit f11bc1776fd2815b60e0b1ed97be00b517348162 since it's failing to build on some bots.
* [CMake] Support installation of InstrProfData.incPetr Hosek2019-11-221-2/+2
| | | | | | | | | | | This header fragment is useful on its own for any consumer that wants to use custom instruction profile runtime with the LLVM instrumentation. The concrete use case is in Fuchsia's kernel where we want to use instruction profile instrumentation, but we cannot use the compiler-rt runtime because it's not designed for use in the kernel environment. This change allows installing this header as part of compiler-rt. Differential Revision: https://reviews.llvm.org/D64532
* [profile] Second speculative fix for WindowsVedant Kumar2019-10-311-1/+1
| | | | | | | | VLAs in C appear to not work on Windows, so use COMPILER_RT_ALLOCA: C:\b\slave\sanitizer-windows\llvm-project\compiler-rt\lib\profile\InstrProfilingWriter.c(264): error C2057: expected constant expression C:\b\slave\sanitizer-windows\llvm-project\compiler-rt\lib\profile\InstrProfilingWriter.c(264): error C2466: cannot allocate an array of constant size 0 C:\b\slave\sanitizer-windows\llvm-project\compiler-rt\lib\profile\InstrProfilingWriter.c(264): error C2133: 'Zeroes': unknown size
* [profile] Add a mode to continuously sync counter updates to a fileVedant Kumar2019-10-311-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [profile] Port the runtime to Solaris (retry)Vedant Kumar2017-12-141-2/+3
| | | | | | | | | | | | | This includes a few nice bits of refactoring (e.g splitting out the exclusive locking code into a common utility). Hopefully the Windows support is fixed now. Patch by Rainer Orth! Differential Revision: https://reviews.llvm.org/D40944 llvm-svn: 320731
* Revert "(HEAD -> master, origin/master, origin/HEAD) [profile] Port the ↵Vedant Kumar2017-12-141-3/+2
| | | | | | | | | | | runtime to Solaris" This reverts commit r320726. It looks like flock isn't available on Windows: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/21317/steps/build%20compiler-rt/logs/stdio llvm-svn: 320728
* [profile] Port the runtime to SolarisVedant Kumar2017-12-141-2/+3
| | | | | | | | | | | This includes a few nice bits of refactoring (e.g splitting out the exclusive locking code into a common utility). Patch by Rainer Orth! Differential Revision: https://reviews.llvm.org/D40944 llvm-svn: 320726
* [PGO] Reduce IO in profile dumping with mergingXinliang David Li2017-06-281-9/+13
| | | | | | Differential Revision: http://reviews.llvm.org/D34709 llvm-svn: 306561
* [PGO] Refactor file/buffer writer callback interfaces /NFCXinliang David Li2017-06-271-25/+26
| | | | | | | | | | 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
* Avoid leak. Free before resetting.Sean Silva2016-05-161-1/+1
| | | | llvm-svn: 269724
* Use __builtin_alloca with __GNUC__Xinliang David Li2016-05-151-4/+1
| | | | llvm-svn: 269592
* Fix FreeBSD build failureXinliang David Li2016-05-151-0/+2
| | | | llvm-svn: 269587
* [profile] Eliminate dynamic memory allocation for vp writingXinliang David Li2016-05-141-13/+104
| | | | | | | | | | This is part-3 of the effort to eliminate dependency on libc allocator in instr profiler runtime. With this change, the profile dumper is completely free of malloc/calloc. Value profile instr API implementation is the only remaining piece with calloc dependency. llvm-svn: 269576
* minor cleanup -- reset buffer pointerXinliang David Li2016-05-141-1/+4
| | | | llvm-svn: 269533
* [profile] Eliminate dynamic memory allocation for buffered writerXinliang David Li2016-05-131-16/+16
| | | | | | | | With this change, dynamic memory allocation is only used for testing purpose. This change is one of the many steps to make instrument profiler dynamic allocation free. llvm-svn: 269453
* Minor code refactoring /NFCXinliang David Li2016-05-121-6/+15
| | | | llvm-svn: 269351
* Reapply r268840: [profile] Simplify value profile writingXinliang David Li2016-05-101-26/+29
| | | | | | | Revert r268864 that reverted 268840 after underlying problem is fixed for arm bot. llvm-svn: 268992
* Fix variable visibilityXinliang David Li2016-05-091-2/+2
| | | | llvm-svn: 268952
* Revert "[profile] Simplify value profile writing"Renato Golin2016-05-071-29/+26
| | | | | | | | 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-26/+29
| | | | | | | | 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-28/+29
| | | | llvm-svn: 262788
* [profile] Compute number of data entries correctlyVedant Kumar2016-02-261-1/+1
| | | | | | | | | | | | | | | | 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]: Refactor VP data writerXinliang David Li2015-12-291-47/+69
| | | | | | | | | Extract the buffered filer writer code used by value profile writer and turn it into common/sharable buffered fileIO interfaces. Added a test case for the buffered file writer and rewrite the VP dumping using the new APIs. llvm-svn: 256604
* [PGO]: Do not update Data->Value field during profile write.Xinliang David Li2015-12-291-15/+81
| | | | | | | | | | The profile reader no longer depends on this field to be updated and point to owning func's vp data. The VP data also no longer needs to be allocated in a contiguous memory space. Differential Revision: http://reviews.llvm.org/D15258 llvm-svn: 256543
* [PGO] Move buffer write callback to a common fileXinliang David Li2015-12-221-0/+17
| | | | | | 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/+5
| | | | llvm-svn: 255748
* Don't shadow a variable in the outer scope. Use canonical form of theJoerg Sonnenberger2015-12-041-3/+3
| | | | | | array size idiom. llvm-svn: 254673
* [PGO] Unify raw profile header definitionXinliang David Li2015-11-231-10/+3
| | | | | | | Replace duplicate definition raw header with common definition in InstrProfData.inc. llvm-svn: 253896
* [PGO] Compiler-rt cleanup -- introduces macros for various macrosXinliang David Li2015-11-231-4/+5
| | | | | | | This makes code more readable and be made more portable in the future. There is no functional change. llvm-svn: 253845
* Fix -Wpointer-sign warningXinliang David Li2015-11-211-5/+5
| | | | llvm-svn: 253770
* [PGO] Implement a more robust/readable Writer callback interfaceXinliang David Li2015-11-211-17/+17
| | | | | | | | | | | | (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] Profile runtime name cleanupsXinliang David Li2015-11-201-1/+1
| | | | | | | | | | | | | Value profile enumerator change to match LLVM code ProfData new member field name change to match LLVM code ProfData member type change to match LLVM code Do not use lower case for types that are internal to implementation (not exposed to APIs) There is no functional change. This is a preparation patch to enable more code sharing in follow up patches Differential Revision: http://reviews.llvm.org/D14841 llvm-svn: 253700
* [PGO] Minor cleanups (from review feedback)Xinliang David Li2015-11-191-10/+10
| | | | | | | | 1. fix naming problem of file/buffer writer 2. change BufferOrFile to WriterCtx 3. move writer and writerctx together llvm-svn: 253545
* Fix format of previous patch (NFC)Xinliang David Li2015-11-181-9/+8
| | | | llvm-svn: 253503
* [PGO] Refactor File and Buffer API profile writing codeXinliang David Li2015-11-181-0/+77
With this change, Buffer API and File API implementations are unified. Differential Revision: http://reviews.llvm.org/D14692 llvm-svn: 253500
OpenPOWER on IntegriCloud