summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/profile/InstrProfilingUtil.c
Commit message (Collapse)AuthorAgeFilesLines
* [profile] Fix file contention causing dropped counts on Windows under ↵Hans Wennborg2019-11-271-2/+7
| | | | | | | | | | | | | | | | | | | | | -fprofile-generate See PR43425: https://bugs.llvm.org/show_bug.cgi?id=43425 When writing profile data on Windows we were opening profile file with exclusive read/write access. In case we are trying to write to the file from multiple processes simultaneously, subsequent calls to CreateFileA would return INVALID_HANDLE_VALUE. To fix this, I changed to open without exclusive access and then take a lock. Patch by Michael Holman! Differential revision: https://reviews.llvm.org/D70330
* compiler-rt: Fix warning if COMPILER_RT_HAS_FCNTL_LCK is 0Nico Weber2019-08-211-0/+1
| | | | | | | Fixes "warning: implicit declaration of function 'flock' is invalid in C99" for flock(). llvm-svn: 369534
* [profile] In Android, do not mkdir() dirs in GCOV_PREFIXPirama Arumuga Nainar2019-07-251-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In Android, attempting to mkdir() or even stat() top-level directories like /data causes noisy selinux denials. During whole-system coverage instrumentation, this causes a deluge of noisy messages that drown out legitimate selinux denials, that should be audited and fixed. To avoid this, skip creating any directory in GCOV_PREFIX (thereby assuming that it exists). - Android platform ensures that the GCOV_PREFIX used in Android is created and read/writable by all processes. - This only affects the Android platform (by checking against __ANDROID_API_FUTURE__) and for apps built with Clang coverage, the runtime will still create any non-existent parent directories for the coverage files. Reviewers: srhines, davidxl Subscribers: krytarowski, #sanitizers, danalbert, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D65245 llvm-svn: 367064
* (Reland with changes) Adding a function for setting coverage output file.Sajjad Mirza2019-06-241-0/+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/+0
| | | | | | | | | | | | | | | 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-0/+20
| | | | | | | | Author: Sajjad Mirza Differential Revision: http://reviews.llvm.org/D62541 llvm-svn: 362676
* [profile] Provide lprofGetHostName for all windows environmentsMartin Storsjo2019-02-131-1/+1
| | | | | | | | | This function doesn't use anything MSVC specific but works fine for any _WIN32 target. Differential Revision: https://reviews.llvm.org/D58106 llvm-svn: 353918
* 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
* [compiler-rt] Add a routine to specify the mode used when creating profile dirs.Matt Davis2018-07-311-1/+10
| | | | | | | | | | | | | | | | | | | | | Summary: This patch introduces `llvm_profile_set_dir_mode` and `llvm_profile_get_dir_mode` to the compiler-rt profile API. Originally, profile data was placed into a directory that was created with a hard-coded mode value of 0755 (for non-win32 builds). In certain cases, it can be helpful to create directories with a different mode other than 0755. This patch introduces set/get routines to allow users to specify a desired mode. The default remains at 0755. Reviewers: void, probinson Reviewed By: probinson Subscribers: probinson, dberris, cfe-commits Differential Revision: https://reviews.llvm.org/D49953 llvm-svn: 338456
* [profile] Fix finding the first and last directory separators on Windows.Igor Kudrin2018-07-241-10/+8
| | | | | | | | | Until now, our code preferred backslashes to slashes, whereas Windows allows using both types of directory separators in one path string. Differential Revision: https://reviews.llvm.org/D49664 llvm-svn: 337826
* Include process.h for getpid on Windows in instr profilingReid Kleckner2017-12-211-0/+1
| | | | llvm-svn: 321313
* [profile] Port the runtime to Solaris (retry)Vedant Kumar2017-12-141-15/+53
| | | | | | | | | | | | | 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-52/+14
| | | | | | | | | | | 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-14/+52
| | | | | | | | | | | 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
* Revert r310857 due to internal test failureXinliang David Li2017-08-151-2/+1
| | | | llvm-svn: 310907
* [PGO] Add support for relocate profile dumping directoryXinliang David Li2017-08-141-1/+2
| | | | | | Differential Revsion: http://reviews.llvm.org/D36648 llvm-svn: 310857
* Resubmit r295469 [PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-writeRong Xu2017-03-171-0/+23
| | | | | | | | 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. llvm-svn: 298113
* Revert "[PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-write"Renato Golin2017-02-201-23/+0
| | | | | | | | Revert "[PGO] remove unintended debug trace. NFC" This reverts commit r295469, r295364, as they are unstable on ARM/AArch64. llvm-svn: 295664
* [PGO] remove unintended debug trace. NFCRong Xu2017-02-171-4/+1
| | | | llvm-svn: 295469
* [PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-writeRong Xu2017-02-161-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 295364
* [profile] use GetComputerNameExW instead of gethostname on WindowsBob Haarman2016-11-291-1/+13
| | | | | | | | | | | | 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 llvm-svn: 288146
* [Profile] introduce reusable internal interfaces to find dir separator \NFCXinliang David Li2016-07-191-0/+23
| | | | llvm-svn: 276027
* [Profile] use portable macro /NFCXinliang David Li2016-07-191-1/+1
| | | | llvm-svn: 276019
* Code refactoring: extract path prefix handling codeXinliang David Li2016-07-181-0/+52
| | | | | | .. into reusable interfaces. No functional change is expected. llvm-svn: 275807
* Use CreateFileA and add a FIXME to switch to the wide variantReid Kleckner2016-06-231-2/+3
| | | | | | | No functional change. Required to build with -DUNICODE, as is done in http://reviews.llvm.org/D21643 llvm-svn: 273571
* Fix most MSVC warnings in compiler-rt profiling libraryReid Kleckner2016-06-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here's the warnings and how they were fixed: - InstrProfilingUtil.c(110): warning C4013: '_open_osfhandle' undefined; assuming extern returning int Include io.h to get the prototype. - warning C4005: 'FILE_MAP_EXECUTE': macro redefinition Stop trying to support pre-XP versions of Windows, don't attempt to define this macro. - InstrProfilingWriter.c(271): warning C4221: nonstandard extension used: 'Data': cannot be initialized using address of automatic variable 'Header' - InstrProfilingWriter.c(275): warning C4221: nonstandard extension used: 'Data': cannot be initialized using address of automatic variable 'Zeroes' Turn this warning off. This is definitely legal in C++, all compilers accept it, and I only have room for half of one language standard in my brain. - InstrProfilingValue.c(320): warning C4113: 'uint32_t (__cdecl *)()' differs in parameter lists from 'uint32_t (__cdecl *)(void)' Fix this with an explicit (void) in the prototype. - InstrProfilingMerge.c.obj : warning LNK4006: _VPMergeHook already defined in InstrProfilingMergeFile.c.obj; second definition ignored Last remaining warning. This is from linking a selectany definition with a strong definition. We need to sort out weak symbols in compiler-rt in general, though. llvm-svn: 273026
* [profile] Pass extra build flags (feature enabling macros) to Darwin buildXinliang David Li2016-06-081-2/+0
| | | | | | Differential Revision: http://reviews.llvm.org/D21119 llvm-svn: 272162
* [profile] Hide a few external symbols (NFCI)Vedant Kumar2016-06-081-2/+2
| | | | | | | | 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. llvm-svn: 272081
* [profile] code cleanup /NFCXinliang David Li2016-06-061-9/+17
| | | | | | | Address review feedback for better readability. llvm-svn: 271922
* [profile] in-process mergeing support (part-2)Xinliang David Li2016-06-061-1/+54
| | | | | | | | | | | (Part-1 merging API is in profile runtime) This patch implements a portable file opening API with exclusive access for the process. In-process profile merge requires profile file update to be atomic/fully sychronized. llvm-svn: 271864
* [profile] Add portability macro for atomic fetch_and_addXinliang David Li2016-05-161-0/+7
| | | | | | | This is another enabler patch to support value profiling without dynamic memory allocation. llvm-svn: 269719
* [libprofile] Handle '\\' in __llvm_profile_recursive_mkdirSean Silva2016-03-281-2/+4
| | | | | | | | | | | | | | This is implicitly needed at least by gcc-flag-compatibility.test The thing that needs it is the `\` preceding the "default.profraw" appended internally by clang when doing `-fprofile-use=`. Clang uses `\` because is uses sys::path::append which will use `\` on a Windows host. This is wrong, but I don't think there's an easy way to solve it (maybe just always using `/` since places that accept `\` also tend to accept `/`, but not the other way around). llvm-svn: 264665
* cleanup: remove dead preprocessing branch /nfcXinliang David Li2016-03-061-2/+0
| | | | llvm-svn: 262792
* [PGO] cleanup: move one support method into InstrProfilingUtil.h /NFCXinliang David Li2016-03-061-0/+17
| | | | llvm-svn: 262791
* [PGO] internal API name cleanups (for better consistency)Xinliang David Li2016-03-061-1/+1
| | | | llvm-svn: 262788
* Minor cleanupXinliang David Li2016-03-061-0/+13
| | | | | | move a function def to InstrProfilingUtil.c llvm-svn: 262785
* [PGO] cleanup: unify prefix for portability macrosXinliang David Li2015-12-161-1/+1
| | | | llvm-svn: 255748
* [PGO] Compiler-rt cleanup -- introduces macros for various macrosXinliang David Li2015-11-231-1/+2
| | | | | | | This makes code more readable and be made more portable in the future. There is no functional change. llvm-svn: 253845
* Add support for generating profiles in a given directory.Diego Novillo2015-07-091-0/+35
When the file is initialized, this patch checks whether the path specifies a directory. If so, it creates the directory tree before truncating the file. Use default.profdata instead of pgo-data for default indexed profile name. llvm-svn: 241824
OpenPOWER on IntegriCloud