summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/profile/InstrProfilingPort.h
Commit message (Collapse)AuthorAgeFilesLines
* [profile] Support online merging with continuous sync modeVedant Kumar2019-11-181-0/+2
| | | | | | | | | | | | | | | Make it possible to use online profile merging ("%m" mode) with continuous sync ("%c" mode). To implement this, the merged profile is locked in the runtime initialization step and either a) filled out for the first time or b) checked for compatibility. Then, the profile can simply be mmap()'d with MAP_SHARED set. With the mmap() in place, counter updates from every process which uses an image are mapped onto the same set of physical pages assigned by the filesystem cache. After the mmap() is set up, the profile is unlocked. Differential Revision: https://reviews.llvm.org/D69586
* [compiler-rt] [profile] Fix building for MinGW after d889d1efefe9fMartin Storsjö2019-11-011-0/+1
| | | | | | | | This commit added use of a Windows API in InstrProfilingPort.h. When _MSC_VER is defined (for MSVC), windows.h is already included earlier in the same header (for atomics), but MinGW, the gcc atomics builtins are used instead. Therefore explicitly include windows.h here, where the API is used.
* [profile] Third speculative fix for Windows after D68351Vedant Kumar2019-10-311-1/+0
| | | | | | | _putenv on Windows takes 1 argument, whereas setenv elsewhere takes 3. Just treat the two platforms differently. http://lab.llvm.org:8011/builders/sanitizer-windows/builds/53547
* [profile] Speculative fix for Windows after D68351Vedant Kumar2019-10-311-0/+1
| | | | | | setenv() appears to not be available on Windows: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/53545/steps/stage%201%20build/logs/stdio
* [profile] Add a mode to continuously sync counter updates to a fileVedant Kumar2019-10-311-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for continuously syncing profile counter updates to a file. The motivation for this is that programs do not always exit cleanly. On iOS, for example, programs are usually killed via a signal from the OS. Running atexit() handlers after catching a signal is unreliable, so some method for progressively writing out profile data is necessary. The approach taken here is to mmap() the `__llvm_prf_cnts` section onto a raw profile. To do this, the linker must page-align the counter and data sections, and the runtime must ensure that counters are mapped to a page-aligned offset within a raw profile. Continuous mode is (for the moment) incompatible with the online merging mode. This limitation is lifted in https://reviews.llvm.org/D69586. Continuous mode is also (for the moment) incompatible with value profiling, as I'm not sure whether there is interest in this and the implementation may be tricky. As I have not been able to test extensively on non-Darwin platforms, only Darwin support is included for the moment. However, continuous mode may "just work" without modification on Linux and some UNIX-likes. AIUI the default value for the GNU linker's `--section-alignment` flag is set to the page size on many systems. This appears to be true for LLD as well, as its `no_nmagic` option is on by default. Continuous mode will not "just work" on Fuchsia or Windows, as it's not possible to mmap() a section on these platforms. There is a proposal to add a layer of indirection to the profile instrumentation to support these platforms. rdar://54210980 Differential Revision: https://reviews.llvm.org/D68351
* 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
* [profile] Fix value profile runtime merging issuesRong Xu2018-04-021-0/+2
| | | | | | | | | | | | | | | | 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 llvm-svn: 328987
* [profile] Port the runtime to Solaris (retry)Vedant Kumar2017-12-141-3/+11
| | | | | | | | | | | | | 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-11/+3
| | | | | | | | | | | 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-3/+11
| | | | | | | | | | | 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
* [profile] use GetComputerNameExW instead of gethostname on WindowsBob Haarman2016-11-291-3/+3
| | | | | | | | | | | | 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] instroduce portability macro for dir separator(sXinliang David Li2016-07-151-0/+14
| | | | llvm-svn: 275597
* 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] cleanup file setting codeXinliang David Li2016-06-101-0/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D21219 llvm-svn: 272428
* [profile] in-process merging support part-3Xinliang David Li2016-06-081-0/+4
| | | | | | Differential Revision: http://reviews.llvm.org/D21056 llvm-svn: 272227
* [profile] Avoid unused variable warning.Sean Silva2016-05-271-1/+1
| | | | llvm-svn: 270969
* Add portable macro in common headerXinliang David Li2016-05-261-0/+10
| | | | llvm-svn: 270928
* [profile] PROF_ERR, PROF_WARNXinliang David Li2016-05-201-2/+4
| | | | | | | | 1) Move common prefix to the macro def 2) Introduced PROF_WARN 3) Make error message unconditionally printed out. llvm-svn: 270185
* [profile] Add portability macro for atomic fetch_and_addXinliang David Li2016-05-161-0/+10
| | | | | | | This is another enabler patch to support value profiling without dynamic memory allocation. llvm-svn: 269719
* [PS4] Change the names of some "environmental" things to what ourPaul Robinson2016-05-161-1/+1
| | | | | | | | licensees actually see in the toolchain we deliver to them. This will reduce the set of local patches we have to maintain. The triple is not changing. (The term ORBIS is an internal code name for PS4.) llvm-svn: 269672
* Use __builtin_alloca with __GNUC__Xinliang David Li2016-05-151-3/+2
| | | | llvm-svn: 269592
* [profile] Eliminate dynamic memory allocation for vp writingXinliang David Li2016-05-141-0/+3
| | | | | | | | | | This is part-3 of the effort to eliminate dependency on libc allocator in instr profiler runtime. With this change, the profile dumper is completely free of malloc/calloc. Value profile instr API implementation is the only remaining piece with calloc dependency. llvm-svn: 269576
* [Fix r262785] Fix missing declaration when COMPILER_RT_BOOL_CMPXCHG was used ↵Filipe Cabecinhas2016-03-071-0/+1
| | | | | | | | but InstrProfilingUtil.h wasn't included. Also fixed declaration which still had the pre-r262788 name. llvm-svn: 262827
* [PGO] internal API name cleanups (for better consistency)Xinliang David Li2016-03-061-2/+2
| | | | llvm-svn: 262788
* Add some minimal portability code paths for PS4.Sean Silva2016-03-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Hi David, SCE folks, What is implemented in this patch is enough for the upstream libprofile to work for PGO with the PS4 game codebase I tested ("game7" for you SCE folks; this is with a standalone build of compiler-rt). The first change, which is simple, is to stub out gethostname. PS4 doesn't have a simple analog for this that doesn't bring in extra OS libraries, so for now we do not support `%h` expansion. This is consistent with internal B#136272. The second change implies future work, but is a simple change at present. PS4 does not have `getenv`, so for now we will introduce a shim. This obviously makes it impossible for many of the tests to be run since they require setting `LLVM_PROFILE_FILE=`. I see two paths forward: 1. In the tests we are already wrapping execution with `%run` and so by setting a PS4-specific expansion for `%run` we can pass the information in another way We can adapt the getenv shim as appropriate. We will need to experiment with this internally. Maggie, Phillip, Filipe? Any ideas? Maybe ping me internally since we may need to get into some PS4 vagaries. I'm thinking a fake getenv library that uses some side channel for communication. 2. Another possibility which is more verbose is to use a separate clang invocation with `-profile-generate=<filename>` to set the filename in each test. This might require redundant clang invocations though which may be undesirable for upstream. David, thoughts? Also, this is a fairly libprofile-specific workaround, so it e.g. doesn't help Filipe's ASan work. Overall, this approach sounds like a bit of a hack to me. Small detail: InstrProfilingPort.h seems like the natural place for the getenv shim, but GCDAProfiling.c needs it as well. InstrProfilingUtil.h is currently the only header common between InstrProfilingFile.c and GCDAProfiling.c. I can move the shim to InstrProfilingPort.h and add an include to GCDAProfiling.c as per your preference David. Reviewers: davidxl, MaggieYi, phillip.power, filcab Subscribers: simon.f.whittaker, slingn, probinson, llvm-commits Differential Revision: http://reviews.llvm.org/D17676 llvm-svn: 262527
* Fix build with VS2015Ismail Donmez2016-01-301-0/+2
| | | | llvm-svn: 259301
* [profile] Support hostname expansion in LLVM_PROFILE_FILEVedant Kumar2016-01-291-0/+8
| | | | | | | | | | | This patch adds support for expanding "%h" out to the machine hostname in the LLVM_PROFILE_FILE environment variable. Patch by Daniel Waters! Differential Revision: http://reviews.llvm.org/D16371 llvm-svn: 259272
* Minor cleanup /NFCXinliang David Li2016-01-281-0/+1
| | | | llvm-svn: 259068
* [profile] Add comments to portability macros for readability (NFC)Vedant Kumar2016-01-081-3/+3
| | | | llvm-svn: 257126
* [PGO]: Eliminate custom typedefs in the FreeBSD case Xinliang David Li2015-12-301-18/+4
| | | | | | | | | | Patch by: Sean Bruno Use o/s provided sys/types.h to bring in Profiling types. Differential Revision: http://reviews.llvm.org/D15088 llvm-svn: 256647
* [PGO] testing _WIN64 instead of _WIN32Xinliang David Li2015-12-201-5/+5
| | | | llvm-svn: 256129
* [PGO] Implement BOOL_CMPXCHG for WindowsXinliang David Li2015-12-201-0/+13
| | | | llvm-svn: 256128
* Fix typo in MSC pathXinliang David Li2015-12-171-1/+1
| | | | llvm-svn: 255938
* [PGO] cleanup: unify prefix for portability macrosXinliang David Li2015-12-161-13/+14
| | | | llvm-svn: 255748
* [PGO] Improve prof library portabilityXinliang David Li2015-12-151-2/+5
| | | | | | | | | Patch by: Johan Engelen Introduce LLVM_LIBRARY_WEAK macro. Define LLVM_LIBRARY_WEAK and LLVM_LIBRARY_VISIBIITY for MSVC llvm-svn: 255688
* [PGO] Move impl specific decl to InstrProfilingInternal.h (NFC)Xinliang David Li2015-12-101-3/+0
| | | | llvm-svn: 255290
* [PGO] Move target-dependent macro to InstrProfilingPort.h (NFC)Xinliang David Li2015-12-101-0/+8
| | | | llvm-svn: 255285
* [PGO] Header file cleanup (NFC)Xinliang David Li2015-12-101-0/+54
InstrProfiling.h file declares profile runtime public APIs. It has become a dumping place for many different things, which needs cleanups. In this change, core type declarations and portability macros are moved to a new file InstrProfilingPort.h. llvm-svn: 255270
OpenPOWER on IntegriCloud