aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-profdata/llvm-profdata.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-06-17Apply another batch of fixes from clang-tidy's ↵Benjamin Kramer1-8/+10
performance-unnecessary-value-param. Contains some manual fixes. No functionality change intended. llvm-svn: 273047
2016-06-09Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith1-1/+1
looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. llvm-svn: 272232
2016-06-07Retry^4 "[llvm-profdata] Add option to ingest filepaths from a file"Vedant Kumar1-6/+59
Changes since the initial commit: - Use echo instead of printf. This should side-step the character escaping issues on Windows. Differential Revision: http://reviews.llvm.org/D20980 llvm-svn: 272068
2016-06-06Revert "Retry^2 "[llvm-profdata] Add option to ingest filepaths from a file""Vedant Kumar1-63/+13
This reverts commit r271953. It's still breaking on Windows, though the list initialization issue is fixed: http://bb.pgr.jp/builders/ninja-clang-i686-msc19-R/builds/3751 llvm-svn: 271963
2016-06-06Retry^2 "[llvm-profdata] Add option to ingest filepaths from a file"Vedant Kumar1-13/+63
Changes since the initial commit: - Normalize file paths read from the file to prevent Windows path separators from escaping parts of the path. - Since we need to store the normalized file paths in WeightedFile, don't do tricky things to keep the source MemoryBuffer alive. - Don't use list-initialization for a std::string in WeightedFile. Differential Revision: http://reviews.llvm.org/D20980 llvm-svn: 271953
2016-06-06Revert "Retry "[llvm-profdata] Add option to ingest filepaths from a file"Vedant Kumar1-58/+13
This reverts commit r271949. It breaks the Windows build: http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/12796 llvm-svn: 271952
2016-06-06Retry "[llvm-profdata] Add option to ingest filepaths from a file"Vedant Kumar1-13/+58
Changes since the initial commit: - Normalize file paths read from the file to prevent Windows path separators from escaping parts of the path. - Since we need to store the normalized file paths in WeightedFile, don't do tricky things to keep the source MemoryBuffer alive. Differential Revision: http://reviews.llvm.org/D20980 llvm-svn: 271949
2016-06-04[llvm-profdata] Revert r271709 and the 3 subsequent commits - the codeChandler Carruth1-57/+4
and/or tests aren't working on Windows currently. There seems to be some problem with quoting the file paths. I don't understand the test structure here or the code well enough to try to come up with a way to correctly handle paths with back slashes in them, and this has caused the Windows builds to be failing for 7 hours now, so I'm reverting the whole thing to bring them back to life. Sorry for the disruption, but a couple of these were bug fixes anyways that can be folded into a fresh commit. Reverts the following patches: r271756: Clean up the way we create the input filenames buffer (NFC) r271748: Fix use-after-free from discarded MemoryBuffer (NFC) r271710: Fix option description (NFC) r271709: Add option to ingest filepaths from a file llvm-svn: 271760
2016-06-04[llvm-profdata] Clean up the way we create the input filenames buffer (NFC)Vedant Kumar1-7/+14
Create the buffer before calling parseInputFilenamesFile(), and add a comment explaining why this is done. Thanks to David Li for the suggestion! llvm-svn: 271756
2016-06-03[llvm-profdata] Fix use-after-free from discarded MemoryBuffer (NFC)Vedant Kumar1-8/+13
Thanks to Justin Bogner for pointing this out! Caught by ASAN. llvm-svn: 271748
2016-06-03[llvm-profdata] Fix option description (NFC)Vedant Kumar1-1/+1
llvm-svn: 271710
2016-06-03[llvm-profdata] Add option to ingest filepaths from a fileVedant Kumar1-4/+45
Differential Revision: http://reviews.llvm.org/D20980 llvm-svn: 271709
2016-06-03Trim some spaces (NFC)Vedant Kumar1-2/+0
llvm-svn: 271681
2016-05-23[profile] show more statisticsXinliang David Li1-1/+14
Add value profile statistics with the 'show' command. llvm-svn: 270450
2016-05-19Remove specializations of ProfileSummaryEaswaran Raman1-4/+3
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-9/+10
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-27/+41
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-41/+27
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-27/+41
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-41/+27
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-27/+41
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-40/+27
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-27/+40
Transition InstrProf and Coverage over to the stricter Error/Expected interface. Differential Revision: http://reviews.llvm.org/D19901 llvm-svn: 269462
2016-05-03Remove unused header, NFCVedant Kumar1-1/+0
llvm-svn: 268361
2016-04-14Remove every uses of getGlobalContext() in LLVM (but the C API)Mehdi Amini1-3/+4
At the same time, fixes InstructionsTest::CastInst unittest: yes you can leave the IR in an invalid state and exit when you don't destroy the context (like the global one), no longer now. This is the first part of http://reviews.llvm.org/D19094 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266379
2016-02-17Add a profile summary class specific to instrumentation profiles.Easwaran Raman1-2/+2
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-4/+11
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-11/+4
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-4/+11
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-04Refactor profile summary support code. NFC.Easwaran Raman1-0/+1
Summary computation is not just for instrumented profiling and so I have moved the ProfileSummary class to ProfileCommon.h (named so to allow code unrelated to summary but common to instrumented and sampled profiling to be placed there) Differential Revision: http://reviews.llvm.org/D16661 llvm-svn: 259846
2016-01-29[Profiling] Add a -sparse mode to llvm-profdata mergeVedant Kumar1-3/+7
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-16[PGO] fix a bug in profile summary computationXinliang David Li1-1/+1
Entry block count was not counted and is corrected. Also introduce a new metric that is MaxInternalBlockCount which show command shows (as before). llvm-svn: 257987
2016-01-14[PGO] Move profile summary interface/impl into InstrProf.[*] /NFCXinliang David Li1-99/+0
llvm-svn: 257819
2016-01-14llvm-profdata.cpp: Fix comment lines. [-Wdocumentation]NAKAMURA Takumi1-3/+3
llvm-svn: 257726
2016-01-13Display detailed profile summary in llvm-profdata tool.Easwaran Raman1-16/+136
This adds a detailed profile summary in llvm-profdata. The summary is in the form of one or more triples of the form (P, N, M) which is interpreted as if we look at the Top-N counts in the profile, their sum accounts for P percentage of the sum of all counts in the program and the minimum count in the Top-N is M. Differential Revision: http://reviews.llvm.org/D16005 llvm-svn: 257680
2015-12-20[PGO] Improve Indexed Profile Reader efficiency Xinliang David Li1-2/+5
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-16[PGO] Handle and report overflow during profile merge for all types of dataNathan Slingerland1-1/+5
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 llvm-svn: 255825
2015-12-15[llvm-profdata] Add support for weighted merge of profile data (2nd try)Nathan Slingerland1-18/+58
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-14Fix formatting. NFC.Diego Novillo1-8/+5
llvm-svn: 255541
2015-12-04Revert "[llvm-profdata] Add support for weighted merge of profile data"Nathan Slingerland1-54/+16
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-16/+54
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-11-23[PGO] Add --text option for llvm-profdata show|merge commandsXinliang David Li1-37/+70
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-18[llvm-profdata] Use SmallSet rather that std::set for keeping track of ↵Nathan Slingerland1-3/+2
profdata merge errors Missed bit of feedback from D14720. Use SmallSet<std::error_code> rather than std::set<...> in order to be more efficient. llvm-svn: 253474
2015-11-18[llvm-profdata] Fix unhandled enumeration values warningNathan Slingerland1-0/+2
Fix this: llvm/tools/llvm-profdata/llvm-profdata.cpp:78:15: warning: 12 enumeration values not handled in switch: 'success', 'eof', 'unrecognized_format'... [-Wswitch] switch (instrError) { ^ llvm-svn: 253413
2015-11-17[llvm-profdata] Show hint for other mismatch errors when merging instr profdataNathan Slingerland1-1/+5
Missed bit of feedback from D14720. Show the same "Make sure that all profile data to be merged is generated from the same binary." hint for hash mismatch and value site count mismatch as we now do for counter mismatch when merging incompatible instrumentation profile data. llvm-svn: 253400
2015-11-17[llvm-profdata] Improve error messaging when merging mismatched profile dataNathan Slingerland1-4/+38
Summary: This change tries to make the root cause of instrumented profile data merge failures clearer. Previous: $ llvm-profdata merge test_0.profraw test_1.profraw -o test_merged.profdata test_1.profraw: foo: Function count mismatch test_1.profraw: bar: Function count mismatch test_1.profraw: baz: Function count mismatch ... Changed: $ llvm-profdata merge test_0.profraw test_1.profraw -o test_merged.profdata test_1.profraw: foo: Function basic block count change detected (counter mismatch) Make sure that all profile data to be merged is generated from the same binary. test_1.profraw: bar: Function basic block count change detected (counter mismatch) test_1.profraw: baz: Function basic block count change detected (counter mismatch) ... Reviewers: dnovillo, davidxl, bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14739 llvm-svn: 253384
2015-11-13[llvm-profdata] Add check for text profile formats and improve error ↵Nathan Slingerland1-13/+29
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
2015-11-12reverting r252916 to investigate test failureNathan Slingerland1-29/+13
llvm-svn: 252921
2015-11-12[llvm-profdata] Add check for text profile formats and improve error reportingNathan Slingerland1-13/+29
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
2015-11-02[PGO] Value profiling (index format) code cleanup and testingXinliang David Li1-5/+9
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