summaryrefslogtreecommitdiff
path: root/lib/profile/GCDAProfiling.c
AgeCommit message (Collapse)Author
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-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-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-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
2016-07-25Define compatibility flag if not defined with -std=c++Xinliang David Li
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276708 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19[Profile] move utility interfaces to the right header /NFCXinliang David Li
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276021 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18Code refactoring: extract path prefix handling codeXinliang David Li
.. into reusable interfaces. No functional change is expected. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275807 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15[Profile] instroduce portability macro for dir separator(sXinliang David Li
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275597 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-05[GCDA] Unlock arc file before closing itVedant Kumar
The GCDA writer closed the arc file before unlocking it. This causes an EBADF while unlocking the file, and opens us up to racy behavior. Fixes PR26847. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@262779 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-11Silence MSVC warning about non-void prototypesReid Kleckner
It thinks that these functions don't match the function pointer type that they are passed with: GCDAProfiling.c(578) : warning C4113: 'void (__cdecl *)()' differs in parameter lists from 'void (__cdecl *)(void)' GCDAProfiling.c(579) : warning C4113: 'void (__cdecl *)()' differs in parameter lists from 'void (__cdecl *)(void)' GCDAProfiling.c(580) : warning C4113: 'void (__cdecl *)()' differs in parameter lists from 'void (__cdecl *)(void)' git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@260475 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-19Fix -Wexpansion-to-defined warnings in compiler-rt.Nico Weber
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258200 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-05[PGO] Enable building compiler-rt profile support library on WindowsNathan Slingerland
Summary: This change configures Windows builds to build the complier-rt profile support library (clang_rt.profile-i386.lib). Windows API incompatibilities in the compiler-rt profile lib are also fixed. Reviewers: davidxl, dnovillo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15830 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256848 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09Add support for generating profiles in a given directory.Diego Novillo
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@241824 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-03Add missing includeJustin Bogner
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234037 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-03profile: Protect .gcda output with flockJustin Bogner
This avoids crashing or corrupting data if multiple concurrent processes write to the same .gcda file. This is hard to test, since the previous behaviour was a data race that often worked out, and it ignores errors in flock to fall back to the old racy behaviour so that it won't degrade the behaviour on filesystems that don't support flock. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234036 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-18profile: Improve error messages on bad GCDA filesJustin Bogner
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215933 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-19PGO: Fix obviously wrong typedefs for MSDuncan P. N. Exon Smith
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204267 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-10A fix for platform-dependent types in sanitizers' profiling support lib on ↵Viktor Kutuzov
x64 FreeBSD in 32-bit mode git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@203470 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-19Fix think-o from r199332 -- write to the new_filename we're building, notNick Lewycky
filename the global variable. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199572 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-15Avoid shadowing the global filename. Reorg mangle_filename to be moreJoerg Sonnenberger
precise in the length accounting and use memcpy instead of strcpy/strcat. Differential Revision: http://llvm-reviews.chandlerc.com/D2547 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199332 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10Fix minor gcc warnings.Matt Arsenault
C++ style comments not allowed in C90, signed unsigned comparision. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196948 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-04compiler-rt: Added support for function checksums.Yuchen Wu
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196357 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20compiler-rt: Support for file checksum in GCDAProfiling.cpp.Yuchen Wu
Takes file checksum as an argument to write to .gcda file. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195190 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-12Added summary info to GCDAProfiling.Yuchen Wu
This function will be called by GCOVProfiling to write and update object and program summaries to be read in by llvm-cov. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194499 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11Fix typoBill Wendling
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190543 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09Don't allow a NULL-length file. Try to revert to the buffered version.Bill Wendling
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190359 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-27Revert hack that omits errno on Darwin platforms. We now have an acceptable ↵Bill Wendling
'errno' header. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@185106 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-26Fix a use after free I introduced and that Bill caught in code reviewChandler Carruth
(thanks!) by deferring the free of the filename until we finish writing the coverage data to that file. Bill, let me know if you'd prefer a different approach! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184895 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-25Don't use 'errno.h' on Apple just yet. This breaks for some of our buildbots.Bill Wendling
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184878 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-25Address a few of the issues in GCDAProfiling I noted when lookingChandler Carruth
through Bill's patch: 1) Correctly test the file descriptor after the sceond attempt at creating the file. 2) Make the filename a global so that we can issue error messages from other routines. 3) Check errno in several places and print it out so that errors are easier to track down. I don't really expect any of these to fix the current failures I'm seeing, but I'm hopeful they'll at least let me debug them. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184799 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-23Don't override 'mode' and cleanup some variable names.Bill Wendling
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182599 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-23Add 'mode' parameter when using 'O_CREAT'. Thanks to Evgeniy for pointing ↵Bill Wendling
this out. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182598 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-23Performance improvement.Bill Wendling
Using fwrite and fread was very *very* slow. The resulting code was multiple times slower than GCC's implementation of gcov. Replace the fwrite/fread system with an mmap() version. If the `.gcda' file doesn't exist, we (re)allocate a buffer that we write into. That gets written to the `.gcda' file in one chunk. If the `.gcda' file already exists, we simply mmap() the file, modify the mapped data, and use msync() to write the contents out to disk. It's much easier than implementing our own buffering scheme, and we don't have to use fwrite's and fread's buffering. For those who are numbers-oriented, here are some timings: GCC Verison ----------- `.gcda' files don't exist: 23s `.gcda' files do exist: 14s LLVM Version (before this change) --------------------------------- `.gcda' files don't exist: 28s `.gcda' files do exist: 28s LLVM Version (with this change) ------------------------------- `.gcda' files don't exist: 18s `.gcda' files do exist: 4s It's a win-win-win-win-lose-win-win scenario! <rdar://problem/13466086> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182563 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-15Try to improve performance by using a read/write buffer instead of I/O.Bill Wendling
The calls to fwrite/fread can be very expensive. GCC avoids this by using a buffer to read and write from the file, thus limiting the number of fwrite/fread calls. <rdar://problem/13466086> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@181924 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-03I was wrong in my testing.Bill Wendling
There isn't a speedup when using unbuffered I/O. It slows it down in fact. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@181060 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-03Use unbuffered I/O. This reduces the runtime by about half. Our ↵Bill Wendling
implementation is now only about 5 times slower than gcc's. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@180980 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-22Improve performance of file I/O.Bill Wendling
The fread / fwrite calls were happening for each timer. However, that could be pretty expensive for a large number of timers. Instead, read and write the timers in one call. This gives ~10% speedup in compilation time. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@179990 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-20Create a coverage initialization function.Bill Wendling
This function replaces the call of `atexit' from being generated in the compile units. Basically, it registers the "writeout" and "flush" functions (if present). It will generate calls to the `atexit' function for cleanups and final writeout functions, but only once. This is better than checking for `main', because a library may not have a `main' function in it. <rdar://problem/12439551> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177578 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-19Add a way to register and execute "writeout" functions.Bill Wendling
It may be prohibitively expensive to write out >1000 files at the same time. So we would rather emit them serially. These functions allow the GCOV implementation to register the functions that writeout the GCOV information per compile unit. At exit, they are written. <rdar://problem/12439551> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177436 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-18Add some GCOV functions that register all of the __llvm_gcov_flush() functions.Bill Wendling
The __llvm_gcov_flush() functions only work for the local compile unit. However, when __gcov_flush() is called, the user expects all of the counters to be flushed, not just the ones in the current compile unit. This adds some library functions that register the flush functions. It also defined __gcov_flush() so that loops through that list and calls the functions. PR15191 & <rdar://problem/13167507> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177337 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-09Don't emit the extra checksum into the .gcda file if the user hasn't asked for Nick Lewycky
it. Fortunately, versions of gcov that predate the extra checksum also ignore any extra data, so this isn't a problem. This matches the API change made in r176745. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@176746 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-07Take the GCDA version string as an input to llvm_gcda_start_file.Nick Lewycky
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@176618 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-28Holy macaroons, somebody made a copy of llvm/runtime/profile/GCDAProfiling.c,Nick Lewycky
didn't delete the original, and now they've diverged. I have no idea what's going on. Apply my patch in r176173 to this one too, this one looks newer? git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@176236 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-17Remove debugging code.Bill Wendling
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@164052 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-14Remove unused variable.Bill Wendling
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163930 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-14Add support for reading the GCDA file and merging the arc information.Bill Wendling
With the advent of the __llvm_gcov_flush function, we need to be able to merge counts into the .gcda files in an intelligent manner. This involves reading the file if it exists, adding the counts together, and then writing the results. <rdar://problem/12185886> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163923 91177308-0d34-0410-b5e6-96231b3b80d8