summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/profile/GCDAProfiling.c
Commit message (Collapse)AuthorAgeFilesLines
* [profile] Don't crash when forking in several threadsCalixte Denizet2020-05-071-2/+52
| | | | | | | | | | | | | | | | | | | Summary: When forking in several threads, the counters were written out in using the same global static variables (see GCDAProfiling.c): that leads to crashes. So when there is a fork, the counters are resetted in the child process and they will be dumped at exit using the interprocess file locking. When there is an exec, the counters are written out and in case of failures they're resetted. Reviewers: jfb, vsk, marco-c, serge-sans-paille Reviewed By: marco-c, serge-sans-paille Subscribers: llvm-commits, serge-sans-paille, dmajor, cfe-commits, hiraditya, dexonsmith, #sanitizers, marco-c, sylvestre.ledru Tags: #sanitizers, #clang, #llvm Differential Revision: https://reviews.llvm.org/D78477 (cherry picked from commit bec223a9bc4eb9747993ee9a4c1aa135c32123e6)
* Revert "[compiler-rt] Add a critical section when flushing gcov counters"Hans Wennborg2020-02-261-24/+1
| | | | | | See the discussion on PR44792. This reverts commit 02ce9d8ef5a84bc884de4105eae5f8736ef67634.
* [compiler-rt] Add a critical section when flushing gcov countersCalixte Denizet2019-12-121-1/+24
| | | | | | | | | | | | | | | | | Summary: Counters can be flushed in a multi-threaded context for example when the process is forked in different threads (https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp#L632-L663). In order to avoid pretty bad things, a critical section is needed around the flush. We had a lot of crashes in this code in Firefox CI when we switched to clang for linux ccov builds and those crashes disappeared with this patch. Reviewers: marco-c, froydnj, dmajor, davidxl, vsk Reviewed By: marco-c, dmajor Subscribers: ahatanak, froydnj, dmajor, dberris, jfb, #sanitizers, llvm-commits, sylvestre.ledru Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D70910
* Revert "[compiler-rt] Add a critical section when flushing gcov counters"Akira Hatanaka2019-12-091-24/+1
| | | | | | | This reverts commit 88f5bf77f92899b19fdafdffc7b060f930c1cb8b as it broke green dragon bots. http://lab.llvm.org:8080/green/job/clang-stage1-RA/4401/
* [compiler-rt] Add a critical section when flushing gcov countersCalixte Denizet2019-12-091-1/+24
| | | | | | | | | | | | | | | | | Summary: Counters can be flushed in a multi-threaded context for example when the process is forked in different threads (https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp#L632-L663). In order to avoid pretty bad things, a critical section is needed around the flush. We had a lot of crashes in this code in Firefox CI when we switched to clang for linux ccov builds and those crashes disappeared with this patch. Reviewers: marco-c, froydnj, dmajor, davidxl Reviewed By: marco-c, dmajor Subscribers: froydnj, dmajor, dberris, jfb, #sanitizers, llvm-commits, sylvestre.ledru Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D70910
* Silence -Wformat warnings about GetLastError returning ULONGReid Kleckner2019-02-071-7/+7
| | | | llvm-svn: 353485
* 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
* [GCOV] Close file mapping handle on Windows, so flushed gcda files can be ↵Marco Castelluccio2018-11-071-0/+49
| | | | | | removed while the process is in execution llvm-svn: 346300
* [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 llvm-svn: 337881
* Fix reading 32 bit gcov tag values on little-endian machinesMarco Castelluccio2018-07-111-1/+1
| | | | | | | | | | | | | | | | | 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 llvm-svn: 336775
* [gcov] Fix fallout from r336693Ulrich Weigand2018-07-101-1/+2
| | | | | | | Fix building GCDAProfiling.c with pre-C99 compilers. This caused a build bot failure. llvm-svn: 336706
* [gcov] Fix gcov profiling on big-endian machinesUlrich Weigand2018-07-101-8/+21
| | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 336693
* Reapply "Make __gcov_flush flush counters for all shared libraries"Marco Castelluccio2018-07-101-69/+80
| | | | | | | This reapplies r336365, after marking tests as failing on various configurations. llvm-svn: 336678
* Revert "Make __gcov_flush flush counters for all shared libraries"Michael Zolotukhin2018-07-071-80/+69
| | | | | | | This reverts r336365: the added tests are failing on various configurations (e.g. on green-dragon). llvm-svn: 336474
* Make __gcov_flush flush counters for all shared librariesMarco Castelluccio2018-07-051-69/+80
| | | | | | | | | | | | | | | | | 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 llvm-svn: 336365
* [profile] Add llvm_gcov_flush to be called outside a shared libraryChih-Hung Hsieh2018-06-291-0/+10
| | | | | | | | | | __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 llvm-svn: 336019
* Hide some symbols to avoid a crash on shutdown when using code coverageMarco Castelluccio2018-01-031-0/+13
| | | | | | | | | | | | | | | | | | | 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 llvm-svn: 321703
* Flush gcda files before unlocking themMarco Castelluccio2018-01-031-0/+1
| | | | | | | | | | | | 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 llvm-svn: 321702
* [profile] Port the runtime to Solaris (retry)Vedant Kumar2017-12-141-11/+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 llvm-svn: 320731
* Revert "(HEAD -> master, origin/master, origin/HEAD) [profile] Port the ↵Vedant Kumar2017-12-141-5/+11
| | | | | | | | | | | 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-11/+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 llvm-svn: 320726
* Use O_BINARY when opening GCDA file on WindowsMarco Castelluccio2017-10-181-3/+6
| | | | | | | | | | | | | | | | | | | 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 llvm-svn: 316048
* Revert r312240Alex Lorenz2017-08-311-2/+2
| | | | | | | 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-2/+2
| | | | | | | | | | | 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
* Define compatibility flag if not defined with -std=c++Xinliang David Li2016-07-251-0/+3
| | | | llvm-svn: 276708
* [Profile] move utility interfaces to the right header /NFCXinliang David Li2016-07-191-1/+0
| | | | llvm-svn: 276021
* Code refactoring: extract path prefix handling codeXinliang David Li2016-07-181-36/+8
| | | | | | .. into reusable interfaces. No functional change is expected. llvm-svn: 275807
* [Profile] instroduce portability macro for dir separator(sXinliang David Li2016-07-151-3/+5
| | | | llvm-svn: 275597
* [GCDA] Unlock arc file before closing itVedant Kumar2016-03-051-1/+1
| | | | | | | | | 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. llvm-svn: 262779
* Silence MSVC warning about non-void prototypesReid Kleckner2016-02-111-3/+3
| | | | | | | | | | | 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)' llvm-svn: 260475
* Fix -Wexpansion-to-defined warnings in compiler-rt.Nico Weber2016-01-191-1/+5
| | | | llvm-svn: 258200
* [PGO] Enable building compiler-rt profile support library on WindowsNathan Slingerland2016-01-051-0/+6
| | | | | | | | | | | | 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 llvm-svn: 256848
* Add support for generating profiles in a given directory.Diego Novillo2015-07-091-25/+3
| | | | | | | | | | 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
* Add missing includeJustin Bogner2015-04-031-0/+1
| | | | llvm-svn: 234037
* profile: Protect .gcda output with flockJustin Bogner2015-04-031-0/+6
| | | | | | | | | | | 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. llvm-svn: 234036
* profile: Improve error messages on bad GCDA filesJustin Bogner2014-08-181-4/+12
| | | | llvm-svn: 215933
* PGO: Fix obviously wrong typedefs for MSDuncan P. N. Exon Smith2014-03-191-1/+1
| | | | llvm-svn: 204267
* A fix for platform-dependent types in sanitizers' profiling support lib on ↵Viktor Kutuzov2014-03-101-4/+19
| | | | | | x64 FreeBSD in 32-bit mode llvm-svn: 203470
* Fix think-o from r199332 -- write to the new_filename we're building, notNick Lewycky2014-01-191-1/+1
| | | | | | filename the global variable. llvm-svn: 199572
* Avoid shadowing the global filename. Reorg mangle_filename to be moreJoerg Sonnenberger2014-01-151-23/+29
| | | | | | | | | precise in the length accounting and use memcpy instead of strcpy/strcat. Differential Revision: http://llvm-reviews.chandlerc.com/D2547 llvm-svn: 199332
* Fix minor gcc warnings.Matt Arsenault2013-12-101-11/+11
| | | | | | | C++ style comments not allowed in C90, signed unsigned comparision. llvm-svn: 196948
* compiler-rt: Added support for function checksums.Yuchen Wu2013-12-041-2/+2
| | | | llvm-svn: 196357
* compiler-rt: Support for file checksum in GCDAProfiling.cpp.Yuchen Wu2013-11-201-5/+7
| | | | | | Takes file checksum as an argument to write to .gcda file. llvm-svn: 195190
* Added summary info to GCDAProfiling.Yuchen Wu2013-11-121-1/+50
| | | | | | | This function will be called by GCOVProfiling to write and update object and program summaries to be read in by llvm-cov. llvm-svn: 194499
* Fix typoBill Wendling2013-09-111-1/+1
| | | | llvm-svn: 190543
* Don't allow a NULL-length file. Try to revert to the buffered version.Bill Wendling2013-09-091-0/+5
| | | | llvm-svn: 190359
* Revert hack that omits errno on Darwin platforms. We now have an acceptable ↵Bill Wendling2013-06-271-9/+0
| | | | | | 'errno' header. llvm-svn: 185106
* Fix a use after free I introduced and that Bill caught in code reviewChandler Carruth2013-06-261-14/+13
| | | | | | | | | (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! llvm-svn: 184895
* Don't use 'errno.h' on Apple just yet. This breaks for some of our buildbots.Bill Wendling2013-06-251-0/+9
| | | | llvm-svn: 184878
* Address a few of the issues in GCDAProfiling I noted when lookingChandler Carruth2013-06-251-7/+37
| | | | | | | | | | | | | | | | 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. llvm-svn: 184799
OpenPOWER on IntegriCloud