summaryrefslogtreecommitdiff
path: root/lib/profile/InstrProfilingFile.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix braced initializer list (NFC)Teresa Johnson2016-05-251-1/+1
| | | | | | | | | | | | | | After r270617 I am getting an error when building: projects/compiler-rt/lib/profile/InstrProfilingFile.c:33:36: error: missing field 'PidChars' initializer [-Werror,-Wmissing-field-initializers] lprofFilename lprofCurFilename = {0}; ^ Fix the aggregate initializer. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270697 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] clean up profile file handling codeXinliang David Li2016-05-241-87/+138
| | | | | | | | Differentianl Revision: http://reviews.llvm.org/D20572 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270617 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo in commentXinliang David Li2016-05-241-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270524 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] clean up file initialization codeXinliang David Li2016-05-241-15/+23
| | | | | | | | | Also added more documentation. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270519 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix bot failureXinliang David Li2016-05-201-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270186 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] PROF_ERR, PROF_WARNXinliang David Li2016-05-201-3/+3
| | | | | | | | | | 1) Move common prefix to the macro def 2) Introduced PROF_WARN 3) Make error message unconditionally printed out. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270185 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Remove anther malloc useXinliang David Li2016-05-201-2/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270181 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Allow max vals per site to be controllable at runtimeXinliang David Li2016-05-181-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269993 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Eliminate dynamic memory allocation for vp writingXinliang David Li2016-05-141-1/+1
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269576 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Eliminate dynamic memory allocation for buffered writerXinliang David Li2016-05-131-7/+13
| | | | | | | | | | With this change, dynamic memory allocation is only used for testing purpose. This change is one of the many steps to make instrument profiler dynamic allocation free. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269453 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r268840: [profile] Simplify value profile writingXinliang David Li2016-05-101-4/+1
| | | | | | | | | | Revert r268864 that reverted 268840 after underlying problem is fixed for arm bot. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268992 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[profile] Simplify value profile writing"Renato Golin2016-05-071-1/+4
| | | | | | | | This reverts commit r268840, as it breaks Thumb2 self-hosting. There is something unstable in the profiling for Thumb2 that needs to be sorted out before we continue implementing these changes to the profiler. See PR27667. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268864 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Simplify value profile writingXinliang David Li2016-05-071-4/+1
| | | | | | | | | | | With this patch, value data are longer pre-collected before writing. The code is simplified and requires less heap space for dumping. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268840 91177308-0d34-0410-b5e6-96231b3b80d8
* [libprofile] Handle '\\' in __llvm_profile_recursive_mkdirSean Silva2016-03-281-1/+1
| | | | | | | | | | | | | | 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). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264665 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] cleanup: move one support method into InstrProfilingUtil.h /NFCXinliang David Li2016-03-061-13/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@262791 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] internal API name cleanups (for better consistency)Xinliang David Li2016-03-061-9/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@262788 91177308-0d34-0410-b5e6-96231b3b80d8
* [profile] Support hostname expansion in LLVM_PROFILE_FILEVedant Kumar2016-01-291-8/+36
| | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259272 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor cleanup /NFCXinliang David Li2016-01-281-4/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259068 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo in commentXinliang David Li2016-01-081-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257232 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Add runtime hook so that IR instrumentation can override versionXinliang David Li2016-01-081-0/+9
| | | | | | | | | | IR level instrumentation needs to override version with variant bits. No change for FE instrumentation is needed. Test case is added to detect version mismatch. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257230 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Enable building compiler-rt profile support library on WindowsNathan Slingerland2016-01-051-0/+4
| | | | | | | | | | | | 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
* [PGO]: Refactor VP data writerXinliang David Li2015-12-291-0/+7
| | | | | | | | | | | Extract the buffered filer writer code used by value profile writer and turn it into common/sharable buffered fileIO interfaces. Added a test case for the buffered file writer and rewrite the VP dumping using the new APIs. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256604 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO]: Do not update Data->Value field during profile write.Xinliang David Li2015-12-291-6/+10
| | | | | | | | | | | The profile reader no longer depends on this field to be updated and point to owning func's vp data. The VP data also no longer needs to be allocated in a contiguous memory space. Differential Revision: http://reviews.llvm.org/D15258 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256543 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] cleanup: unify prefix for portability macrosXinliang David Li2015-12-161-7/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255748 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Improve prof library portabilityXinliang David Li2015-12-151-2/+2
| | | | | | | | | | | Patch by: Johan Engelen Introduce LLVM_LIBRARY_WEAK macro. Define LLVM_LIBRARY_WEAK and LLVM_LIBRARY_VISIBIITY for MSVC git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255688 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Open file with explict binary modeXinliang David Li2015-12-151-1/+1
| | | | | | | | | | | | Patch by: Johan Engelen On windows, opening in text mode will result in line ending chars to be appended leading to profile corruption. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255684 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Stop leaking libc function to buffer API implXinliang David Li2015-12-071-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254943 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Introduce error report macro in profile-rtXinliang David Li2015-12-031-3/+5
| | | | | | | | Also added a test case for runtime error reporting. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254625 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Compiler-rt cleanup -- introduces macros for various macrosXinliang David Li2015-11-231-8/+6
| | | | | | | | | | | | This makes code more readable and be made more portable in the future. There is no functional change. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253845 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Implement a more robust/readable Writer callback interfaceXinliang David Li2015-11-211-5/+12
| | | | | | | | | | | | | | (patch suggested by silvas) With this patch, the IO information is wrapped in struct ProfDataIOVec, and interface of writerCallback takes a vector of IOVec and a pointer to writer context pointer. Differential Revision: http://reviews.llvm.org/D14859 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253764 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Minor cleanups (from review feedback)Xinliang David Li2015-11-191-2/+2
| | | | | | | | | 1. fix naming problem of file/buffer writer 2. change BufferOrFile to WriterCtx 3. move writer and writerctx together git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253545 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix format of previous patch (NFC)Xinliang David Li2015-11-181-4/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253503 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Refactor File and Buffer API profile writing codeXinliang David Li2015-11-181-49/+11
| | | | | | | | | | | With this change, Buffer API and File API implementations are unified. Differential Revision: http://reviews.llvm.org/D14692 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253500 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Runtime support for value profiling.Betul Buyukkurt2015-11-181-3/+11
| | | | | | | | | | This change adds extends the data structures and adds in the routines for handling runtime calls for value profiling. The profile data format is modified and the version number is incremented. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253483 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Ensure profile section symbols are created (linux)Xinliang David Li2015-11-131-0/+4
| | | | | | | | | | | | | | | - This is to handle a corner case where profile lib is linked in but non of the modules are instrumented (On linux, since we avoided the overhead to emit runtime hook use functions so this is the side effect of that size optimization). - Added a profile runtime test case to cover all scenarios of shared library builds. Differential Revision: http://reviews.llvm.org/D14468 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253098 91177308-0d34-0410-b5e6-96231b3b80d8
* Use struct type instead of raw array for raw profile header (NFC)Xinliang David Li2015-10-161-9/+9
| | | | | | | | | | | | This patch introduces a well defined header struct to represent raw profile header instead of using raw array. Previously the raw array is used in two different files and is very error prone when header structure is re-organized. This is a small cleanup with NFC. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@250561 91177308-0d34-0410-b5e6-96231b3b80d8
* [probile] Fix memory leak introduced in r241824.Alexey Samsonov2015-07-151-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242350 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for generating profiles in a given directory.Diego Novillo2015-07-091-0/+8
| | | | | | | | | | 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
* This change is the first of 3 patches to add support for specifyingEric Christopher2015-04-281-17/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the profile output from the command line via -fprofile-instr-generate=<path>, where the specified output path/file will be overridden by the LLVM_PROFILE_FILE environment variable. Several changes are made to the runtime to support this: Add a new interface __llvm_profile_override_default_filename that will set the profile output filename, but allows LLVM_PROFILE_FILE to override. This is the interface used by the new option. Refactor the pid-expansion done for LLVM_PROFILE_FILE into a separate routine that can be shared by the various filename setting routines (so that the filename from the option can also use the "%p" syntax). Move the truncation into setFilename, and only truncate if there is a new filename specified (to maintain support for appending to the same profile file in the case of multiple shared objects built with profiling). Move the handling for a NULL filename passed to __llvm_profile_set_filename and __llvm_profile_override_default_filename into the new setFilenamePossiblyWithPid routine. This now correctly resets the output file to default.profraw instead of NULL. The handling for a null LLVM_PROFILE_FILE (which should not reset) is done by caller setFilenameFromEnvironment. Patch by Teresa Johnson. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@236055 91177308-0d34-0410-b5e6-96231b3b80d8
* At least on NetBSD, sys/errno.h and errno.h are different, so use theJoerg Sonnenberger2015-03-091-1/+1
| | | | | | | correct header to get errno. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@231647 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Fix warnings for mixed declarations and code. NFC.Vasileios Kalintiris2015-02-251-10/+15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230494 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Optionally print an error when emitting profile data failsJustin Bogner2015-01-161-1/+6
| | | | | | | | Debugging a missing profile is a bit painful right now. We can make people's lives a bit easier by adding a knob to enable printing a helpful error message for such failures. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226312 91177308-0d34-0410-b5e6-96231b3b80d8
* profile: Avoid name collisions between instrumentation and runtimeJustin Bogner2014-09-041-6/+6
| | | | | | | | | | | | The naming scheme we're using for counters in profile data shares a prefix with some fixed names we use for the runtime, notably __llvm_profile_data_begin and _end. Embarrassingly, this means a function called begin() can't be instrumented. This modifies the runtime names so as not to collide with the instrumentation. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217166 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix building InstrProfilingFile.c on FreeBSDViktor Kutuzov2014-06-151-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210989 91177308-0d34-0410-b5e6-96231b3b80d8
* Go via uintptr_t when casting away constness, otherwise GCC will warnJoerg Sonnenberger2014-05-201-1/+4
| | | | | | | when using -Wcast-qual. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209214 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Support profiling dlopen'd shared librariesDuncan P. N. Exon Smith2014-05-171-75/+91
| | | | | | | | | | | | | | | | | | Shared objects are hard. After this commit, we do the right thing when profiling two separate shared objects that have been dlopen'd with `RTLD_LOCAL`, when the main executable is *not* being profiled. This mainly simplifies the writer logic. - At initialization, determine the output filename and truncate the file. Depending on whether shared objects can see each other, this may happen multiple times. - At exit, each executable writes its own profile in append mode. <rdar://problem/16918688> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209053 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Fix shared object profilingDuncan P. N. Exon Smith2014-05-161-8/+42
| | | | | | | | | | | | | | | | | | Change the API of the instrumented profiling library to work with shared objects. - Most things are now declared hidden, so that each executable gets its own copy. - Initialization hooks up a linked list of writers. - The raw format with shared objects that are profiled consists of a concatenated series of profiles. llvm-profdata knows how to deal with that since r208938. <rdar://problem/16918688> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208940 91177308-0d34-0410-b5e6-96231b3b80d8
* profile: Fix the build with gcc 4.9Reid Kleckner2014-05-011-9/+8
| | | | | | | | | | GCC -pedantic warns that the initialization of Header is not constant: InstrProfilingFile.c:31:5: error: initializer element is not computable at load time [-Werror] LLVM defaults to enabling -pedantic. If this warning is unhelpful, we can consider revisiting that decision. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@207784 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Change the extension of the default profileDuncan P. N. Exon Smith2014-03-241-1/+1
| | | | | | | | | Change the name of the default profile dumped by compiler-rt to default.profraw. This distinguishes it more clearly from the (incompatible) format output by llvm-profdata that is read by clang -fprofile-instr-use. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204676 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid GCC's "cast from pointer to integer of different size" warning.David Blaikie2014-03-211-2/+2
| | | | | | | | This is a bit of a stab in the dark as I'm not sure I've got these source files compiling correctly locally. (and the warning only reproduces on a 32bit build anyway) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204521 91177308-0d34-0410-b5e6-96231b3b80d8