aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/InstrProfWriter.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-08-11Use range algorithms instead of unpacking begin/endDavid Majnemer1-2/+1
No functionality change is intended. llvm-svn: 278417
2016-08-11Fix some Clang-tidy modernize and Include What You Use warnings.Eugene Zelenko1-3/+16
Differential revision: https://reviews.llvm.org/D23291 llvm-svn: 278364
2016-07-19Retry: [llvm-profdata] Speed up merging by using a thread poolVedant Kumar1-0/+8
Add a "-j" option to llvm-profdata to control the number of threads used. Auto-detect NumThreads when it isn't specified, and avoid spawning threads when they wouldn't be beneficial. I tested this patch using a raw profile produced by clang (147MB). Here is the time taken to merge 4 copies together on my laptop: No thread pool: 112.87s user 5.92s system 97% cpu 2:01.08 total With 2 threads: 134.99s user 26.54s system 164% cpu 1:33.31 total Changes since the initial commit: - When handling odd-length inputs, call ThreadPool::wait() before merging the last profile. Should fix a race/off-by-one (see r275937). Differential Revision: https://reviews.llvm.org/D22438 llvm-svn: 275938
2016-07-19Revert "[llvm-profdata] Speed up merging by using a thread pool"Vedant Kumar1-8/+0
This reverts commit r275921. It broke the ppc64be bot: http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/3537 I'm not sure why it broke, but based on the output, it looks like an off-by-one (one profile left un-merged). llvm-svn: 275937
2016-07-18[llvm-profdata] Speed up merging by using a thread poolVedant Kumar1-0/+8
Add a "-j" option to llvm-profdata to control the number of threads used. Auto-detect NumThreads when it isn't specified, and avoid spawning threads when they wouldn't be beneficial. I tested this patch using a raw profile produced by clang (147MB). Here is the time taken to merge 4 copies together on my laptop: No thread pool: 112.87s user 5.92s system 97% cpu 2:01.08 total With 2 threads: 134.99s user 26.54s system 164% cpu 1:33.31 total Differential Revision: https://reviews.llvm.org/D22438 llvm-svn: 275921
2016-05-20[ProfileData] Thread unique_ptr through the summary builder to avoid leaks.Benjamin Kramer1-1/+1
llvm-svn: 270195
2016-05-19Remove specializations of ProfileSummaryEaswaran Raman1-7/+6
This removes the subclasses of ProfileSummary, moves the members of the derived classes to the base class. Differential Revision: http://reviews.llvm.org/D20390 llvm-svn: 270143
2016-05-19Move ProfileSummary to IR.Easwaran Raman1-7/+8
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 llvm-svn: 270136
2016-05-19Retry^3 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"Vedant Kumar1-3/+2
Transition InstrProf and Coverage over to the stricter Error/Expected interface. Changes since the initial commit: - Fix error message printing in llvm-profdata. - Check errors in loadTestingFormat() + annotateAllFunctions(). - Defer error handling in InstrProfIterator to InstrProfReader. - Remove the base ProfError class to work around an MSVC ICE. Differential Revision: http://reviews.llvm.org/D19901 llvm-svn: 270020
2016-05-16Revert "Retry^2 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC""Vedant Kumar1-2/+3
This reverts commit r269694. MSVC says: error C2086: 'char llvm::ProfErrorInfoBase<enum llvm::instrprof_error>::ID' : redefinition llvm-svn: 269700
2016-05-16Retry^2 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"Vedant Kumar1-3/+2
Transition InstrProf and Coverage over to the stricter Error/Expected interface. Changes since the initial commit: - Address undefined-var-template warning. - Fix error message printing in llvm-profdata. - Check errors in loadTestingFormat() + annotateAllFunctions(). - Defer error handling in InstrProfIterator to InstrProfReader. Differential Revision: http://reviews.llvm.org/D19901 llvm-svn: 269694
2016-05-14Revert "Retry "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC""Chandler Carruth1-2/+3
This reverts commit r269491. It triggers warnings with Clang, breaking builds for -Werror users including several build bots. llvm-svn: 269547
2016-05-13Retry "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"Vedant Kumar1-3/+2
Transition InstrProf and Coverage over to the stricter Error/Expected interface. Changes since the initial commit: - Fix error message printing in llvm-profdata. - Check errors in loadTestingFormat() + annotateAllFunctions(). - Defer error handling in InstrProfIterator to InstrProfReader. Differential Revision: http://reviews.llvm.org/D19901 llvm-svn: 269491
2016-05-13Revert "(HEAD -> master, origin/master, origin/HEAD) [ProfileData] (llvm) ↵Vedant Kumar1-2/+3
Use Error in InstrProf and Coverage, NFC" This reverts commit r269462. It fails two llvm-profdata tests. llvm-svn: 269466
2016-05-13[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFCVedant Kumar1-3/+2
Transition InstrProf and Coverage over to the stricter Error/Expected interface. Differential Revision: http://reviews.llvm.org/D19901 llvm-svn: 269462
2016-05-11[ProfileData] Use SoftInstrProfErrors to count soft errors, NFCVedant Kumar1-4/+3
Differential Revision: http://reviews.llvm.org/D20082 llvm-svn: 269222
2016-02-19Add profile summary support for sample profile.Easwaran Raman1-4/+2
Differential Revision: http://reviews.llvm.org/D17178 llvm-svn: 261304
2016-02-17Add a profile summary class specific to instrumentation profiles.Easwaran Raman1-3/+3
Modify ProfileSummary class to make it not instrumented profile specific. Add a new InstrumentedProfileSummary class that inherits from ProfileSummary. Differential Revision: http://reviews.llvm.org/D17310 llvm-svn: 261119
2016-02-10[PGO] Differentiate Clang instrumentation and IR level instrumentation profilesRong Xu1-1/+5
This patch uses one bit in profile version to differentiate Clang instrumentation and IR level instrumentation profiles. PGOInstrumenation generates a COMDAT variable __llvm_profile_raw_version so that the compiler runtime can set the right profile kind. For Maco-O platform, we generate the variable as linkonce_odr linkage as COMDAT is not supported. PGOInstrumenation now checks this bit to make sure it's an IR level instrumentation profile. The patch was submitted as r260164 but reverted due to a Darwin test breakage. Original Differential Revision: http://reviews.llvm.org/D15540 Differential Revision: http://reviews.llvm.org/D17020 llvm-svn: 260385
2016-02-08[PGO] Revert r260146 as it breaks Darwin platforms.Rong Xu1-5/+1
r260146 | xur | 2016-02-08 13:07:46 -0800 (Mon, 08 Feb 2016) | 13 lines [PGO] Differentiate Clang instrumentation and IR level instrumentation profiles llvm-svn: 260170
2016-02-08[PGO] Differentiate Clang instrumentation and IR level instrumentation profilesRong Xu1-1/+5
This patch uses one bit in profile version to differentiate Clang instrumentation and IR level instrumentation profiles. PGOInstrumenation generates a COMDAT variable __llvm_profile_raw_version so that the compiler runtime can set the right profile kind. PGOInstrumenation now checks this bit to make sure it's an IR level instrumentation profile. Differential Revision: http://reviews.llvm.org/D15540 llvm-svn: 260146
2016-02-03Fix a typo in commentXinliang David Li1-1/+1
llvm-svn: 259631
2016-02-03[PGO] Profile summary reader/writer supportXinliang David Li1-10/+53
With this patch, the profile summary data will be available in indexed profile data file so that profiler reader/compiler optimizer can start to make use of. Differential Revision: http://reviews.llvm.org/D16258 llvm-svn: 259626
2016-01-29[Profiling] Add a -sparse mode to llvm-profdata mergeVedant Kumar1-6/+24
Add an option to llvm-profdata merge for writing out sparse indexed profiles. These profiles omit InstrProfRecords for functions which are never executed. Differential Revision: http://reviews.llvm.org/D16727 llvm-svn: 259258
2016-01-22[PGO] Remove use of static variable. /NFCXinliang David Li1-11/+15
Make the variable a member of the writer trait object owned now by the writer. Also use a different generator interface to pass the infoObject from the writer. llvm-svn: 258544
2016-01-22Revert 258486 -- for a better fix coming soonXinliang David Li1-10/+7
llvm-svn: 258538
2016-01-22[PGO] eliminate use of static variableXinliang David Li1-7/+10
llvm-svn: 258486
2016-01-15Fix -Wmismatched-tags warning/errorXinliang David Li1-1/+2
llvm-svn: 257924
2016-01-15[PGO] Commonize (more) index profile file and buffer writer.Xinliang David Li1-33/+70
The file and buffer writer code are mostly shared except for the stream back-patching. This is because raw_string_ostream does not support seek like interface. The result is that the data patching code needs to be pushed to the caller which is not quite readable (passing around offset, value etc). This also makes future enhancement (which needs more patching) more difficult (and can make impl messy). In this patch, two types of streams needed by the writer are now unified with same set of interfaces under ProfOStream class. The patch method is added so that common implementation becomes cleaner. It also enables future enhancement. Should be NFC. llvm-svn: 257921
2016-01-14[PGO] clean up and documentationXinliang David Li1-1/+1
Introduce enum for indexed format versions and document indexed format change history. llvm-svn: 257737
2016-01-08[PGO] Ensure vp data in indexed profile always sortedXinliang David Li1-0/+2
Done in InstrProfWriter to eliminate the need for client code to do the sorting. The operation is done once and reused many times so it is more efficient. Update unit test to remove sorting. Also update expected output of affected tests. llvm-svn: 257145
2016-01-08[PGO] Fix a bug in InstProfWriter addRecordXinliang David Li1-11/+3
For a new record with weight != 1, only edge profiling counters are scaled, VP data is not properly scaled. This patch refactors the code and fixes the problem. Also added sort by count interface (for follow up patch). llvm-svn: 257143
2015-12-20Fix a latent UAF bug in profwriterXinliang David Li1-0/+2
llvm-svn: 256116
2015-12-20[PGO] Improve Indexed Profile Reader efficiency Xinliang David Li1-8/+8
With the support of value profiling added, the Indexed prof reader gets less efficient. The prof reader initialization used to be just reading the file header, but with VP support added, initialization needs to walk through all profile keys of ondisk hash table resulting in very poor locality and large memory increase (keys are stored together with the profile data in the mapped profile buffer). Even worse, when the reader is used by the compiler (not llvm-profdata too), the penalty becomes very high as compilation of each single module requires touching profile data buffer for the whole program. In this patch, the icall target values (MD5hash) are no longer eargerly converted back to name strings when the data is read into memory. New interface is added to to profile reader so that InstrProfSymtab can be lazily created for Indexed profile reader on-demand. Creating of the symtab is intended to be used by llvm-profdata tool for symbolic dumping of VP data. It can be used with compiler (for legacy out of tree uses) too but not recommended due to compile time and memory reasons mentioned above. Some other cleanups are also included: Function Addr to md5 map is now consolated into InstrProfSymtab. InstrProfStringtab is no longer used and eliminated. llvm-svn: 256114
2015-12-18[PGO] Simplify computehash interface (NFC)Xinliang David Li1-1/+1
llvm-svn: 256047
2015-12-15[llvm-profdata] Add support for weighted merge of profile data (2nd try)Nathan Slingerland1-2/+12
Summary: This change adds support for specifying a weight when merging profile data with the llvm-profdata tool. Weights are specified by using the --weighted-input=<weight>,<filename> option. Input files not specified with this option (normal positional list after options) are given a default weight of 1. Adding support for arbitrary weighting of input profile data allows for relative importance to be placed on the input data from multiple training runs. Both sampled and instrumented profiles are supported. Reviewers: davidxl, dnovillo, bogner, silvas Subscribers: silvas, davidxl, llvm-commits Differential Revision: http://reviews.llvm.org/D15306 llvm-svn: 255659
2015-12-14[PGO] Value profiling text format reader/writer supportXinliang David Li1-1/+33
This patch adds the missing functionality in parsable text format support for value profiling. Differential Revision: http://reviews.llvm.org/D15212 llvm-svn: 255523
2015-12-04Revert "[llvm-profdata] Add support for weighted merge of profile data"Nathan Slingerland1-12/+2
This reverts commit b7250858d96b8ce567681214273ac0e62713c661. Reverting in order to investigate Windows test failure. llvm-svn: 254687
2015-12-04[llvm-profdata] Add support for weighted merge of profile dataNathan Slingerland1-2/+12
This change adds support for an optional weight when merging profile data with the llvm-profdata tool. Weights are specified by adding an option ':<weight>' suffix to the input file names. Adding support for arbitrary weighting of input profile data allows for relative importance to be placed on the input data from multiple training runs. Both sampled and instrumented profiles are supported. Reviewers: dnovillo, bogner, davidxl Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14547 llvm-svn: 254669
2015-12-02[llvm-profdata] Change instr prof counter overflow to saturate rather than ↵Nathan Slingerland1-5/+6
discard Summary: This changes overflow handling during instrumentation profile merge. Rathar than throwing away records that would result in counter overflow, merged counts are instead clamped to the maximum representable value. A warning about counter overflow is still surfaced to the user as before. Reviewers: dnovillo, davidxl, silvas Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14893 llvm-svn: 254525
2015-11-23[PGO] In llvm-profdata text dump, add comment lines as annotationsXinliang David Li1-1/+4
llvm-svn: 253930
2015-11-23[PGO] Add --text option for llvm-profdata show|merge commandsXinliang David Li1-0/+15
The new option is similar to the SampleProfile dump option. - dump raw/indexed format into text profile format - merge the profile and output into text profile format. Note that Value Profiling data text format is not yet designed. That functionality will be added later. Differential Revision: http://reviews.llvm.org/D14894 llvm-svn: 253913
2015-11-20Fix the Windows build, include <tuple> for std::tieReid Kleckner1-0/+1
llvm-svn: 253698
2015-11-20[llvm-profdata] Add merge() to InstrProfRecordNathan Slingerland1-36/+18
Summary: This change refactors two aspects of InstrProfRecord: 1) Add a merge() method to InstrProfRecord (previously InstrProfWriter combineInstrProfRecords()) in order to better encapsulate this functionality and to make the InstrProfRecord and SampleRecord APIs more consistent. 2) Make InstrProfRecord mergeValueProfData() a private method since it is only ever called internally by merge(). Reviewers: dnovillo, bogner, davidxl Subscribers: silvas, vsk, llvm-commits Differential Revision: http://reviews.llvm.org/D14786 llvm-svn: 253695
2015-11-17[PGO] Move value profile data definitions out of IndexedInstrProfXinliang David Li1-3/+3
Move the data structure defintions out of the namespace. The defs will be shared by raw format. [NFC] llvm-svn: 253394
2015-11-10[PGO] Make indexed value profile data more compactXinliang David Li1-43/+14
- 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
2015-11-06Code style fix (caused by wrongly default clang-format style) (NFC)Xinliang David Li1-5/+9
llvm-svn: 252276
2015-11-02[PGO] Value profiling (index format) code cleanup and testingXinliang David Li1-48/+30
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
2015-10-18Minor Instr PGO code restructuringXinliang David Li1-5/+15
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
2015-09-29InstrProf: Support for value profiling in the indexed profile formatJustin Bogner1-34/+114
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