1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/docs/CommandGuide
wlei db7fa377e4 [CSSPGO][llvm-profgen] Context-sensitive profile data generation
This stack of changes introduces `llvm-profgen` utility which generates a profile data file from given perf script data files for sample-based PGO. It’s part of(not only) the CSSPGO work. Specifically to support context-sensitive with/without pseudo probe profile, it implements a series of functionalities including perf trace parsing, instruction symbolization, LBR stack/call frame stack unwinding, pseudo probe decoding, etc. Also high throughput is achieved by multiple levels of sample aggregation and compatible format with one stop is generated at the end. Please refer to: https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s for the CSSPGO RFC.

This change supports context-sensitive profile data generation into llvm-profgen. With simultaneous sampling for LBR and call stack, we can identify leaf of LBR sample with calling context from stack sample . During the process of deriving fall through path from LBR entries, we unwind LBR by replaying all the calls and returns (including implicit calls/returns due to inlining) backwards on top of the sampled call stack. Then the state of call stack as we unwind through LBR always represents the calling context of current fall through path.

we have two types of virtual unwinding 1) LBR unwinding and 2) linear range unwinding.
Specifically, for each LBR entry which can be classified into call, return, regular branch, LBR unwinding will replay the operation by pushing, popping or switching leaf frame towards the call stack and since the initial call stack is most recently sampled, the replay should be in anti-execution order, i.e. for the regular case, pop the call stack when LBR is call, push frame on call stack when LBR is return. After each LBR processed, it also needs to align with the next LBR by going through instructions from previous LBR's target to current LBR's source, which we named linear unwinding. As instruction from linear range can come from different function by inlining, linear unwinding will do the range splitting and record counters through the range with same inline context.

With each fall through path from LBR unwinding, we aggregate each sample into counters by the calling context and eventually generate full context sensitive profile (without relying on inlining) to driver compiler's PGO/FDO.

A breakdown of noteworthy changes:
- Added `HybridSample` class as the abstraction perf sample including LBR stack and call stack
* Extended `PerfReader` to implement auto-detect whether input perf script output contains CS profile, then do the parsing. Multiple `HybridSample` are extracted
* Speed up by aggregating  `HybridSample` into `AggregatedSamples`
* Added VirtualUnwinder that consumes aggregated  `HybridSample` and implements unwinding of calls, returns, and linear path that contains implicit call/return from inlining. Ranges and branches counters are aggregated by the calling context.
 Here calling context is string type, each context is a pair of function name and callsite location info, the whole context is like `main:1 @ foo:2 @ bar`.
* Added PorfileGenerater that accumulates counters by ranges unfolding or branch target mapping, then generates context-sensitive function profile including function body, inferring callee's head sample, callsite target samples, eventually records into ProfileMap.

* Leveraged LLVM build-in(`SampleProfWriter`) writer to support different serialization format with no stop
- `getCanonicalFnName` for callee name and name from ELF section
- Added regression test for both unwinding and profile generation

Test Plan:
ninja & ninja check-llvm

Reviewed By: hoy, wenlei, wmi

