summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData
Commit message (Collapse)AuthorAgeFilesLines
...
* SamplePGO - Move FunctionSamples::print() to a better location. NFC.Diego Novillo2015-11-122-31/+32
| | | | | | | The class is declared in SampleProf.h, so a better home for this is SampleProf.cpp. llvm-svn: 252915
* Fix problems in coding styleXinliang David Li2015-11-121-13/+23
| | | | llvm-svn: 252829
* unique_ptrify the AllocValueProfData helper function introduced in r252783David Blaikie2015-11-111-6/+5
| | | | llvm-svn: 252799
* Refactoring and fix another instance of asan errorXinliang David Li2015-11-111-5/+10
| | | | llvm-svn: 252783
* Silencing a signed vs unsigned type mismatch warning.Aaron Ballman2015-11-111-1/+1
| | | | llvm-svn: 252732
* Fix asan warning (NFC)Xinliang David Li2015-11-101-2/+3
| | | | llvm-svn: 252617
* [PGO] Make indexed value profile data more compactXinliang David Li2015-11-103-84/+248
| | | | | | | | | | | | | | | | - Make indexed value profile data more compact by peeling out the per-site value count field into its own smaller sized array. - Introduced formal data structure definitions to specify value profile data layout in indexed format. Previously the layout of the data is only assumed in the client code (scattered in three different places : size computation, EmitData, and ReadData - The new data structure serves as a central place for layout documentation. - Add interfaces to force BE output for value profile data (testing purpose) - Add byte swap unit tests Differential Revision: http://reviews.llvm.org/D14401 llvm-svn: 252563
* [PGO] Instr func name var creation code refactoringXinliang David Li2015-11-091-0/+66
| | | | | | | Move the code from cfe to LLMV and become shared interfaces. There is no functional change. llvm-svn: 252433
* Code style fix (caused by wrongly default clang-format style) (NFC)Xinliang David Li2015-11-062-10/+17
| | | | llvm-svn: 252276
* [PGO] Use template file to define runtime structuresXinliang David Li2015-11-051-6/+9
| | | | | | | | | | | With this change, instrumentation code and reader/write code related to profile data structs are kept strictly in-sync. THis will be extended to cfe and compile-rt references as well. Differential Revision: http://reviews.llvm.org/D13843 llvm-svn: 252113
* [PGO] Value profiling (index format) code cleanup and testingXinliang David Li2015-11-022-75/+58
| | | | | | | | | | | | | | | | | 1. Added a set of public interfaces in InstrProfRecord class to access (read/write) value profile data. 2. Changed IndexedProfile reader and writer code to use the newly defined interfaces and hide implementation details. 3. Added a couple of unittests for value profiling: - Test new interfaces to get and set value profile data - Test value profile data merging with various scenarios. No functional change is expected. The new interfaces will also make it possible to change on-disk format of value prof data to be more compact (to be submitted). llvm-svn: 251771
* [PGO] RawProf Reader code cleanupXinliang David Li2015-10-281-16/+42
| | | | | | | | | Add a couple of helper methods to make the primary raw profile reader interface's implementation more readable. It also hides more format details. This patch has no functional change. llvm-svn: 251546
* [PGO] Indexed Prof Reader refactoring (NFC)Xinliang David Li2015-10-281-36/+58
| | | | | | | | | | Change InstrProfReaderIndex from typedef into a wrapper class with helper methods. This makes the index profile reader code more readable. It also hides the implementation detail of the index format and make it more flexible to allow support different (or more than one) format in the future. llvm-svn: 251491
* Add helper functions and remove hard coded references to instProf related ↵Xinliang David Li2015-10-221-2/+3
| | | | | | | | | | | | name/name-prefixes This is a clean up patch that defines instr prof section and variable name prefixes in a common header with access helper functions. clang FE change will be done as a follow up once this patch is in. Differential Revision: http://reviews.llvm.org/D13919 llvm-svn: 251058
* Tolerate negative offset when matching sample profile.Dehao Chen2015-10-211-1/+11
| | | | | | | | In some cases (as illustrated in the unittest), lineno can be less than the heade_lineno because the function body are included from some other files. In this case, offset will be negative. This patch makes clang still able to match the profile to IR in this situation. http://reviews.llvm.org/D13914 llvm-svn: 250873
* Minor Instr PGO code restructuringXinliang David Li2015-10-183-115/+42
| | | | | | | | | | | | | | | | 1. Key constant values (version, magic) and data structures related to raw and indexed profile format are moved into one centralized file: InstrProf.h. 2. Utility function such as MD5Hash computation is also moved to the common header to allow sharing with other components in the future. 3. A header data structure is introduced for Indexed format so that the reader and writer can always be in sync. 4. Added some comments to document different places where multiple definition of the data structure must be kept in sync (reader/writer, runtime, lowering etc). No functional change is intended. Differential Revision: http://reviews.llvm.org/D13758 llvm-svn: 250638
* Sample profiles - Re-arrange binary format to emit head samples only on top ↵Diego Novillo2015-10-162-18/+24
| | | | | | | | | | | | | | functions. The number of samples collected at the head of a function only make sense for top-level functions (i.e., those actually called as opposed to being inlined inside another). Head samples essentially count the time spent inside the function's prologue. This clearly doesn't make sense for inlined functions, so we were always emitting 0 in those. llvm-svn: 250539
* Sample Profiles - Adjust integer types. Mostly NFC.Diego Novillo2015-10-152-25/+25
| | | | | | | | | | | | | | This adjusts all integers in the reader/writer to reflect the types stored on profile files. They should all be unsigned 32-bit or 64-bit values. Changed all associated internal types to be uint32_t or uint64_t. The only place that needed some adjustments is in the sample profile transformation. Altough the weight read from the profile are 64-bit values, the internal API for branch weights only accepts 32-bit values. The pass now saturates weights that overflow uint32_t. llvm-svn: 250427
* Sample profiles - Add documentation for binary profile encoding. NFC.Diego Novillo2015-10-141-103/+6
| | | | | | | | This adds documentation for the binary profile encoding and moves the documentation for the text encoding into the header file SampleProfReader.h. llvm-svn: 250309
* Sample profile reader - remove dead code. NFC.Diego Novillo2015-10-131-10/+0
| | | | | | | This removes old remnants from the gcov reader. I missed these when I re-wrote it recently. llvm-svn: 250242
* Sample profiles - Add a name table to the binary encoding.Diego Novillo2015-10-133-21/+94
| | | | | | | | Binary encoded profiles used to encode all function names inline at every reference. This is clearly suboptimal in terms of space. This patch fixes this by adding a name table to the header of the file. llvm-svn: 250241
* Fix a couple of comments; NFCXinliang David Li2015-10-131-6/+6
| | | | llvm-svn: 250177
* [ProfileData] Test commit for slingnNathan Slingerland2015-10-111-0/+1
| | | | | | This is a test of the LLVM commit system. In the event of a real commit there would be some useful code changes. llvm-svn: 249972
* Add inline stack streaming to binary sample profiles.Diego Novillo2015-10-092-43/+84
| | | | | | | | | | | | With this patch we can now read and write inline stacks in sample profiles to the binary encoded profiles. In a subsequent patch, I will add a string table to the binary encoding. Right now function names are emitted as strings every time we find them. This is too bloated and will produce large files in applications with lots of inlining. llvm-svn: 249861
* Re-apply r249644: Handle inline stacks in gcov-encoded sample profiles.Diego Novillo2015-10-082-47/+88
| | | | | | | | | | | | | This fixes memory allocation problems by making the merge operation keep the profile readers around until the merged profile has been emitted. This is needed to prevent the inlined function names to disappear from the function profiles. Since all the names are kept as references, once the reader disappears, the names are also deallocated. Additionally, XFAIL on big-endian architectures. The test case uses a gcov file generated on a little-endian system. llvm-svn: 249724
* Revert "Handle inline stacks in gcov-encoded sample profiles."Diego Novillo2015-10-082-88/+47
| | | | | | | | This reverts commit r249644. The buildbots are failing the new test I added. Investigating. llvm-svn: 249648
* Handle inline stacks in gcov-encoded sample profiles.Diego Novillo2015-10-082-47/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for reading sample profiles with inline stacks. Inline stacks in a profile are generated when the sampled binary has samples in inlined functions. For instance, if main() calls foo() and foo() calls bar(), and bar() is inlined into foo() and foo() inlined into main(), the profile may look something like: main total:364084 head:0 [ ... ] 2.3: _Z3fool total:243786 1: 60149 1.2: 38568 1.4: 46511 1.7: _Z3bari total:98558 1.1: 52672 1.2: 45886 At line 2, discriminator 3, main() calls foo(). In turn, foo() calls bar() at line 1, discriminator 7. In the textual format, this stacking of inline calls is represented with indentation. With this change, LLVM can now read sample profile files generated by the create_gcov tool from https://github.com/google/autofdo. llvm-svn: 249644
* Remove AutoFDO profile handling for GCC's LIPO. NFC.Diego Novillo2015-10-051-22/+0
| | | | | | | | Given the work we are doing on ThinLTO, we will never need to support module groups and working sets in GCC's implementation of LIPO. These are currently dead code, and will continue to be so. llvm-svn: 249351
* InstrProf: Don't call std::unique twice hereJustin Bogner2015-09-301-1/+0
| | | | llvm-svn: 248872
* http://reviews.llvm.org/D13145Dehao Chen2015-09-301-65/+168
| | | | | | Support hierarachical sample profile format. llvm-svn: 248865
* InstrProf: Support for value profiling in the indexed profile formatJustin Bogner2015-09-294-54/+208
| | | | | | | | | Add support to the indexed instrprof reader and writer for the format that will be used for value profiling. Patch by Betul Buyukkurt, with minor modifications. llvm-svn: 248833
* GCC AutoFDO profile reader - Initial support.Diego Novillo2015-09-172-9/+271
| | | | | | | | | | | | | | | | | | This adds enough machinery to support reading simple GCC AutoFDO profiles. It now supports reading flat profiles (no function calls). Subsequent patches will add support for: - Inlined calls (in particular, the inline call stack is not traversed to accumulate samples). - Working sets and modules. These are used mostly for GCC's LIPO optimizations, so they're not needed in LLVM atm. I'm not sure that we will ever need them. For now, I've if0'd around the calls. The patch also adds support in GCOV.h for gcov version V704 (generated by GCC's profile conversion tool). llvm-svn: 247874
* Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko2015-06-237-8/+8
| | | | | | Apparently, the style needs to be agreed upon first. llvm-svn: 240390
* Re-apply "InstrProf: When reading, copy the data instead of taking a ↵Justin Bogner2015-06-221-47/+65
| | | | | | | | | | | | | | reference. NFC" This version fixes a missing include that MSVC noticed and clarifies the ownership of the counter buffer that's passed to InstrProfRecord. This restores r240206, which was reverted in r240208. Patch by Betul Buyukkurt. llvm-svn: 240360
* [Object] Search for architecures by name in ↵Frederic Riss2015-06-222-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | MachOUniversalBinary::getObjectForArch() The reason we need to search by name rather than by Triple::ArchType is to handle subarchitecture correclty. There is no different ArchType for the x86_64h architecture (it identifies itself as x86_64), or for the various ARM subarches. The only way to get to the subarch slice in an universal binary is to search by name. This issue led to hard to debug and transient symbolication failures in Asan tests (it mostly works, because the files are very similar). This also affects the Profiling infrastucture as it is the other user of that API. Reviewers: samsonov, bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10604 llvm-svn: 240339
* Revert "InstrProf: When reading, copy the data instead of taking a ↵Justin Bogner2015-06-201-65/+47
| | | | | | | | | | | | reference. NFC" Seems like MSVC doesn't like this: InstrProf.h(49) : error C2614: 'llvm::InstrProfRecord' : illegal member initialization: 'Hash' is not a base or member This reverts r240206. llvm-svn: 240208
* InstrProf: When reading, copy the data instead of taking a reference. NFCJustin Bogner2015-06-201-47/+65
| | | | | | | | | | | This consolidates the logic to read instrprof records into the on disk hash table's lookup trait and makes us copy the counter data instead of taking references to it as we read. This will simplify further changes to the format. Patch by Betul Buyukkurt. llvm-svn: 240206
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-197-8/+8
| | | | | | | | | | | | | The patch is generated using this command: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ llvm/lib/ Thanks to Eugene Kosov for the original patch! llvm-svn: 240137
* modules: Add explicit dependency on intrinsics_genDuncan P. N. Exon Smith2015-06-161-0/+3
| | | | | | | | | `LLVM_ENABLE_MODULES` builds sometimes fail because `Intrinsics.td` needs to regenerate `Instrinsics.h` before anyone can include anything from the LLVM_IR module. Represent the dependency explicitly to prevent that. llvm-svn: 239796
* Don't use std::errc.Rafael Espindola2015-06-131-2/+3
| | | | | | | | | | | | | | | | | | | | | As noted on Errc.h: // * std::errc is just marked with is_error_condition_enum. This means that // common patters like AnErrorCode == errc::no_such_file_or_directory take // 4 virtual calls instead of two comparisons. And on some libstdc++ those virtual functions conclude that ------------------------ int main() { std::error_code foo = std::make_error_code(std::errc::no_such_file_or_directory); return foo == std::errc::no_such_file_or_directory; } ------------------------- should exit with 0. llvm-svn: 239683
* InstrProf: Fix reading of consecutive 32 bit coverage mapsJustin Bogner2015-06-051-0/+5
| | | | | | | | | | | | | | | | | When we generate coverage data, we explicitly set each coverage map's alignment to 8 (See InstrProfiling::lowerCoverageData), but when we read the coverage data, we assume consecutive maps are exactly adjacent. When we're dealing with 32 bit, maps can end on a 4 byte boundary, causing us to think the padding is part of the next record. Fix this by adjusting the buffer to an appropriately aligned address between records. This is pretty awkward to test, as it requires a binary with multiple coverage maps to hit, so we'd need to check in multiple source files and a binary blob as inputs. llvm-svn: 239129
* InstrProf: Treat functions with a coverage map but no profile as unreachedJustin Bogner2015-05-131-2/+3
| | | | | | | | | | If we have a coverage mapping but no profile data for a function, calling it mismatched is misleading. This can just as easily be unreachable code that was stripped from the binary. Instead, treat these the same as functions where we have an explicit "zero" coverage map by setting the count to zero for each mapped region. llvm-svn: 237298
* InstrProf: Simplify looking up sections for coverage dataJustin Bogner2015-05-071-18/+19
| | | | llvm-svn: 236685
* InstrProf: Give coverage its own errors instead of piggy backing on instrprofJustin Bogner2015-05-063-33/+64
| | | | | | | | | | | | Since the coverage mapping reader and the instrprof reader were emitting a shared set of error codes, the error messages you'd get back from llvm-cov were ambiguous about what was actually wrong. Add another error category to fix this. I've also improved the wording on a couple of the instrprof errors, for consistency. llvm-svn: 236665
* InstrProf: Remove a function that just returns its argument (NFC)Justin Bogner2015-05-061-20/+20
| | | | llvm-svn: 236664
* InstrProf: Strip filename prefixes from the names we display for coverageJustin Bogner2015-05-051-1/+15
| | | | | | | For consumers of coverage data, any filename prefixes we store in the profile data are just noise. Strip this prefix if it exists. llvm-svn: 236558
* Re-sort includes with sort-includes.py and insert raw_ostream.h where it's used.Benjamin Kramer2015-03-232-0/+2
| | | | llvm-svn: 232998
* InstrProf: Fix CoverageMappingReader on big endianJustin Bogner2015-03-161-16/+28
| | | | | | | | This makes the reader check the endianness of the object file its given and behave appropriately. For the test I dug up a really old linker and created a ppc-apple-darwin file for llvm-cov to read. llvm-svn: 232422
* InstrProf: Do a better job of reading coverage mapping data.Justin Bogner2015-03-161-59/+41
| | | | | | | | | | | | | | | | | | | | | | This code was casting regions of a memory buffer to a couple of different structs. This is wrong in a few ways: 1. It breaks aliasing rules. 2. If the buffer isn't aligned, it hits undefined behaviour. 3. It completely ignores endianness differences. 4. The structs being defined for this aren't specifying their padding properly, so this doesn't even represent the data properly on some platforms. This commit is mostly NFC, except that it fixes reading coverage for 32 bit binaries as a side effect of getting rid of the mispadded structs. I've included a test for that. I've also baked in that we only handle little endian more explicitly, since that was true in practice already. I'll fix this to handle endianness properly in a followup commit. llvm-svn: 232346
* InstrProf: Teach llvm-cov to handle universal binaries when given -archJustin Bogner2015-03-112-8/+31
| | | | llvm-svn: 231902
OpenPOWER on IntegriCloud