aboutsummaryrefslogtreecommitdiff
path: root/llvm/docs/CommandGuide/llvm-profdata.rst
AgeCommit message (Collapse)AuthorFilesLines
2025-08-01[llvm] Proofread *.rst (#151087)Kazu Hirata1-1/+1
This patch hyphenates words that are used as adjecives, such as: - architecture specific - human readable - implementation defined - language independent - language specific - machine readable - machine specific - target independent - target specific
2024-09-06[InstrProf] Add debuginfod correlation support (#106606)gulfemsavrun1-0/+19
This patch adds debuginfod support into llvm-profdata to find the assosicated executable by a build id in a raw profile to correlate a profile with a provided correlation kind (debug-info or binary).
2024-08-28[llvm-profdata] Enabled functionality to write split-layout profile (#101795)William Junda Huang1-0/+6
Using the flag `-split_layout` in llvm-profdata merge, the output profile can write profiles with and without inlined function into two different extbinary sections (and their FuncOffsetTable too). The section without inlined functions are marked with `SecFlagFlat` and is skipped by ThinLTO because it provides no useful info. The split layout feature was already implemented in SampleProfWriter but previously there is no way to use it from llvm-profdata.
2024-01-23Added feature in llvm-profdata merge to filter functions from the profile ↵William Junda Huang1-0/+10
(#78378) `--function=<regex>` Include functions matching regex in the output `--no-function=<regex>` Exclude functions matching regex from the output If both are specified, `--no-function` has a higher precedence if a function name matches both filters
2023-12-14[Profile] Add binary profile correlation for code coverage. (#69493)Zequan Wu1-4/+11
## Motivation Since we don't need the metadata sections at runtime, we can somehow offload them from memory at runtime. Initially, I explored [debug info correlation](https://discourse.llvm.org/t/instrprofiling-lightweight-instrumentation/59113), which is used for PGO with value profiling disabled. However, it currently only works with DWARF and it's be hard to add such artificial debug info for every function in to CodeView which is used on Windows. So, offloading profile metadata sections at runtime seems to be a platform independent option. ## Design The idea is to use new section names for profile name and data sections and mark them as metadata sections. Under this mode, the new sections are non-SHF_ALLOC in ELF. So, they are not loaded into memory at runtime and can be stripped away as a post-linking step. After the process exits, the generated raw profiles will contains only headers + counters. llvm-profdata can be used correlate raw profiles with the unstripped binary to generate indexed profile. ## Data For chromium base_unittests with code coverage on linux, the binary size overhead due to instrumentation reduced from 64M to 38.8M (39.4%) and the raw profile files size reduce from 128M to 68M (46.9%) ``` $ bloaty out/cov/base_unittests.stripped -- out/no-cov/base_unittests.stripped FILE SIZE VM SIZE -------------- -------------- +121% +30.4Mi +121% +30.4Mi .text [NEW] +14.6Mi [NEW] +14.6Mi __llvm_prf_data [NEW] +10.6Mi [NEW] +10.6Mi __llvm_prf_names [NEW] +5.86Mi [NEW] +5.86Mi __llvm_prf_cnts +95% +1.75Mi +95% +1.75Mi .eh_frame +108% +400Ki +108% +400Ki .eh_frame_hdr +9.5% +211Ki +9.5% +211Ki .rela.dyn +9.2% +95.0Ki +9.2% +95.0Ki .data.rel.ro +5.0% +87.3Ki +5.0% +87.3Ki .rodata [ = ] 0 +13% +47.0Ki .bss +40% +1.78Ki +40% +1.78Ki .got +12% +1.49Ki +12% +1.49Ki .gcc_except_table [ = ] 0 +65% +1.23Ki .relro_padding +62% +1.20Ki [ = ] 0 [Unmapped] +13% +448 +19% +448 .init_array +8.8% +192 [ = ] 0 [ELF Section Headers] +0.0% +136 +0.0% +80 [7 Others] +0.1% +96 +0.1% +96 .dynsym +1.2% +96 +1.2% +96 .rela.plt +1.5% +80 +1.2% +64 .plt [ = ] 0 -99.2% -3.68Ki [LOAD #5 [RW]] +195% +64.0Mi +194% +64.0Mi TOTAL $ bloaty out/cov-cor/base_unittests.stripped -- out/no-cov/base_unittests.stripped FILE SIZE VM SIZE -------------- -------------- +121% +30.4Mi +121% +30.4Mi .text [NEW] +5.86Mi [NEW] +5.86Mi __llvm_prf_cnts +95% +1.75Mi +95% +1.75Mi .eh_frame +108% +400Ki +108% +400Ki .eh_frame_hdr +9.5% +211Ki +9.5% +211Ki .rela.dyn +9.2% +95.0Ki +9.2% +95.0Ki .data.rel.ro +5.0% +87.3Ki +5.0% +87.3Ki .rodata [ = ] 0 +13% +47.0Ki .bss +40% +1.78Ki +40% +1.78Ki .got +12% +1.49Ki +12% +1.49Ki .gcc_except_table +13% +448 +19% +448 .init_array +0.1% +96 +0.1% +96 .dynsym +1.2% +96 +1.2% +96 .rela.plt +1.2% +64 +1.2% +64 .plt +2.9% +64 [ = ] 0 [ELF Section Headers] +0.0% +40 +0.0% +40 .data +1.2% +32 +1.2% +32 .got.plt +0.0% +24 +0.0% +8 [5 Others] [ = ] 0 -22.9% -872 [LOAD #5 [RW]] -74.5% -1.44Ki [ = ] 0 [Unmapped] [ = ] 0 -76.5% -1.45Ki .relro_padding +118% +38.8Mi +117% +38.8Mi TOTAL ``` A few things to note: 1. llvm-profdata doesn't support filter raw profiles by binary id yet, so when a raw profile doesn't belongs to the binary being digested by llvm-profdata, merging will fail. Once this is implemented, llvm-profdata should be able to only merge raw profiles with the same binary id as the binary and discard the rest (with mismatched/missing binary id). The workflow I have in mind is to have scripts invoke llvm-profdata to get all binary ids for all raw profiles, and selectively choose the raw pnrofiles with matching binary id and the binary to llvm-profdata for merging. 2. Note: In COFF, currently they are still loaded into memory but not used. I didn't do it in this patch because I noticed that `.lcovmap` and `.lcovfunc` are loaded into memory. A separate patch will address it. 3. This should works with PGO when value profiling is disabled as debug info correlation currently doing, though I haven't tested this yet.
2023-10-31Revert "[Profile] Refactor profile correlation. (#70712)"Zequan Wu1-2/+2
This reverts commit 4b383d0af93136b80841fc140da0823dfc441dd4.
2023-10-31[Profile] Refactor profile correlation. (#70712)Zequan Wu1-2/+2
Refactor some code from https://github.com/llvm/llvm-project/pull/69493. Rebase of https://github.com/llvm/llvm-project/pull/69656 on top of main as it was messed up.
2023-06-06[InstrProf] Use BalancedPartitioning to order temporal profiling trace dataEllis Hoag1-0/+35
In [0] we described an algorithm called //BalancedPartitioning// (bp) to consume function traces [1] and compute a function order that reduces the number of page faults during startup. This patch adds the `order` command to the `llvm-profdata` tool which uses bp to output a function order that can be passed to the linker via `--symbol-ordering-file=`. Special thanks to Sergey Pupyrev and Julian Mestre for designing this balanced partitioning algorithm. [0] https://discourse.llvm.org/t/rfc-temporal-profiling-extension-for-irpgo/68068 [1] https://reviews.llvm.org/D147287 Reviewed By: spupyrev Differential Revision: https://reviews.llvm.org/D147812
2023-04-13[InstrProf][Temporal] Add weight field to tracesEllis Hoag1-0/+12
As discussed in [0], add a `weight` field to temporal profiling traces found in profiles. This allows users to use the `--weighted-input=` flag in the `llvm-profdata merge` command to weight traces from different scenarios differently. Note that this is a breaking change, but since [1] landed very recently and there is no way to "use" this trace data, there should be no users of this feature. We believe it is acceptable to land this change without bumping the profile format version. [0] https://reviews.llvm.org/D147812#4259507 [1] https://reviews.llvm.org/D147287 Reviewed By: snehasish Differential Revision: https://reviews.llvm.org/D148150
2023-03-30fix docs warning in llvm-profdata.rstwlei1-2/+2
2023-03-30[AutoFDO] Use flattened profiles for profile staleness metricswlei1-0/+6
For profile staleness report, before it only counts for the top-level function samples in the nested profile, the samples in the inlinees are ignored. This could affect the quality of the metrics when there are heavily inlined functions. This change adds a feature to flatten the nested profile and we're changing to use flatten profile as the input for stale profile detection and matching. Example for profile flattening: ``` Original profile: _Z3bazi:20301:1000 1: 1000 3: 2000 5: inline1:1600 1: 600 3: inline2:500 1: 500 Flattened profile: _Z3bazi:18701:1000 1: 1000 3: 2000 5: 600 inline1:600 inline1:1100:600 1: 600 3: 500 inline2: 500 inline2:500:500 1: 500 ``` This feature could be useful for offline analysis, like understanding the hotness of each individual function. So I'm adding the support to `llvm-profdata merge` under `--gen-flattened-profile`. Reviewed By: hoy, wenlei Differential Revision: https://reviews.llvm.org/D146452
2022-10-07[llvm-profdata] Rename show flag to --show-formatEllis Hoag1-1/+1
In https://reviews.llvm.org/D135127 we created the show flag `--output-format` which was confusing because it behaved differently than the same flag in the merge command. So, rename the flag to `--show-format`. This also allows us to add the `text` option to mean "normal text output" rather than "text-encoded profiles" like it does for the merge command. Reviewed By: wenlei Differential Revision: https://reviews.llvm.org/D135467
2022-10-07[llvm-profdata] Add --output-format optionEllis Hoag1-0/+4
Add `--output-format` option for the `llvm-profdata show` command to select the type of output. The existing `--text` flag is used to emit text encoded profiles. To avoid confusion, `--output-format=text-encoding` indicates that the output will be profiles encoded in the text format, and `--output-format=text` indicates the default text output that doesn't necessarily represent a profile. `--output-format=json` is an alias for `--json` and `--output-format=yaml` will be used in D134770. Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D135127
2022-10-06[llvm-profdata] Add some missing options to docsEllis Hoag1-0/+11
I forgot to add documentation for these options when I added them to the `show` command, so add them now. Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D135383
2022-10-06[InstrProf] Add version into llvm-profdataGulfem Savrun Yeniceri1-0/+8
This patch adds support of printing profile version into llvm-profdata which was proposed in: https://discourse.llvm.org/t/llvm-profdata-failure-guarantees-for-code-coverage/64924 Differential Revision: https://reviews.llvm.org/D135317
2022-05-05Fix "the the" typo in documentation and user facing stringsBrian Tracy1-1/+1
There are many more instances of this pattern, but I chose to limit this change to .rst files (docs), anything in libcxx/include, and string literals. These have the highest chance of being seen by end users. Reviewed By: #libc, Mordante, martong, ldionne Differential Revision: https://reviews.llvm.org/D124708
2021-12-30[docs][llvm-profdata] Prefer double-dash long optionsFangrui Song1-45/+45
To match the `--help` message and most other utilities. While here, change `option:: -output=output` to `option:: --output=<output>` and omit the value name for the short options (convention of other utilities). Reviewed By: snehasish Differential Revision: https://reviews.llvm.org/D116353
2021-12-28[llvm-profdata][docs] Use `` instead of `Fangrui Song1-3/+3
2021-12-28[llvm-profdata] Make -debug-info visibleKyungwoo Lee1-0/+7
Add the option comment in .rst. Reviewed By: ellis Differential Revision: https://reviews.llvm.org/D116348
2021-11-15[NFC] Trim trailing whitespace in *.rstShao-Ce SUN1-2/+2
2020-07-27Supplement instr profile with sample profile.Wei Mi1-0/+24
PGO profile is usually more precise than sample profile. However, PGO profile needs to be collected from loadtest and loadtest may not be representative enough to the production workload. Sample profile collected from production can be used as a supplement -- for functions cold in loadtest but warm/hot in production, we can scale up the related function in PGO profile if the function is warm or hot in sample profile. The implementation contains changes in compiler side and llvm-profdata side. Given an instr profile and a sample profile, for a function cold in PGO profile but warm/hot in sample profile, llvm-profdata will either mark all the counters in the profile to be -1 or scale up the max count in the function to be above hot threshold, depending on the zero counter ratio in the profile. The assumption is if there are too many counters being zero in the function profile, the profile is more likely to cause harm than good, then llvm-profdata will mark all the counters to be -1 indicating the function is hot but the profile is unaccountable. In compiler side, if a function profile with all -1 counters is seen, the function entry count will be set to be above hot threshold but its internal profile will be dropped. In the long run, it may be useful to let compiler support using PGO profile and sample profile at the same time, but that requires more careful design and more substantial changes to make two profiles work seamlessly. The patch here serves as a simple intermediate solution. Differential Revision: https://reviews.llvm.org/D81981
2020-05-14[llvm-profdata] Update CommandGuideWei Mi1-0/+39
Add a bunch of SampleFDO related flags added recently into llvm-profdata to its command guide. Differential Revision: https://reviews.llvm.org/D79911
2020-04-13Typos correction.SCOTT-HAMILTON1-1/+1
2019-09-03[llvm-profdata] Add mode to recover from profile read failuresVedant Kumar1-0/+8
Add a mode in which profile read errors are not immediately treated as fatal. In this mode, merging makes forward progress and reports failure only if no inputs can be read. Differential Revision: https://reviews.llvm.org/D66985 llvm-svn: 370827
2019-07-04[docs] [NFC] Removed excess spacingAlex Brachet1-1/+0
Summary: Removed excess new lines from documentations. As far as I can tell, it seems as though restructured text is agnostic to new lines, the use of new lines was inconsistent and had no effect on how the files were being displayed. Reviewers: jhenderson, rupprecht, JDevlieghere Reviewed By: jhenderson Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63971 llvm-svn: 365105
2019-06-27[docs][tools] Add missing "program" tags to rst filesJames Henderson1-0/+2
Sphinx allows for definitions of command-line options using `.. option <name>` and references to those options via `:option:<name>`. However, it looks like there is no scoping of these options by default, meaning that links can end up pointing to incorrect documents. See for example the llvm-mca document, which contains references to -o that, prior to this patch, pointed to a different document. What's worse is that these links appear to be non-deterministic in which one is picked (on my machine, some references end up pointing to opt, whereas on the live docs, they point to llvm-dwarfdump, for example). The fix is to add the .. program <name> tag. This essentially namespaces the options (definitions and references) to the named program, ensuring that the links are kept correct. Reviwed by: andreadb Differential Revision: https://reviews.llvm.org/D63873 llvm-svn: 364538
2019-04-30[llvm-profdata] Fix indentation error in docs. NFC.Rong Xu1-1/+1
llvm-svn: 359625
2019-04-30[llvm-profdata] Fix indentation error. NFCRong Xu1-1/+1
llvm-svn: 359619
2019-04-30[llvm-profdata] Add overlap command to compute similarity b/w two profile filesRong Xu1-0/+67
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-04-18[llvm-profdata] Fix one bad format in llvm-profdata CommandGuide doc. NFCRong Xu1-0/+1
llvm-svn: 358643
2019-02-28[PGO] Context sensitive PGO (part 2)Rong Xu1-0/+4
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-01-08[llvm-profdata] add value-cutoff functionality in show commandRong Xu1-1/+11
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-11/+1
Will re-commit it using the correct commit message. llvm-svn: 350670
2019-01-07[PGO] Use SourceFileName rather module name in PGOFuncNameRong Xu1-1/+11
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-0/+10
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
2017-07-11[ProfileData] Add new option to dump topn hottest functionsXinliang David Li1-0/+6
Differential Revision: http://reviews.llvm.org/D35155 llvm-svn: 307702
2017-03-16Resubmit r297897: [PGO] Value profile for size of memory intrinsic callsRong Xu1-0/+4
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-4/+0
This commit reverts r297897 and r297909. llvm-svn: 297951
2017-03-15[PGO] Value profile for size of memory intrinsic callsRong Xu1-0/+4
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
2016-07-19Retry: [llvm-profdata] Speed up merging by using a thread poolVedant Kumar1-0/+5
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-5/+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/+5
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-06-09[docs] Fix indentation for a tool optionVedant Kumar1-1/+1
llvm-svn: 272309
2016-06-07Retry^4 "[llvm-profdata] Add option to ingest filepaths from a file"Vedant Kumar1-0/+9
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-9/+0
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-0/+9
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-9/+0
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-0/+9
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-9/+0
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-03[llvm-profdata] Add option to ingest filepaths from a fileVedant Kumar1-0/+9
Differential Revision: http://reviews.llvm.org/D20980 llvm-svn: 271709