summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/profile/InstrProfiling.h
Commit message (Collapse)AuthorAgeFilesLines
* Reland "[CMake] Support installation of InstrProfData.inc"Petr Hosek2019-11-221-6/+6
| | | | | | | | | | | 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-6/+6
| | | | | This reverts commit f11bc1776fd2815b60e0b1ed97be00b517348162 since it's failing to build on some bots.
* [CMake] Support installation of InstrProfData.incPetr Hosek2019-11-221-6/+6
| | | | | | | | | | | 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] Add a mode to continuously sync counter updates to a fileVedant Kumar2019-10-311-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [profile] Do not cache __llvm_profile_get_filename resultVedant Kumar2019-10-181-1/+14
| | | | | | | | | | | | | | | | | When the %m filename pattern is used, the filename is unique to each image, so the cached value is wrong. It struck me that the full filename isn't something that's recomputed often, so perhaps it doesn't need to be cached at all. David Li pointed out we can go further and just hide lprofCurFilename. This may regress workflows that depend on using the set-filename API to change filenames across all loaded DSOs, but this is expected to be very rare. rdar://55137071 Differential Revision: https://reviews.llvm.org/D69137 llvm-svn: 375301
* compiler-rt: Rename .cc file in lib/profile to .cppNico Weber2019-07-311-1/+1
| | | | | | | | See https://reviews.llvm.org/D58620 for discussion. Note how the comment in the file already said ".cpp" :) llvm-svn: 367460
* (Reland with changes) Adding a function for setting coverage output file.Sajjad Mirza2019-06-241-1/+20
| | | | | | | | | | | | | | | | | | | | | | | Summary: User code can open a file on its own and pass it to the runtime, rather than specifying a name and having the runtime open the file. This supports the use case where a process cannot open a file on its own but can receive a file descriptor from another process. Relanding https://reviews.llvm.org/D62541. The original revision unlocked the file before calling flush, this revision fixes that. Reviewers: Dor1s, davidxl Reviewed By: Dor1s Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D63581 llvm-svn: 364231
* Revert r362676 "[Profile]: Add runtime interface to specify file handle for ↵Hans Wennborg2019-06-121-20/+1
| | | | | | | | | | | | | | | profile data." This caused instrumented Clang to become crashy. See llvm-commits thread for repro steps. This also reverts follow-up r362716 which added test cases. > Author: Sajjad Mirza > > Differential Revision: http://reviews.llvm.org/D62541 llvm-svn: 363134
* [Profile]: Add runtime interface to specify file handle for profile data.Xinliang David Li2019-06-061-1/+20
| | | | | | | | Author: Sajjad Mirza Differential Revision: http://reviews.llvm.org/D62541 llvm-svn: 362676
* This change adds an API to allow setting the flag to indicate that the ↵Max Moroz2019-05-201-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | profile data has been dumped to the file. Summary: The main use is for users to disable dumping profile data to the file for certain processes in case the processes don't have permission to write to the disks, and trying to do so would result in side effects such as crashes. Patch by Yuke Liao (@liaoyuke). Additional context (Chromium use case): - https://bugs.chromium.org/p/chromium/issues/detail?id=842424 - https://bugs.chromium.org/p/chromium/issues/detail?id=957655 - https://chromium-review.googlesource.com/c/chromium/src/+/1610093 Reviewers: Dor1s, vsk, davidxl Reviewed By: Dor1s, davidxl Subscribers: delcypher, davidxl, sajjadm, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D62078 llvm-svn: 361194
* The error message for mismatched value sites is very cryptic.Dmitry Mikulin2019-04-231-1/+1
| | | | | | | | Make it more readable for an average user. Differential Revision: https://reviews.llvm.org/D60896 llvm-svn: 359043
* Reland compiler-rt support for order file instrumentation.Manman Ren2019-03-081-0/+4
| | | | | | | | | | | | | | r355343 was landed and was reverted in r355363 due to build breakage. This patch adds Linux/Windows support on top of r355343. In this patch, Darwin should be working with testing case. Linux should be working, I will enable the testing case in a follwup diff. Windows/Other should be building. Correct implementation for Other platforms will be added. Thanks David for reviewing the original diff, helping me with issues on Linux, and giving suggestions for adding support for Other platforms. llvm-svn: 355701
* Revert compiler-rt diffs for order file instrumentation to get bot green!Manman Ren2019-03-051-4/+0
| | | | | | | | This caused issues on Linux/Windows and other platforms. r355343 355350 355350 llvm-svn: 355363
* Order File Instrumentation: dump the data in compiler-rtManman Ren2019-03-041-0/+4
| | | | | | | | The profile data will be dumped in a file default_xxx.profraw.order. Differential Revision: https://reviews.llvm.org/D57530 llvm-svn: 355343
* 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] Add interface to get profile filenameTeresa Johnson2018-07-191-0/+8
| | | | | | | | | | | | | | | | Summary: Add __llvm_profile_get_filename interface to get the profile filename, which can be used for identifying which profile file belongs to an app when multiple binaries are instrumented and dumping profiles into the same directory. The filename includes the path. Reviewers: davidxl Subscribers: delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D49529 llvm-svn: 337482
* [profile] Fix value profile runtime merging issuesRong Xu2018-04-021-0/+4
| | | | | | | | | | | | | | | | This patch fixes the following issues: (1) The strong definition of the merge hook function was not working which breaks the online value profile merging. This patch removes the weak attribute of VPMergeHook and assigns the value dynamically. (2) Truncate the proifle file so that we don't have garbage data at the end of the file. (3) Add new __llvm_profile_instrument_target_value() interface to do the value profile update in batch. This is needed as the original incremental by 1 in __llvm_profile_instrument_target() is too slow for online merge. Differential Revision: https://reviews.llvm.org/D44847 llvm-svn: 328987
* Revert r312240Alex Lorenz2017-08-311-3/+3
| | | | | | | The buildbots have shown that -Wstrict-prototypes behaves differently in GCC and Clang so we should keep it disabled until Clang follows GCC's behaviour llvm-svn: 312246
* Build LLVM with -Wstrict-prototypes enabledAlex Lorenz2017-08-311-3/+3
| | | | | | | | | | | Clang 5 supports -Wstrict-prototypes. We should use it to catch any C declarations that declare a non-prototype function. rdar://33705313 Differential Revision: https://reviews.llvm.org/D36669 llvm-svn: 312240
* [Profile] Implement new API __llvm_profile_dumpXinliang David Li2016-08-091-0/+22
| | | | | | | | | The API is intended to be used by user to do fine grained (per-region) control of profile dumping. Differential Revision: http://reviews.llvm.org/D23106 llvm-svn: 278092
* [Profile] cleanup: do not reference name directly of vars shared between rt ↵Xinliang David Li2016-07-221-3/+3
| | | | | | and llvm llvm-svn: 276385
* [Profile] deprecate __llvm_profile_override_default_filename (part2)Xinliang David Li2016-07-211-16/+9
| | | | | | | | This eliminates unncessary calls and init functions. Differential Revision: http://reviews.llvm.org/D22614 llvm-svn: 276355
* [Profile] implement interface to get profile path prefixXinliang David Li2016-07-201-0/+10
| | | | | | Differential Revision: http://reviews.llvm.org/D22546 llvm-svn: 276083
* [profile] Hide some external symbols in InstrProfData.incVedant Kumar2016-06-081-0/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D21116 llvm-svn: 272167
* [profile] clean up profile file handling codeXinliang David Li2016-05-241-7/+1
| | | | | | Differentianl Revision: http://reviews.llvm.org/D20572 llvm-svn: 270617
* [profile] Static counter allocation for value profiling (part-2)Xinliang David Li2016-05-211-0/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D20460 llvm-svn: 270337
* Small typo and whitespace fix.Sean Silva2016-05-201-2/+2
| | | | llvm-svn: 270177
* Fix typo.Sean Silva2016-05-191-1/+1
| | | | llvm-svn: 270005
* [profile] add runtime variable documentationXinliang David Li2016-05-181-0/+29
| | | | llvm-svn: 269964
* [profile] minor code restructuring /NFCXinliang David Li2016-05-161-0/+6
| | | | | | | This is one of the enabler patch to allow value profiler to allocate counter statically. llvm-svn: 269689
* Reapply r268840: [profile] Simplify value profile writingXinliang David Li2016-05-101-9/+1
| | | | | | | 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-1/+9
| | | | | | | | 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-9/+1
| | | | | | | | 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] Add API to check compatibility of profile data in bufferXinliang David Li2016-03-041-1/+13
| | | | | | This is needed by client which uses in-process merge API. llvm-svn: 262736
* [PGO] Add API for profile merge from bufferXinliang David Li2016-03-031-0/+9
| | | | | | Differential Revision: http://reviews.llvm.org/D17831 llvm-svn: 262644
* [profile] Compute number of data entries correctlyVedant Kumar2016-02-261-0/+4
| | | | | | | | | | | | | | | | 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]: Do not update Data->Value field during profile write.Xinliang David Li2015-12-291-4/+5
| | | | | | | | | | 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] cleanup: unify prefix for portability macrosXinliang David Li2015-12-161-1/+2
| | | | llvm-svn: 255748
* [PGO] Header file cleanup (NFC)Xinliang David Li2015-12-101-41/+1
| | | | | | | | | InstrProfiling.h file declares profile runtime public APIs. It has become a dumping place for many different things, which needs cleanups. In this change, core type declarations and portability macros are moved to a new file InstrProfilingPort.h. llvm-svn: 255270
* [PGO] Stop leaking libc function to buffer API implXinliang David Li2015-12-071-3/+4
| | | | llvm-svn: 254943
* Move macro defs closer (NFC)Xinliang David Li2015-12-041-4/+5
| | | | llvm-svn: 254761
* [PGO] Introduce error report macro in profile-rtXinliang David Li2015-12-031-0/+4
| | | | | | Also added a test case for runtime error reporting. llvm-svn: 254625
* [PGO] sync up target instrument decl between runtime and llvm (NFC)Xinliang David Li2015-11-231-2/+6
| | | | llvm-svn: 253911
* [PGO] Unify raw profile header definitionXinliang David Li2015-11-231-10/+2
| | | | | | | Replace duplicate definition raw header with common definition in InstrProfData.inc. llvm-svn: 253896
* [PGO] Use the alignment macro newly introduced (NFC)Xinliang David Li2015-11-231-1/+1
| | | | llvm-svn: 253895
* [PGO] Unify per-function control data definitionXinliang David Li2015-11-231-8/+2
| | | | | | | Replace duplicate definition per-func profile control data with common definition in InstrProfData.inc. llvm-svn: 253891
* [PGO] Use common definition of value profile kindXinliang David Li2015-11-231-3/+2
| | | | | | | Replace duplicate definition value profile kind definitions with common definition in InstrProfData.inc. llvm-svn: 253890
* [PGO] Start use InstrProf template file in compiler-rt/lib/profileXinliang David Li2015-11-231-5/+2
| | | | | | | - Replace use of __llvm_profile_value_data with common data structure. - Remve duplicate InstrProfValueNode llvm-svn: 253883
* [PGO] Compiler-rt cleanup -- introduces macros for various macrosXinliang David Li2015-11-231-1/+4
| | | | | | | This makes code more readable and be made more portable in the future. There is no functional change. llvm-svn: 253845
* [PGO] Fix buildbot failure on FreeBSD (when building __x86_64__ lib)Xinliang David Li2015-11-201-0/+7
| | | | | | | | There seems to be a problem in system header (stdint.h) of FreeBSD where uint8_t nor uint16_t are defined. Explicitly define the key types as done for FreeBSD i386. llvm-svn: 253703
OpenPOWER on IntegriCloud