summaryrefslogtreecommitdiff
path: root/lib/profile/InstrProfilingFile.c
Commit message (Collapse)AuthorAgeFilesLines
* [profile] Do not cache __llvm_profile_get_filename resultVedant Kumar2019-10-181-9/+2
| | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@375301 91177308-0d34-0410-b5e6-96231b3b80d8
* (Reland with changes) Adding a function for setting coverage output file.Sajjad Mirza2019-06-241-12/+52
| | | | | | | | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@364231 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r362676 "[Profile]: Add runtime interface to specify file handle for ↵Hans Wennborg2019-06-121-52/+12
| | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@363134 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile]: Add runtime interface to specify file handle for profile data.Xinliang David Li2019-06-061-12/+52
| | | | | | | | | Author: Sajjad Mirza Differential Revision: http://reviews.llvm.org/D62541 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@362676 91177308-0d34-0410-b5e6-96231b3b80d8
* Reland compiler-rt support for order file instrumentation.Manman Ren2019-03-081-0/+86
| | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355701 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert compiler-rt diffs for order file instrumentation to get bot green!Manman Ren2019-03-051-86/+0
| | | | | | | | | | This caused issues on Linux/Windows and other platforms. r355343 355350 355350 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355363 91177308-0d34-0410-b5e6-96231b3b80d8
* Order File Instrumentation: dump the data in compiler-rtManman Ren2019-03-041-0/+86
| | | | | | | | | | The profile data will be dumped in a file default_xxx.profraw.order. Differential Revision: https://reviews.llvm.org/D57530 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355343 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Support profiling runtime on FuchsiaPetr Hosek2018-07-251-0/+4
| | | | | | | | | | | | | This ports the profiling runtime on Fuchsia and enables the instrumentation. Unlike on other platforms, Fuchsia doesn't use files to dump the instrumentation data since on Fuchsia, filesystem may not be accessible to the instrumented process. We instead use the data sink to pass the profiling data to the system the same sanitizer runtimes do. Differential Revision: https://reviews.llvm.org/D47208 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337881 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Fix a possible memory leak in parseFilenamePattern().Igor Kudrin2018-07-241-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D49666 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337823 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Add interface to get profile filenameTeresa Johnson2018-07-191-12/+47
| | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337482 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix clang-cl warnings in compiler-rtReid Kleckner2018-04-231-1/+2
| | | | | | | | | The profile library was missing some includes and was erroneously using ftruncate. WinASan was using `= {0}` to initialize structs, which creates -Wmissing-field-initializers and -Wmissing-braces warnings with clang. Use `= {}` instead, since this is C++. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@330616 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Fix value profile runtime merging issuesRong Xu2018-04-021-1/+6
| | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@328987 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Port the runtime to Solaris (retry)Vedant Kumar2017-12-141-5/+5
| | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320731 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "(HEAD -> master, origin/master, origin/HEAD) [profile] Port the ↵Vedant Kumar2017-12-141-5/+5
| | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320728 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Port the runtime to SolarisVedant Kumar2017-12-141-5/+5
| | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320726 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r312240Alex Lorenz2017-08-311-1/+1
| | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@312246 91177308-0d34-0410-b5e6-96231b3b80d8
* Build LLVM with -Wstrict-prototypes enabledAlex Lorenz2017-08-311-1/+1
| | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@312240 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile] create a copy of profile file name from environmentXinliang David Li2017-08-231-2/+4
| | | | | | | | | Original patch by Max Moroz. Differential Revsion: http://reviews.llvm.org/D36903 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311607 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r310857 due to internal test failureXinliang David Li2017-08-151-17/+11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310907 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Add support for relocate profile dumping directoryXinliang David Li2017-08-141-11/+17
| | | | | | | Differential Revsion: http://reviews.llvm.org/D36648 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310857 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Reduce IO in profile dumping with mergingXinliang David Li2017-06-281-11/+19
| | | | | | | | | Differential Revision: http://reviews.llvm.org/D34709 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306561 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile] Remove redundant callXinliang David Li2017-06-271-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306480 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Refactor file/buffer writer callback interfaces /NFCXinliang David Li2017-06-271-5/+18
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306432 91177308-0d34-0410-b5e6-96231b3b80d8
* Resubmit r295469 [PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-writeRong Xu2017-03-171-0/+9
| | | | | | | | | | And also r295364 [PGO] remove unintended debug trace. NFC I removed the test case: it's hard to write synchronized test b/w processes in this framework. I will revisit the test-case later. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298113 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-write"Renato Golin2017-02-201-9/+0
| | | | | | | | Revert "[PGO] remove unintended debug trace. NFC" This reverts commit r295469, r295364, as they are unstable on ARM/AArch64. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295664 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-writeRong Xu2017-02-161-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We found a nondeterministic behavior when doing online profile merging for multi-process applications. The application forks a sub-process and sub-process sets to get SIGKILL when the parent process exits, The first process gets the lock, and dumps the profile. The second one will mmap the file, do the merge and write out the file. Note that before the merged write, we truncate the profile. Depending on the timing, the child process might be terminated abnormally when the parent exits first. If this happens: (1) before the truncation, we will get the profile for the main process (2) after the truncation, and before write-out the profile, we will get 0 size profile. (3) after the merged write, we get merged profile. This patch temporarily suspend the SIGKILL for PR_SET_PDEATHSIG before profile-write and restore it after the write. This patch only applies to Linux system. Reviewers: davidxl Reviewed By: davidxl Subscribers: xur, llvm-commits Differential Revision: https://reviews.llvm.org/D29954 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295364 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Delay profile dir creation until writeXinliang David Li2017-02-141-7/+13
| | | | | | | Differential Revision: http://reviews.llvm.org/D29960 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295108 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] use GetComputerNameExW instead of gethostname on WindowsBob Haarman2016-11-291-6/+6
| | | | | | | | | | | | | Summary: In profile data paths, we replace "%h" with the hostname of the machine the program is running on. On Windows, we used gethostname() to obtain the hostname. This requires linking with ws2_32. With this change, we instead get the hostname from GetComputerNameExW(), which does not require ws2_32. Reviewers: rnk, vsk, amccarth Subscribers: zturner, ruiu, hans Differential Revision: https://reviews.llvm.org/D27178 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288146 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Mark lprofCurFilename as COMPILER_RT_WEAKVedant Kumar2016-10-181-1/+2
| | | | | | | | | | | | | | | | | | This makes __llvm_profile_set_filename() work across dylib boundaries on Darwin. This functionality was originally meant to work on all platforms, but was moved to a Linux-only directory with r272404. The root cause of the test failure on Darwin was that lprofCurFilename was not marked weak. Each dylib maintained its own copy of the variable due to the two-level namespace. Tested with check-profile (on Darwin). I don't expect this to regress other platforms. Differential Revision: https://reviews.llvm.org/D25707 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@284440 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[profile] Hide lprofCurFilename"Vedant Kumar2016-09-231-2/+1
| | | | | | | | | | | | | | | This reverts commit r282294. It breaks a Linux bot: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/12180 It looks like the test checks that __llvm_profile_set_filename() alters the raw profile filename in both the dylib and the main program. Now that lprofCurFilename is hidden, this can't work, and we get two profiles (one for the call to "main" and one for "func"). Back this change out so that we don't affect external users. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282304 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Hide lprofCurFilenameVedant Kumar2016-09-231-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D24885 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282294 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile] suppress verbose rt message by defaultXinliang David Li2016-09-221-5/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282193 91177308-0d34-0410-b5e6-96231b3b80d8
* Correctly escape %.Nico Weber2016-09-081-1/+1
| | | | | | | Found be an MSVC warning; I filed PR30320 for adding a similar warning to clang. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@280900 91177308-0d34-0410-b5e6-96231b3b80d8
* test commit.Ying Yi2016-08-101-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@278210 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile] Implement new API __llvm_profile_dumpXinliang David Li2016-08-091-0/+18
| | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@278092 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile] track ownership of filename pattern stringXinliang David Li2016-08-021-7/+24
| | | | | | | | | | Make sure runtime copy and owns the string when passed in from external users of runtime API. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277507 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile] deprecate __llvm_profile_override_default_filename (part2)Xinliang David Li2016-07-211-20/+17
| | | | | | | | | This eliminates unncessary calls and init functions. Differential Revision: http://reviews.llvm.org/D22614 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276355 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile] bug fix: profile dir not recursively createdXinliang David Li2016-07-211-2/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276234 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor cleanup -- clear name structure before parsingXinliang David Li2016-07-201-6/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276089 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile] implement interface to get profile path prefixXinliang David Li2016-07-201-1/+39
| | | | | | | | | Differential Revision: http://reviews.llvm.org/D22546 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276083 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile] introduce reusable internal interfaces to find dir separator \NFCXinliang David Li2016-07-191-5/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276027 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a typeo.George Burgess IV2016-07-151-1/+1
| | | | | | | (obligatory s/typeo/typo) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275632 91177308-0d34-0410-b5e6-96231b3b80d8
* [Profile] instroduce portability macro for dir separator(sXinliang David Li2016-07-151-1/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275597 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Update a warning message (NFC)Vedant Kumar2016-06-141-3/+2
| | | | | | | It's possible for a merge pool specifier to appear anywhere in a filename pattern. Update the warning to reflect this. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272685 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] cleanup file setting codeXinliang David Li2016-06-101-20/+68
| | | | | | | | Differential Revision: http://reviews.llvm.org/D21219 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272428 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] in-process merging support part-3Xinliang David Li2016-06-081-11/+157
| | | | | | | | Differential Revision: http://reviews.llvm.org/D21056 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272227 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Un-hide two symbolsVedant Kumar2016-06-081-1/+1
| | | | | | | | | | | - lprofCurFilename was intended to have external visibility. This is pending further discussion. - The raw version number doesn't need to be hidden: hiding it may make it easier to accidentally combine FE/IR profiles. See the mailing list discussion on r272081. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272089 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Hide a few external symbols (NFCI)Vedant Kumar2016-06-081-1/+1
| | | | | | | | There are still a few external symbols visible from InstrProfData.inc. The plan for dealing with those isn't as straightforward, so I'll try it in a separate commit. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272081 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Further cleanup/refactor file handling codeXinliang David Li2016-05-251-34/+26
| | | | | | | Also get rid of the redundant strncpy calls. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270730 91177308-0d34-0410-b5e6-96231b3b80d8