Differential Revision: https://reviews.llvm.org/D89723
2020-12-07 13:48:58 -08:00
..
bugpoint.rst [docs] [tools] Fix see also links 2019-07-04 21:19:05 +00:00
dsymutil.rst Fix typo in dsymutil.rst 2020-09-10 09:46:10 -07:00
FileCheck.rst [Docs][FileCheck] Small fix. 2020-11-03 07:08:51 -08:00
index.rst [llvm-profgen] [docs] Fix invalid header. Add to ToC. NFC. 2020-11-26 10:45:05 +01:00
lit.rst fix doc typo to cycle bots 2020-08-06 21:02:41 -04:00
llc.rst [llc] (almost) remove --print-machineinstrs 2020-07-20 10:43:28 -07:00
lli.rst [llc] (almost) remove --print-machineinstrs 2020-07-20 10:43:28 -07:00
llvm-addr2line.rst llvm-addr2line: assume addresses on the command line are hexadecimal rather than attempting to guess the base based on the form of the number. 2020-04-16 16:16:21 -07:00
llvm-ar.rst [docs][llvm-ar] Update llvm-ar command guide 2019-10-21 13:13:31 +00:00
llvm-as.rst [docs] [tools] Fix see also links 2019-07-04 21:19:05 +00:00
llvm-bcanalyzer.rst [docs] [tools] Fix see also links 2019-07-04 21:19:05 +00:00
llvm-config.rst [docs] [NFC] Removed excess spacing 2019-07-04 04:41:06 +00:00
llvm-cov.rst Revert "[llvm-cov] Add option to whitelist filenames" 2019-10-29 22:38:38 -07:00
llvm-cxxfilt.rst [docs][llvm-cxxfilt] Document --no-strip-underscore option 2020-05-01 11:03:06 +01:00
llvm-cxxmap.rst llvm-cxxmap: fix support for remapping non-mangled names. 2019-12-18 10:47:02 -08:00
llvm-diff.rst [docs] [NFC] Removed excess spacing 2019-07-04 04:41:06 +00:00
llvm-dis.rst [docs] [tools] Fix see also links 2019-07-04 21:19:05 +00:00
llvm-dwarfdump.rst [docs][llvm-dwarfdump] Fix the warnings during docs-llvm-html buil 2020-06-25 11:04:28 +02:00
llvm-exegesis-analysis.png
llvm-exegesis.rst [llvm-exegesis][doc] Remove old FIXME. 2020-10-28 10:53:23 +01:00
llvm-extract.rst [docs] Fix typos 2020-08-09 19:31:49 -07:00
llvm-install-name-tool.rst [llvm-install-name-tool] Add -delete_all_rpaths option 2020-10-13 00:45:57 -07:00
llvm-lib.rst [docs] [NFC] Removed excess spacing 2019-07-04 04:41:06 +00:00
llvm-libtool-darwin.rst [llvm-libtool-darwin] Address post-commit feedback 2020-08-25 15:04:23 -07:00
llvm-link.rst [docs] [NFC] Removed excess spacing 2019-07-04 04:41:06 +00:00
llvm-lipo.rst doc: use the right url to bugzilla 2020-03-22 22:49:40 +01:00
llvm-locstats.rst [llvm-locstats] Add the --compare option 2020-01-15 14:35:29 +01:00
llvm-mca.rst [Docs] fix typos for llvm-mca; NFC 2020-06-07 11:14:24 -04:00
llvm-nm.rst llvm-nm: Implement --special-syms. 2020-06-22 13:05:47 -07:00
llvm-objcopy.rst [docs][llvm-objcopy] Update --output-target text with right defaults 2020-05-05 11:22:56 +01:00
llvm-objdump.rst [llvm-objdump] Document --mattr=help in --help output 2020-11-30 12:52:54 +00:00
llvm-pdbutil.rst [docs][tools] Add missing "program" tags to rst files 2019-06-27 13:24:46 +00:00
llvm-profdata.rst Supplement instr profile with sample profile. 2020-07-27 20:17:40 -07:00
llvm-profgen.rst [CSSPGO][llvm-profgen] Context-sensitive profile data generation 2020-12-07 13:48:58 -08:00
llvm-ranlib.rst Fix some regressions caused by r369553 on old versions of Debian and Ubuntu 2019-08-22 12:16:08 +00:00
llvm-readelf.rst [llvm-readelf] - Implement --section-details option. 2020-10-27 13:29:39 +03:00
llvm-readobj.rst [llvm-readobj] Add --coff-tls-directory flag to print TLS Directory & test. 2020-10-08 01:53:15 -07:00
llvm-size.rst doc: use the right url to bugzilla 2020-03-22 22:49:40 +01:00
llvm-stress.rst [docs] [NFC] Removed excess spacing 2019-07-04 04:41:06 +00:00
llvm-strings.rst doc: use the right url to bugzilla 2020-03-22 22:49:40 +01:00
llvm-strip.rst [llvm-objcopy][MachO] Add support for removing Swift symbols 2020-05-26 16:49:56 -07:00
llvm-symbolizer.rst Recommit "[llvm-symbolizer] Switch to using native symbolizer by default on Windows" 2020-11-30 17:36:12 -08:00
locstats-compare.png [llvm-locstats] Add the --compare option 2020-01-15 14:35:29 +01:00
locstats-draw-plot.png [llvm-locstats] Fix the docs 2020-01-15 12:32:01 +01:00
opt.rst [docs] [NFC] Removed excess spacing 2019-07-04 04:41:06 +00:00
tblgen.rst [TableGen] Improve a couple of descriptions in the command guide 2020-11-15 09:59:59 -05:00