llvm-project/llvm/test/tools/llvm-profdata
Hongtao Yu 5740bb801a [CSSPGO] Use nested context-sensitive profile.
CSSPGO currently employs a flat profile format for context-sensitive profiles. Such a flat profile allows for precisely manipulating contexts that is either inlined or not inlined. This is a benefit over the nested profile format used by non-CS AutoFDO. A downside of this is the longer build time due to parsing the indexing the full CS contexts.

For a CS flat profile, though only the context profiles relevant to a module are loaded when that module is compiled, the cost to figure out what profiles are relevant is noticeably high when there're many contexts,  since the sample reader will need to scan all context strings anyway. On the contrary, a nested function profile has its related inline subcontexts isolated from other unrelated contexts. Therefore when compiling a set of functions, unrelated contexts will never need to be scanned.

In this change we are exploring using nested profile format for CSSPGO. This is expected to work based on an assumption that with a preinliner-computed profile all contexts are precomputed and expected to be inlined by the compiler. Contexts not expected to be inlined will be cut off and returned to corresponding base profiles (for top-level outlined functions). This naturally forms a nested profile where all nested contexts are expected to be inlined. The compiler will less likely optimize on derived contexts that are not precomputed.

A CS-nested profile will look exactly the same with regular nested profile except that each nested profile can come with an attributes. With pseudo probes,  a nested profile shown as below can also have a CFG checksum.

```

main:1968679:12
 2: 24
 3: 28 _Z5funcAi:18
 3.1: 28 _Z5funcBi:30
 3: _Z5funcAi:1467398
  0: 10
  1: 10 _Z8funcLeafi:11
  3: 24
  1: _Z8funcLeafi:1467299
   0: 6
   1: 6
   3: 287884
   4: 287864 _Z3fibi:315608
   15: 23
   !CFGChecksum: 138828622701
   !Attributes: 2
  !CFGChecksum: 281479271677951
  !Attributes: 2
```

Specific work included in this change:
- A recursive profile converter to convert CS flat profile to nested profile.
- Extend function checksum and attribute metadata to be stored in nested way for text profile and extbinary profile.
- Unifiy sample loader inliner path for CS and preinlined nested profile.
 - Changes in the sample loader to support probe-based nested profile.

I've seen promising results regarding build time. A nested profile can result in a 20% shorter build time than a CS flat profile while keep an on-par performance. This is with -duplicate-contexts-into-base=1.

