summaryrefslogtreecommitdiff
path: root/lib/profile
AgeCommit message (Collapse)Author
2018-07-19[profile] Add interface to get profile filenameTeresa Johnson
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
2018-07-11Fix reading 32 bit gcov tag values on little-endian machinesMarco Castelluccio
Summary: The write buffer contains signed chars, which means the shift operations caused values such as the arc tag value (0x01a10000) to be read incorrectly (0xffa10000). This fixes a regression from https://reviews.llvm.org/D49132. Reviewers: uweigand, davidxl Reviewed By: uweigand Subscribers: llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D49161 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336775 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-10[gcov] Fix fallout from r336693Ulrich Weigand
Fix building GCDAProfiling.c with pre-C99 compilers. This caused a build bot failure. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336706 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-10[gcov] Fix gcov profiling on big-endian machinesUlrich Weigand
Two fixes required to handle big-endian systems: - 64-bit counter values are stored in a mixed-endian format in the gcov files: a 32-bit low-part followed by a 32-bit high part. Note that this is already implemented correctly on the LLVM side, see GCOVBuffer::readInt64. - The tag values (e.g. arcs tag, object summary tag, ...) are aways written as the same sequence of bytes independent of byte order. But when *reading* them back in, the code reads them as 32-bit values in host byte order. For the comparisons to work correctly, this should instead always read them as little-endian values. Fixes PR 38121. Reviewed By: marco-c Differential Revision: https://reviews.llvm.org/D49132 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336693 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-10Reapply "Make __gcov_flush flush counters for all shared libraries"Marco Castelluccio
This reapplies r336365, after marking tests as failing on various configurations. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336678 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-10[CMake] Add compiler-rt header files to the list of sources for targetsDan Liew
when building with an IDE so that header files show up in the UI. This massively improves the development workflow in IDEs. To implement this a new function `compiler_rt_process_sources(...)` has been added that adds header files to the list of sources when the generator is an IDE. For non-IDE generators (e.g. Ninja/Makefile) no changes are made to the list of source files. The function can be passed a list of headers via the `ADDITIONAL_HEADERS` argument. For each runtime library a list of explicit header files has been added and passed via `ADDITIONAL_HEADERS`. For `tsan` and `sanitizer_common` a list of headers was already present but it was stale and has been updated to reflect the current state of the source tree. The original version of this patch used file globbing (`*.{h,inc,def}`) to find the headers but the approach was changed due to this being a CMake anti-pattern (if the list of headers changes CMake won't automatically re-generate if globbing is used). The LLVM repo contains a similar function named `llvm_process_sources()` but we don't use it here for several reasons: * It depends on the `LLVM_ENABLE_OPTION` cache variable which is not set in standalone compiler-rt builds. * We would have to `include(LLVMProcessSources)` which I'd like to avoid because it would include a bunch of stuff we don't need. Differential Revision: https://reviews.llvm.org/D48422 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336663 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-07Revert "Make __gcov_flush flush counters for all shared libraries"Michael Zolotukhin
This reverts r336365: the added tests are failing on various configurations (e.g. on green-dragon). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336474 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-05Make __gcov_flush flush counters for all shared librariesMarco Castelluccio
Summary: This will make the behavior of __gcov_flush match the GCC behavior. I would like to rename __gcov_flush to __llvm_gcov_flush (in case of programs linking to libraries built with different compilers), but I guess we can't for compatibility reasons. Reviewers: davidxl Reviewed By: davidxl Subscribers: samsonov, vitalybuka, pcc, kcc, junbuml, glider, fhahn, eugenis, dvyukov, davidxl, srhines, chh, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D48538 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336365 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-29[profile] Add llvm_gcov_flush to be called outside a shared libraryChih-Hung Hsieh
__gcov_flush is hidden. For applications to dump profiling data of selected .so files, they can use dlsym to find and call llvm_gcov_flush in each .so file. Differential Revision: https://reviews.llvm.org/D45454 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336019 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09[CMake] Build shared version of runtimes for FuchsiaPetr Hosek
Fuchsia is no longer treated as UNIX which means we need to explicitly enable building of shared versions of runtimes. Differential Revision: https://reviews.llvm.org/D46609 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@331922 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-23Fix clang-cl warnings in compiler-rtReid Kleckner
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
2018-04-02[profile] Fix value profile runtime merging issuesRong Xu
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
2018-01-22[NFC] fix trivial typos in commentsHiroshi Inoue
"the the" -> "the" git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@323080 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-03Hide some symbols to avoid a crash on shutdown when using code coverageMarco Castelluccio
Summary: gcov / gcda-based profiling crashes when shared libraries are unloaded Patch by Benoit Belley and test by Marco Castelluccio for Firefox See https://bugs.llvm.org/show_bug.cgi?id=27224 & https://bugzilla.mozilla.org/show_bug.cgi?id=1401230 Reviewers: davidxl, rnk, void Subscribers: jessicah, marco-c, belleyb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D38124 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321703 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-03Flush gcda files before unlocking themMarco Castelluccio
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=35464. Reviewers: zturner, rnk, void Subscribers: sylvestre.ledru, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D40610 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321702 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-21Include process.h for getpid on Windows in instr profilingReid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321313 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-14[profile] Port the runtime to Solaris (retry)Vedant Kumar
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
2017-12-14Revert "(HEAD -> master, origin/master, origin/HEAD) [profile] Port the ↵Vedant Kumar
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
2017-12-14[profile] Port the runtime to SolarisVedant Kumar
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
2017-11-14[profile] Update InstrProfData.inc to sync with llvmVedant Kumar
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318230 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-08Implement flock for Windows in compiler-rtMarco Castelluccio
Summary: This patch implements flock for Windows, needed to make gcda writing work in a multiprocessing scenario. Fixes https://bugs.llvm.org/show_bug.cgi?id=34923. Reviewers: zturner Reviewed By: zturner Subscribers: rnk, zturner, llvm-commits Differential Revision: https://reviews.llvm.org/D38891 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317705 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-18Use O_BINARY when opening GCDA file on WindowsMarco Castelluccio
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=34922. Apparently, the mode in **fdopen** gets simply ignored and Windows only cares about the mode of the original **open**. I have verified this both with the simple case from bug 34922 and with a full Firefox build. Reviewers: zturner Reviewed By: zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D38984 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316048 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18[profile] Update InstrProfData.incVedant Kumar
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313599 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-31Revert r312240Alex Lorenz
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
2017-08-31Build LLVM with -Wstrict-prototypes enabledAlex Lorenz
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
2017-08-23[Profile] create a copy of profile file name from environmentXinliang David Li
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
2017-08-22[profile] Fix warning about C++ style comment in C fileHans Wennborg
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311496 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-15Revert r310857 due to internal test failureXinliang David Li
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310907 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-14[PGO] Add support for relocate profile dumping directoryXinliang David Li
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
2017-07-28Change INSTR_PROF_DEFAULT_NUM_VAL_PER_SITE from 8 to 16.Dehao Chen
Summary: In the current implementation, the defaul number of values per site tracked by value profiler is 8, which is too small and could introduce inaccuracies to profile. Changing it to 16 will be able to gain more accurate value profiler. Reviewers: davidxl, tejohnson Reviewed By: tejohnson Subscribers: sanjoy, llvm-commits Differential Revision: https://reviews.llvm.org/D35964 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309388 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-29[profile] Move __llvm_profile_filename into a separate objectVedant Kumar
Users can specify the path a raw profile is written to by passing -fprofile-instr-generate=<path>, but this functionality broke on Darwin after __llvm_profile_filename was made weak [1], resulting in profiles being written to "default.profraw" even when <path> is specified. The situation is that instrumented programs provide a weak definition of __llvm_profile_filename, which conflicts with a weak redefinition provided by the profiling runtime. The linker appears to pick the 'winning' definition arbitrarily: on Darwin, it usually prefers the larger definition, which is probably why the instrprof-override-filename.c test has been passing. The fix is to move the runtime's definition into a separate object file within the archive. This means that the linker won't "see" the runtime's definition unless the user program has not provided one. I couldn't think of a great way to test this other than to mimic the Darwin failure: use -fprofile-instr-generate=<some-small-path>. Testing: check-{clang,profile}, modified instrprof-override-filename.c. [1] [Profile] deprecate __llvm_profile_override_default_filename https://reviews.llvm.org/D22613 https://reviews.llvm.org/D22614 Differential Revision: https://reviews.llvm.org/D34797 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306710 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-28[PGO] Reduce IO in profile dumping with mergingXinliang David Li
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
2017-06-27[Profile] Remove redundant callXinliang David Li
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306480 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-27[PGO] Refactor file/buffer writer callback interfaces /NFCXinliang David Li
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
2017-04-15[profile] Sync up InstrProfData.inc (NFC)Vedant Kumar
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300383 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13[Profile] PE binary coverage bug fixXinliang David Li
PR/32584 Differential Revision: https://reviews.llvm.org/D32023 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300278 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11Revert 299954 : test failure needs to be fixedXinliang David Li
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299960 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11[Profile] PE binary coverage bug fixXinliang David Li
PR/32584 Differential Revision: https://reviews.llvm.org/D31939 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299954 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-17Resubmit r295469 [PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-writeRong Xu
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
2017-03-15[PGO] Value profile support for value rangesRong Xu
This patch adds profile run time support to profile a range of values. This interface will be used in profiling the size of memory intrinsic calls. Differential Revision: http://reviews.llvm.org/D28964 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297895 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-20Revert "[PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-write"Renato Golin
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
2017-02-17[PGO] remove unintended debug trace. NFCRong Xu
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295469 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-16[PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-writeRong Xu
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
2017-02-14[PGO] Delay profile dir creation until writeXinliang David Li
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
2016-11-29[Profile] Fix value profiler eviction bugXinliang David Li
Differential Revision: https://reviews.llvm.org/D27224 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288204 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-29[profile] use GetComputerNameExW instead of gethostname on WindowsBob Haarman
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
2016-10-18[profile] Mark lprofCurFilename as COMPILER_RT_WEAKVedant Kumar
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
2016-09-23Revert "[profile] Hide lprofCurFilename"Vedant Kumar
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
2016-09-23[profile] Hide lprofCurFilenameVedant Kumar
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
2016-09-22[Profile] Remove unused variableXinliang David Li
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282198 91177308-0d34-0410-b5e6-96231b3b80d8