aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-profdata/llvm-profdata.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-08-31Fix some errors introduced by rL370563 which were not exposed on my local ↵Wei Mi1-1/+1
machine. 1. zlib::compress accept &size_t but the param is an uint64_t. 2. Some systems don't have zlib installed. Don't use compression by default. llvm-svn: 370564
2019-08-31[SampleFDO] Add profile symbol list section to discriminate function beingWei Mi1-20/+67
cold versus function being newly added. This is the second half of https://reviews.llvm.org/D66374. Profile symbol list is the collection of function symbols showing up in the binary which generates the current profile. It is used to discriminate function being cold versus function being newly added. Profile symbol list is only added for profile with ExtBinary format. During profile use compilation, when profile-sample-accurate is enabled, a function without profile will be regarded as cold only when it is contained in that list. Differential Revision: https://reviews.llvm.org/D66766 llvm-svn: 370563
2019-08-23[SampleFDO] Add ExtBinary format to support extension of binary profile.Wei Mi1-9/+16
This is a patch split from https://reviews.llvm.org/D66374. It tries to add a new format of profile called ExtBinary. The format adds a section header table to the profile and organize the profile in sections, so the future extension like adding a new section or extending an existing section will be easier while keeping backward compatiblity feasible. Differential Revision: https://reviews.llvm.org/D66513 llvm-svn: 369798
2019-08-15[llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-2/+2
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
2019-08-05Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song1-3/+3
F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
2019-07-08llvm-profdata] Handle the cases of overlapping input file and output fileRong Xu1-11/+17
Currently llvm-profdata does not expect the same file name for the input profile and the output profile. >llvm-profdata merge A.profraw B.profraw -o B.profraw The above command runs successfully but the resulted B.profraw is not correct. This patch fixes the issue by moving the initialization of writer after loading the profile. For the show command, the following will report a confusing error of "Empty raw profile file": >llvm-profdata show B.profraw -o B.profraw It's harder to fix as we need to output something before loading the input profile. I don't think that a fix for this is worth the effort. I just make the error explicit for the show command. Differential Revision: https://reviews.llvm.org/D64360 llvm-svn: 365386
2019-04-30[llvm-profdata] Add overlap command to compute similarity b/w two profile filesRong Xu1-2/+89
Add overlap functionality to llvm-profdata tool to compute the similarity between two profile files. Differential Revision: https://reviews.llvm.org/D60977 llvm-svn: 359612
2019-03-15[llvm-profdata] Deleted unused Cutoffs added by D16005Fangrui Song1-2/+0
llvm-svn: 356248
2019-02-28[PGO] Context sensitive PGO (part 2)Rong Xu1-6/+15
Part 2 of CSPGO changes (mostly related to ProfileSummary). Note that I use a default parameter in setProfileSummary() and getSummary(). This is to break the dependency in clang. I will make the parameter explicit after changing clang in a separated patch. Differential Revision: https://reviews.llvm.org/D54175 llvm-svn: 355131
2019-02-21Fix some include order and file headers issues. NFCFangrui Song1-1/+1
llvm-svn: 354550
2019-02-05[PGO] Fix the type of the formated variablePetar Jovanovic1-1/+1
Change the format type of Value to PRIu64 since it is a uint64_t. The problem was detected on mips boards building 32-bit binaries, where it was printing junk values and causing test failure. Patch by Milos Stojanovic. Differential Revision: https://reviews.llvm.org/D57583 llvm-svn: 353194
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2019-01-08[llvm-profdata] add value-cutoff functionality in show commandRong Xu1-13/+53
This patch improves llvm-profdata show command: (1) add -value-cutoff=<N> option: Show only those functions whose max count values are greater or equal to N. (2) add -list-below-cutoff option: Only output names of functions whose max count value are below the cutoff. (3) formats value-profile counts and prints out percentage. Differential Revision: https://reviews.llvm.org/D56342 llvm-svn: 350673
2019-01-08[PGO] Revert r350579 to fix commit message.Rong Xu1-53/+13
Will re-commit it using the correct commit message. llvm-svn: 350670
2019-01-07[PGO] Use SourceFileName rather module name in PGOFuncNameRong Xu1-13/+53
In LTO or Thin-lto mode (though linker plugin), the module names are of temp file names which are different for different compilations. Using SourceFileName avoids the issue. This should not change any functionality for current PGO as all the current callers of getPGOFuncName() is before LTO. llvm-svn: 350579
2018-09-13Add flag to llvm-profdata to allow symbols in profile data to be remapped, andRichard Smith1-9/+99
add a tool to generate symbol remapping files. Summary: The new tool llvm-cxxmap builds a symbol mapping table from a file containing a description of partial equivalences to apply to mangled names and files containing old and new symbol tables. Reviewers: davidxl Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D51470 llvm-svn: 342168
2018-08-24Make llvm-profdata show -text work as advertised in the documentation.Richard Smith1-2/+6
Per LLVM's CommandGuide, llvm-profdata show -text is supposed to produce textual output that can be passed as input to further llvm-profdata invocations. This previously didn't work for two reasons: 1) -text was not sufficient to enable the machine-readable text format output; instead, -text was effectively ignored if -counts was not also specified. (With this patch, -counts is instead ignored if -text is specified, because the machine-readable text format always includes counts.) 2) When the input data was an IR-level profile, the :ir marker was missing from the output, resulting in a text format output that would not be usable as profiling data due to function hash mismatches. Differential Revision: https://reviews.llvm.org/D51188 llvm-svn: 340592
2018-06-12[NFC] Change sample profile format enum name SPF_Raw_Binary to SPF_Binary.Wei Mi1-11/+10
Some out-of-tree targets depend on the enum name SPF_Binary. Keep the name can avoid unnecessary churn to those targets. llvm-svn: 334476
2018-06-12Fix a typo in rL334447.Wei Mi1-1/+1
llvm-svn: 334475
2018-06-11[SampleFDO] Add a new compact binary format for sample profile.Wei Mi1-9/+19
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 llvm-svn: 334447
2018-04-18[llvm-profdata] Use WithColor for printing errorsJonas Devlieghere1-6/+12
Use convenience helpers in WithColor to print errors and warnings. Differential revision: https://reviews.llvm.org/D45658 llvm-svn: 330262
2018-04-13Define InitLLVM to do common initialization all at once.Rui Ueyama1-7/+2
We have a few functions that virtually all command wants to run on process startup/shutdown. This patch adds InitLLVM class to do that all at once, so that we don't need to copy-n-paste boilerplate code to each llvm command's main() function. Differential Revision: https://reviews.llvm.org/D45602 llvm-svn: 330046
2017-11-17[llvm-profdata] Don't treat non-fatal merge errors as fatalVedant Kumar1-7/+43
This fixes an issue seen on the coverage bot: http://lab.llvm.org:8080/green/view/Experimental/job/clang-stage2-coverage-R/1930 Profile merging shouldn't fail if a single counter mismatch is detected. llvm-svn: 318555
2017-11-17[llvm-profdata] Fix a dangling reference to an error stringVedant Kumar1-3/+11
llvm-svn: 318502
2017-11-14[llvm-profdata] Report if profile data file is IR- or FE-levelAdam Nemet1-0/+2
Differential Revision: https://reviews.llvm.org/D39997 llvm-svn: 318159
2017-10-04Bring r314809 back.Rafael Espindola1-2/+2
But now include a check for CPU_COUNT so we still build on 10 year old versions of glibc. Original message: Use sched_getaffinity instead of std::thread::hardware_concurrency. The issue with std::thread::hardware_concurrency is that it forwards to libc and some implementations (like glibc) don't take thread affinity into consideration. With this change a llvm program that can execute in only 2 cores will use 2 threads, even if the machine has 32 cores. This makes benchmarking a lot easier, but should also help if someone doesn't want to use all cores for compilation for example. llvm-svn: 314931
2017-10-04Revert D38481 due to missing cmake check for CPU_COUNTDaniel Neilson1-2/+2
Summary: This reverts D38481. The change breaks systems with older versions of glibc. It injects a use of CPU_COUNT() from sched.h without checking to ensure that the function exists first. Reviewers: Subscribers: llvm-svn: 314922
2017-10-03Use sched_getaffinity instead of std::thread::hardware_concurrency.Rafael Espindola1-2/+2
The issue with std::thread::hardware_concurrency is that it forwards to libc and some implementations (like glibc) don't take thread affinity into consideration. With this change a llvm program that can execute in only 2 cores will use 2 threads, even if the machine has 32 cores. This makes benchmarking a lot easier, but should also help if someone doesn't want to use all cores for compilation for example. llvm-svn: 314809
2017-07-11[ProfileData] Add new option to dump topn hottest functionsXinliang David Li1-6/+46
Differential Revision: http://reviews.llvm.org/D35155 llvm-svn: 307702
2017-07-10llvm-profdata: Reduce memory usage by using Error callback rather than memberDavid Blaikie1-3/+16
Reduces llvm-profdata memory usage on a large profile from 7.8GB to 5.1GB. The ProfData API now supports reporting all the errors/warnings rather than only the first, though llvm-profdata ignores everything after the first for now to preserve existing behavior. (if there's a desire for other behavior, happy to implement that - but might be as well left for a separate patch) Reviewers: davidxl Differential Revision: https://reviews.llvm.org/D35149 llvm-svn: 307516
2017-07-06Prototype: Reduce llvm-profdata merge memory usage furtherDavid Blaikie1-1/+2
The InstrProfWriter already stores the name and hash of the record in the nested maps it uses for lookup while merging - this data is duplicated in the value within the maps. Refactor the InstrProfRecord to use a nested struct for the counters themselves so that InstrProfWriter can use this nested struct alone without the name or hash duplicated there. This work is incomplete, but enough to demonstrate the value (around a 50% decrease in memory usage for a large test case (10GB -> 5GB)). Though most of that decrease is probably from removing the SoftInstrProfError as well, but I haven't implemented a replacement for it yet. (it needs to go with the counters, because the operations on the counters - merging, etc, are where the failures are - unlike the name/hash which are totally unused by those counter-related operations and thus easy to split out) Ongoing discussion about removing SoftInstrProfError as a field of the InstrProfRecord is happening on the thread that added it - including the possibility of moving back towards an earlier version of that proposed patch that passed SoftInstrProfError through the various APIs, rather than as a member of InstrProfRecord. Reviewers: davidxl Differential Revision: https://reviews.llvm.org/D34838 llvm-svn: 307298
2017-06-20[ProfileData] PR33517: Check for failure of symtab creationVedant Kumar1-3/+5
With PR33517, it became apparent that symbol table creation can fail when presented with malformed inputs. This patch makes that sort of error detectable, so llvm-cov etc. can fail more gracefully. Specifically, we now check that function names within the symbol table aren't empty. Testing: check-{llvm,clang,profile}, some unit test updates. llvm-svn: 305765
2017-05-24Fix a couple of typos in memory intrinsic optimization output (NFC)Teresa Johnson1-1/+1
s/instrinsic/intrinsic llvm-svn: 303782
2017-03-16Resubmit r297897: [PGO] Value profile for size of memory intrinsic callsRong Xu1-7/+32
R297897 inadvertently enabled annotation for memop profiling. This new patch fixed it. llvm-svn: 297996
2017-03-16Revert "[PGO] Value profile for size of memory intrinsic calls"Eric Liu1-32/+7
This commit reverts r297897 and r297909. llvm-svn: 297951
2017-03-15[PGO] Value profile for size of memory intrinsic callsRong Xu1-7/+32
This patch adds the value profile support to profile the size parameter of memory intrinsic calls: memcpy, memcmp, and memmov. Differential Revision: http://reviews.llvm.org/D28965 llvm-svn: 297897
2017-03-09[PGO] Refactor profile dumping function for ease of adding other profile kindRong Xu1-35/+56
Refactor the dumping function so that we can add other value profile kind easily. Differential Revision: https://reviews.llvm.org/D30752 llvm-svn: 297399
2016-10-19[PGO] Fix a use-after-move. NFC.Rong Xu1-1/+2
llvm-svn: 284664
2016-10-19[PGO] Fix bogus warning for merging empty llvm profile fileRong Xu1-1/+6
Profile runtime can generate an empty raw profile (when there is no function in the shared library). This empty profile is treated as a text format profile. A test format profile without the flag of "#IR" is thought to be a clang generated profile. So in llvm profile merging, we will get a bogus warning of "Merge IR generated profile with Clang generated profile." The fix here is to skip the empty profile (when the buffer size is 0) for profile merge. Reviewers: vsk, davidxl Differential Revision: http://reviews.llvm.org/D25687 llvm-svn: 284659
2016-10-08Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini1-4/+3
template The core of the change is supposed to be NFC, however it also fixes what I believe was an undefined behavior when calling: va_start(ValueArgs, Desc); with Desc being a StringRef. Differential Revision: https://reviews.llvm.org/D25342 llvm-svn: 283671
2016-09-20[Profile] dump ic value profile value/site-count histogramXinliang David Li1-1/+11
Differential Revision: http://reviews.google.com/D24783 llvm-svn: 282017
2016-08-03llvm-profdata: Clarify the top level helpJustin Bogner1-0/+1
It wasn't very obvious that you're supposed to call help on the subcommands. This should help. llvm-svn: 277678
2016-07-22[llvm-profdata] Bring back reading profile data from STDIN.Benjamin Kramer1-0/+7
This feature was lost in r276197. llvm-svn: 276407
2016-07-21[profdata] Remove constructor that MSVC 2013 pretends to not understand.Benjamin Kramer1-6/+2
No functionality change intended. llvm-svn: 276284
2016-07-20Reapply r276185Xinliang David Li1-10/+33
Fix the test case that should not depend on dir iteration order. llvm-svn: 276197
2016-07-20Revert r276185 -- build bot failure Xinliang David Li1-33/+10
llvm-svn: 276194
2016-07-20[Profile] support directory reading in profile mergingXinliang David Li1-10/+33
Differential Revision: http://reviews.llvm.org/D22560 llvm-svn: 276185
2016-07-19Retry: [llvm-profdata] Speed up merging by using a thread poolVedant Kumar1-23/+117
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-115/+23
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-23/+115
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