summaryrefslogtreecommitdiff
path: root/lib/ProfileData/SampleProfReader.cpp
AgeCommit message (Collapse)Author
2018-06-11Fix a warning issued by clang.Wei Mi
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334453 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-11[SampleFDO] Add a new compact binary format for sample profile.Wei Mi
Name table occupies a big chunk of size in current binary format sample profile. In order to reduce its size, the patch changes the sample writer/reader to save/restore MD5Hash of names in the name table. Sample annotation phase will also use MD5Hash of name to query samples accordingly. Experiment shows compact binary format can reduce the size of sample profile by 2/3 compared with binary format generally. Differential Revision: https://reviews.llvm.org/D47955 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334447 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-01Remove \brief commands from doxygen comments.Adrian Prantl
We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46290 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331272 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-07[SampleFDO] Extend SampleProfReader to handle demangled names.Wei Mi
SampleProfReader assumes function names in the profile are all mangled names. However, there are cases that few demangled names are somehow contained in the profile (usually because of debug info problems), which may trigger parsing error in SampleProfReader and cause the whole profile to be unusable. The patch extends SampleProfReader to handle profiles with demangled names, so that those profiles can still be useful. Differential revision: https://reviews.llvm.org/D44161 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326905 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-14Fix many -Wsign-compare and -Wtautological-constant-compare warnings.Zachary Turner
Most of the -Wsign-compare warnings are due to the fact that enums are signed by default in the MS ABI, while the tautological comparison warnings trigger on x86 builds where sizeof(size_t) is 4 bytes, so N > numeric_limits<unsigned>::max() is always false. Differential Revision: https://reviews.llvm.org/D41256 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320750 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-12Fix warnings. [-Wdocumentation]NAKAMURA Takumi
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315573 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13SamplePGO: convert callsite samples map key from callsite_location to ↵Dehao Chen
callsite_location+callee_name Summary: For iterative SamplePGO, an indirect call can be speculatively promoted to multiple direct calls and get inlined. All these promoted direct calls will share the same callsite location (offset+discriminator). With the current implementation, we cannot distinguish between different promotion candidates and its inlined instance. This patch adds callee_name to the key of the callsite sample map. And added helper functions to get all inlined callee samples for a given callsite location. This helps the profile annotator promote correct targets and inline it before annotation, and ensures all indirect call targets to be annotated correctly. Reviewers: davidxl, dnovillo Reviewed By: davidxl Subscribers: andreadb, llvm-commits Differential Revision: https://reviews.llvm.org/D31950 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300240 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-03[ProfileData] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko
warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296846 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-22Fix an obvious bug in SampleProfileReaderGCC.Dehao Chen
Summary: The CallTargetProfile should be added to FProfile to be consistent with other profile readers. Reviewers: dnovillo, davidxl Reviewed By: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30233 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295852 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-29[ProfileData] Clean up string handling a bit.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271180 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20[ProfileData] Thread unique_ptr through the summary builder to avoid leaks.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270195 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19Remove specializations of ProfileSummaryEaswaran Raman
This removes the subclasses of ProfileSummary, moves the members of the derived classes to the base class. Differential Revision: http://reviews.llvm.org/D20390 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270143 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19Move ProfileSummary to IR.Easwaran Raman
This splits ProfileSummary into two classes: a ProfileSummary class that has methods to convert from/to metadata and a ProfileSummaryBuilder class that computes the profiles summary which is in ProfileData. Differential Revision: http://reviews.llvm.org/D20314 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270136 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18[NFC] Header cleanupMehdi Amini
Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266595 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-03Use LineLocation instead of CallsiteLocation to index callsite profile.Dehao Chen
Summary: With discriminator, LineLocation can uniquely identify a callsite without the need to specifying callee name. Remove Callee function name from the key, and put it in the value (FunctionSamples). Reviewers: davidxl, dnovillo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17827 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262634 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-19Add profile summary support for sample profile.Easwaran Raman
Differential Revision: http://reviews.llvm.org/D17178 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261304 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-16[PGO] Handle and report overflow during profile merge for all types of dataNathan Slingerland
Summary: Surface counter overflow when merging profile data. Merging still occurs on overflow but counts saturate to the maximum representable value. Overflow is reported to the user. Reviewers: davidxl, dnovillo, silvas Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15547 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255825 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-10[ProfileData] Add unit test infrastructure for sample profile reader/writerNathan Slingerland
Summary: Adds support for in-memory round-trip of sample profile data along with basic round trip unit tests. This will also make it easier to include unit tests for future changes to sample profiling. Reviewers: davidxl, dnovillo, silvas Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15211 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255264 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-13SamplePGO - Add dump routines for LineLocation, SampleRecord and FunctionSamplesDiego Novillo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253071 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-13[llvm-profdata] Add check for text profile formats and improve error ↵Nathan Slingerland
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253009 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12reverting r252916 to investigate test failureNathan Slingerland
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252921 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12[llvm-profdata] Add check for text profile formats and improve error reportingNathan Slingerland
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252916 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12SamplePGO - Move FunctionSamples::print() to a better location. NFC.Diego Novillo
The class is declared in SampleProf.h, so a better home for this is SampleProf.cpp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252915 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-21Tolerate negative offset when matching sample profile.Dehao Chen
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250873 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-16Sample profiles - Re-arrange binary format to emit head samples only on top ↵Diego Novillo
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250539 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-15Sample Profiles - Adjust integer types. Mostly NFC.Diego Novillo
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250427 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-14Sample profiles - Add documentation for binary profile encoding. NFC.Diego Novillo
This adds documentation for the binary profile encoding and moves the documentation for the text encoding into the header file SampleProfReader.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250309 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13Sample profile reader - remove dead code. NFC.Diego Novillo
This removes old remnants from the gcov reader. I missed these when I re-wrote it recently. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250242 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13Sample profiles - Add a name table to the binary encoding.Diego Novillo
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250241 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09Add inline stack streaming to binary sample profiles.Diego Novillo
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249861 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08Re-apply r249644: Handle inline stacks in gcov-encoded sample profiles.Diego Novillo
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249724 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08Revert "Handle inline stacks in gcov-encoded sample profiles."Diego Novillo
This reverts commit r249644. The buildbots are failing the new test I added. Investigating. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249648 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08Handle inline stacks in gcov-encoded sample profiles.Diego Novillo
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249644 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05Remove AutoFDO profile handling for GCC's LIPO. NFC.Diego Novillo
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249351 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30http://reviews.llvm.org/D13145Dehao Chen
Support hierarachical sample profile format. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248865 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-17GCC AutoFDO profile reader - Initial support.Diego Novillo
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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247874 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03Use ErrorOr for the ::create factory on instrumented and sample profilers.Diego Novillo
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221120 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-01Add show and merge tools for sample PGO profiles.Diego Novillo
Summary: This patch extends the 'show' and 'merge' commands in llvm-profdata to handle sample PGO formats. Using the 'merge' command it is now possible to convert one sample PGO format to another. The only format that is currently not working is 'gcc'. I still need to implement support for it in lib/ProfileData. The changes in the sample profile support classes are needed for the merge operation. Reviewers: bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6065 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221032 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-30Add profile writing capabilities for sampling profiles.Diego Novillo
Summary: This patch finishes up support for handling sampling profiles in both text and binary formats. The new binary format uses uleb128 encoding to represent numeric values. This makes profiles files about 25% smaller. The profile writer class can write profiles in the existing text and the new binary format. In subsequent patches, I will add the capability to read (and perhaps write) profiles in the gcov format used by GCC. Additionally, I will be adding support in llvm-profdata to manipulate sampling profiles. There was a bit of refactoring needed to separate some code that was in the reader files, but is actually common to both the reader and writer. The new test checks that reading the same profile encoded as text or raw, produces the same results. Reviewers: bogner, dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6000 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220915 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-17LineIterator: Provide a variant that keeps blank linesJustin Bogner
It isn't always useful to skip blank lines, as evidenced by the somewhat awkward use of line_iterator in llvm-cov. This adds a knob to control whether or not to skip blanks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217960 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-09Re-factor sample profile reader into lib/ProfileData.Diego Novillo
Summary: This patch moves the profile reading logic out of the Sample Profile transformation into a generic profile reader facility in lib/ProfileData. The intent is to use this new reader to implement a sample profile reader/writer that can be used to convert sample profiles from external sources into LLVM. This first patch introduces no functional changes. It moves the profile reading code from lib/Transforms/SampleProfile.cpp into lib/ProfileData/SampleProfReader.cpp. In subsequent patches I will: - Add a bitcode format for sample profiles to allow for more efficient encoding of the profile. - Add a writer for both text and bitcode format profiles. - Add a 'convert' command to llvm-profdata to be able to convert between the two (and serve as entry point for other sample profile formats). Reviewers: bogner, echristo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5250 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217437 91177308-0d34-0410-b5e6-96231b3b80d8