Test Plan:

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D115205
2021-12-14 14:40:25 -08:00
..
Inputs [CSSPGO] Use nested context-sensitive profile. 2021-12-14 14:40:25 -08:00
binary-ids-padding.test [InstrProfData] Bump the raw profile version to 8 2021-10-05 09:57:56 -07:00
c-general.test [profile] Add binary id into profiles 2021-07-23 00:19:12 +00:00
compact-sample.proftext
compat.proftext
count-mismatch.proftext [llvm-profdata] Make diagnostics consistent with the (no capitalization, no period) style 2021-06-19 14:54:25 -07:00
cs-sample-nested-profile.test [CSSPGO] Use nested context-sensitive profile. 2021-12-14 14:40:25 -08:00
cs-sample-profile.test [llvm-profdata] Print out section flags for FunctionMetadata section 2021-11-02 17:59:22 -07:00
cs-sample-trimmer.test [CSSPGO] Use nested context-sensitive profile. 2021-12-14 14:40:25 -08:00
csprof-dump.test
cutoff.test
forward-compatible.test Add "REQUIRES: zlib" in forward-compatible.test since it handles compressed file. 2021-09-24 15:35:07 -07:00
gcc-gcov-sample-profile.test
general.proftext
hash-mismatch.proftext
header-directives.test
inline-samples.test
input-dir.test
input-filenames.test
instr-remap.test
insufficient-binary-ids-size.test [InstrProfData] Bump the raw profile version to 8 2021-10-05 09:57:56 -07:00
invalid-profdata.test [llvm-profdata] Make diagnostics consistent with the (no capitalization, no period) style 2021-06-19 14:54:25 -07:00
invalid-profile-gen-zeros.proftext [llvm-profdata] Make diagnostics consistent with the (no capitalization, no period) style 2021-06-19 14:54:25 -07:00
large-binary-id-size.test [compiler-rt] Fix diagnostic in InstrProfError 2021-11-09 20:30:03 +00:00
lit.local.cfg
malformed-not-space-for-another-header.test [compiler-rt] Fix diagnostic in InstrProfError 2021-11-09 20:30:03 +00:00
malformed-num-counters-zero.test [compiler-rt] Fix diagnostic in InstrProfError 2021-11-09 20:30:03 +00:00
malformed-ptr-to-counter-array.test [compiler-rt] Fix diagnostic in InstrProfError 2021-11-09 20:30:03 +00:00
memop-size-prof.proftext
memprof-basic.test [memprof] Align each rawprofile section to 8b. 2021-11-30 20:12:43 -08:00
memprof-multi.test [memprof] Disallow memprof profile reader tests on non-x86 archs. 2021-11-30 12:27:06 -08:00
merge-incompatible.test
merge-probe-profile.test [llvm-profdata] Print out section flags for FunctionMetadata section 2021-11-02 17:59:22 -07:00
merge_empty_profile.test
misaligned-binary-ids-size.test [InstrProfData] Bump the raw profile version to 8 2021-10-05 09:57:56 -07:00
multiple-inputs.test
multiple-profdata-merge.test
nocompress.test [test] Fix nocompress.test 2021-06-19 16:27:53 -07:00
overflow-instr.test [llvm-profdata] Make diagnostics consistent with the (no capitalization, no period) style 2021-06-19 14:54:25 -07:00
overflow-sample.test
overlap.test
overlap_cs.test
overlap_vp.test
profile-symbol-list-compress.test
profile-symbol-list.test
raw-32-bits-be.test [InstrProfData] Bump the raw profile version to 8 2021-10-05 09:57:56 -07:00
raw-32-bits-le.test [InstrProfData] Bump the raw profile version to 8 2021-10-05 09:57:56 -07:00
raw-64-bits-be.test [InstrProfData] Bump the raw profile version to 8 2021-10-05 09:57:56 -07:00
raw-64-bits-le.test [InstrProfData] Bump the raw profile version to 8 2021-10-05 09:57:56 -07:00
raw-magic-but-no-header.test [llvm-profdata] Make diagnostics consistent with the (no capitalization, no period) style 2021-06-19 14:54:25 -07:00
raw-two-profiles.test [InstrProfData] Bump the raw profile version to 8 2021-10-05 09:57:56 -07:00
roundtrip-compress.test
roundtrip.test
same-filename.test
sample-fs.test [SampleFDO] Set ProfileIsFS bit properly from the internal option 2021-08-25 09:07:34 -07:00
sample-hot-func-list.test [llvm-profdata] Extend support of --topn to sample profiles 2021-09-24 16:42:46 -07:00
sample-overlap.test
sample-profile-basic.test
sample-remap.test
sample-summary.test
show-instr-level.test
show-prof-info.test
suppl-instr-with-sample.test
text-dump.test [llvm-profdata] Allow omission of -o for --text output 2021-06-21 12:01:57 -07:00
text-format-errors.test [memprof] Extend llvm-profdata to display MemProf profile summaries. 2021-11-30 10:45:26 -08:00
threaded-count-mismatch.test [llvm-profdata] Make diagnostics consistent with the (no capitalization, no period) style 2021-06-19 14:54:25 -07:00
value-prof.proftext
weight-instr.test [llvm-profdata] Make diagnostics consistent with the (no capitalization, no period) style 2021-06-19 14:54:25 -07:00
weight-sample.test [llvm-profdata] Make diagnostics consistent with the (no capitalization, no period) style 2021-06-19 14:54:25 -07:00