summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData/InstrProfReader.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [PGO] Move value profile data definitions out of IndexedInstrProfXinliang David Li2015-11-171-3/+2
| | | | | | | Move the data structure defintions out of the namespace. The defs will be shared by raw format. [NFC] llvm-svn: 253394
* [llvm-profdata] Add check for text profile formats and improve error ↵Nathan Slingerland2015-11-131-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | reporting (2nd try) Summary: This change addresses two possible instances of user error / confusion when merging sampled profile data. Previously any input that didn't match the raw or processed instrumented format would automatically be interpreted as instrumented profile text format data. No error would be reported during the merge. Example: If foo-sampled.profdata and bar-sampled.profdata are binary sampled profiles: Old behavior: $ llvm-profdata merge foo-sampled.profdata bar-sampled.profdata -output foobar-sampled.profdata $ llvm-profdata show -sample foobar-sampled.profdata error: foobar-sampled.profdata:1: Expected 'mangled_name:NUM:NUM', found lprofi This change adds basic checks for valid input data when assuming text input. It also makes error messages related to file format validity more specific about the assumbed profile data type. New behavior: $ llvm-profdata merge foo-sampled.profdata bar-sampled.profdata -o foobar-sampled.profdata error: foo.profdata: Unrecognized instrumentation profile encoding format Perhaps you forgot to use the -sample option? Reviewers: bogner, davidxl, dnovillo Subscribers: davidxl, llvm-commits Differential Revision: http://reviews.llvm.org/D14558 llvm-svn: 253009
* reverting r252916 to investigate test failureNathan Slingerland2015-11-121-12/+1
| | | | llvm-svn: 252921
* [llvm-profdata] Add check for text profile formats and improve error reportingNathan Slingerland2015-11-121-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change addresses two possible instances of user error / confusion when merging sampled profile data. Previously any input that didn't match the raw or processed instrumented format would automatically be interpreted as instrumented profile text format data. No error would be reported during the merge. Example: If foo-sampled.profdata and bar-sampled.profdata are binary sampled profiles: Old behavior: $ llvm-profdata merge foo-sampled.profdata bar-sampled.profdata -output foobar-sampled.profdata $ llvm-profdata show -sample foobar-sampled.profdata error: foobar-sampled.profdata:1: Expected 'mangled_name:NUM:NUM', found lprofi This change adds basic checks for valid input data when assuming text input. It also makes error messages related to file format validity more specific about the assumbed profile data type. New behavior: $ llvm-profdata merge foo-sampled.profdata bar-sampled.profdata -o foobar-sampled.profdata error: foo.profdata: Unrecognized instrumentation profile encoding format Perhaps you forgot to use the -sample option? Reviewers: bogner, davidxl, dnovillo Subscribers: davidxl, llvm-commits Differential Revision: http://reviews.llvm.org/D14558 llvm-svn: 252916
* Fix problems in coding styleXinliang David Li2015-11-121-13/+23
| | | | llvm-svn: 252829
* [PGO] Make indexed value profile data more compactXinliang David Li2015-11-101-41/+6
| | | | | | | | | | | | | | | | - 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
* Code style fix (caused by wrongly default clang-format style) (NFC)Xinliang David Li2015-11-061-5/+8
| | | | llvm-svn: 252276
* [PGO] Value profiling (index format) code cleanup and testingXinliang David Li2015-11-021-27/+28
| | | | | | | | | | | | | | | | | 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
* Minor Instr PGO code restructuringXinliang David Li2015-10-181-54/+27
| | | | | | | | | | | | | | | | 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
* 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
* InstrProf: Don't call std::unique twice hereJustin Bogner2015-09-301-1/+0
| | | | llvm-svn: 248872
* InstrProf: Support for value profiling in the indexed profile formatJustin Bogner2015-09-291-19/+91
| | | | | | | | | 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
* 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
* 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
* InstrProf: Allow hexadecimal function hashes in proftext formatJustin Bogner2015-03-091-1/+1
| | | | llvm-svn: 231685
* Add missing includes. make_unique proliferated everywhere.Benjamin Kramer2015-03-011-0/+1
| | | | llvm-svn: 230909
* Re-apply "InstrProf: Add unit tests for the profile reader and writer"Justin Bogner2015-02-181-11/+18
| | | | | | | | | | | | | | Have the InstrProfWriter return a MemoryBuffer instead of a std::string. This fixes the alignment issues the reader would hit, and it's a more appropriate type for this anyway. I've also removed an ugly helper function that's not needed since we're allowing initializer lists now, and updated some error code checks based on MSVC's issues with r229473. This reverts r229483, reapplying r229478. llvm-svn: 229602
* Revert "InstrProf: Add unit tests for the profile reader and writer"Justin Bogner2015-02-171-18/+11
| | | | | | | | | | This added API to the InstrProfWriter to write to a string so I could write unittests without using temp files. This doesn't really work, since the format has tighter alignment requirements than a char. This reverts r229478 and its follow-up, r229481. llvm-svn: 229483
* Re-apply "InstrProf: Add unit tests for the profile reader and writer"Justin Bogner2015-02-171-11/+18
| | | | | | | | Add these tests again, but use va_list instead of initializer lists. This reverts r229456, reapplying r229455. llvm-svn: 229478
* Revert "InstrProf: Add unit tests for the profile reader and writer"Justin Bogner2015-02-161-18/+11
| | | | | | | | Looks like the bots don't like my initializer lists. This reverts r229455 llvm-svn: 229456
* InstrProf: Add unit tests for the profile reader and writerJustin Bogner2015-02-161-11/+18
| | | | | | | | | | This required some minor API to be added to these types to avoid needing temp files. Also, I've used initializer lists in the tests, as MSVC 2013 claims to support them. I'll redo this without them if the bots complain. llvm-svn: 229455
* InstrProf: Use ErrorOr for IndexedInstrProfReader::create (NFC)Justin Bogner2015-02-161-3/+8
| | | | | | | The other InstrProfReader::create factories were updated to return ErrorOr in r221120, and it's odd for these APIs not to match. llvm-svn: 229433
* [cleanup] Re-sort all the #include lines in LLVM usingChandler Carruth2015-01-141-3/+1
| | | | | | | | | | | utils/sort_includes.py. I clearly haven't done this in a while, so more changed than usual. This even uncovered a missing include from the InstrProf library that I've added. No functionality changed here, just mechanical cleanup of the include order. llvm-svn: 225974
* Use ErrorOr for the ::create factory on instrumented and sample profilers.Diego Novillo2014-11-031-12/+18
| | | | | | | | | | | | | | | | | Summary: As discussed in http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141027/242445.html, the creation of reader and writer instances is better done using ErrorOr. There are no functional changes, but several callers needed to be adjusted. Reviewers: bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6076 llvm-svn: 221120
* llvm-profdata: Avoid undefined behaviour when reading raw profilesJustin Bogner2014-09-121-0/+3
| | | | | | | | | | The raw profiles that are generated in compiler-rt always add padding so that each profile is aligned, so we can simply treat files that don't have this property as malformed. Caught by Alexey's new ubsan bot. Thanks! llvm-svn: 217708
* InstrProf: Allow multiple functions with the same nameJustin Bogner2014-08-011-15/+48
| | | | | | | | | | | | | | | | | | | | | | | This updates the instrumentation based profiling format so that when we have multiple functions with the same name (but different function hashes) we keep all of them instead of rejecting the later ones. There are a number of scenarios where this can come up where it's more useful to keep multiple function profiles: * Name collisions in unrelated libraries that are profiled together. * Multiple "main" functions from multiple tools built against a common library. * Combining profiles from different build configurations (ie, asserts and no-asserts) The profile format now stores the number of counters between the hash and the counts themselves, so that multiple sets of counts can be stored. Since this is backwards incompatible, I've bumped the format version and added some trivial logic to skip this when reading the old format. llvm-svn: 214585
* llvm-profdata: Clean up and reorganize some testsJustin Bogner2014-07-291-2/+2
| | | | | | | | This moves some tests around to make it clearer what's being tested, and adds very rudimentary comment syntax to the text input format to make specifying this kind of test a little bit simpler. llvm-svn: 214235
* Update the MemoryBuffer API to use ErrorOr.Rafael Espindola2014-07-061-1/+4
| | | | llvm-svn: 212405
* Renaming SwapByteOrder() to getSwappedBytes()Artyom Skrobov2014-06-141-1/+1
| | | | | | The next commit will add swapByteOrder(), acting in-place llvm-svn: 210973
* Remove 'using std::errro_code' from lib.Rafael Espindola2014-06-131-19/+22
| | | | llvm-svn: 210871
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-121-0/+1
| | | | | | This should make sure that most new uses use the std prefix. llvm-svn: 210835
* ProfileData: Allow multiple profiles in RawInstrProfReaderJustin Bogner2014-05-161-4/+29
| | | | | | | | | | | | | | | | | | | Allow multiple raw profiles to coexist in a single .profraw file, given the following conditions: - Zero padding at the end of or between profiles will be skipped. - Each profile must start with a valid header. - Mixing endianness or pointer sizes in concatenated profiles files is not allowed. This is needed to handle cases where a program's shared libraries are profiled as well as the main executable itself, as we'll need to emit each executable's counters. Combining the tables in the runtime would be expensive for the instrumented program. rdar://16918688 llvm-svn: 208938
* Fixing a cast-qual warning. getBufferStart() and getBufferEnd() both return ↵Aaron Ballman2014-05-011-2/+3
| | | | | | | | a const char *, so casting to non-const was triggering a warning (even though the assignment and usage was always const anyway). No functional changes intended. llvm-svn: 207774
* ProfileData: Treat missing function counts as malformedJustin Bogner2014-04-251-2/+6
| | | | llvm-svn: 207172
* ProfileData: Don't forward declare ComputeHash and make it static inlineJustin Bogner2014-04-181-0/+5
| | | | llvm-svn: 206663
* ProfileData: Add support for the indexed instrprof formatJustin Bogner2014-04-181-6/+112
| | | | | | | | This adds support for an indexed instrumentation based profiling format, which is just a small header and an on disk hash table. This format will be used by clang's -fprofile-instr-use= for PGO. llvm-svn: 206656
* InstrProf: Silence spurious warnings in GCC 4.8Duncan P. N. Exon Smith2014-03-241-9/+13
| | | | | | No functionality change. llvm-svn: 204580
* InstrProf: Check pointer size in raw profileDuncan P. N. Exon Smith2014-03-231-11/+40
| | | | | | | | | | | | | | | Since the profile can come from 32-bit machines, we need to check the pointer size. Change the magic number to facilitate this. Adds tests for reading 32-bit and 64-bit binaries (both big- and little-endian). The tests write a binary using printf in RUN lines (like raw-magic-but-no-header.test). Assuming the bots don't complain, this seems like a better way forward for testing RawInstrProfReader than committing binary files. <rdar://problem/16400648> llvm-svn: 204557
* InstrProf: Move constructor to the headerDuncan P. N. Exon Smith2014-03-211-3/+0
| | | | | | | | Fixes 80-column violation at the same time. <rdar://problem/15950346> llvm-svn: 204516
* InstrProf: Change magic number to have non-text charactersDuncan P. N. Exon Smith2014-03-211-8/+8
| | | | | | | | | Include non-text characters in the magic number so that text files can't match. <rdar://problem/15950346> llvm-svn: 204513
* InstrProf: Use move semantics with unique_ptrDuncan P. N. Exon Smith2014-03-211-4/+4
| | | | | | <rdar://problem/15950346> llvm-svn: 204512
* InstrProf: Detect magic numbers in a more scalable wayDuncan P. N. Exon Smith2014-03-211-34/+32
| | | | | | | | No functionality change. <rdar://problem/15950346> llvm-svn: 204511
* InstrProf: Actually detect bad headersDuncan P. N. Exon Smith2014-03-211-7/+5
| | | | | | <rdar://problem/15950346> llvm-svn: 204510
* InstrProf: Read raw binary profile in llvm-profdataDuncan P. N. Exon Smith2014-03-211-4/+106
| | | | | | | | | | | | | | Read a raw binary profile that corresponds to a memory dump from the runtime profile. The test is a binary file generated from cfe/trunk/test/Profile/c-general.c with the new compiler-rt runtime and the matching text version of the input. It includes instructions on how to regenerate. <rdar://problem/15950346> llvm-svn: 204496
* ProfileData: Introduce the InstrProfReader interface and a text readerJustin Bogner2014-03-211-0/+84
This introduces the ProfileData library and updates llvm-profdata to use this library for reading profiles. InstrProfReader is an abstract base class that will be subclassed for both the raw instrprof data from compiler-rt and the efficient instrprof format that will be used for PGO. llvm-svn: 204482
OpenPOWER on IntegriCloud