llvm-project/llvm/test/Transforms/SampleProfile
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
branch.ll [test] Fixup tests with -analyze in llvm/test/Transforms 2021-09-04 16:45:51 -07:00
calls.ll [test] Fixup tests with -analyze in llvm/test/Transforms 2021-09-04 16:45:51 -07:00
cold-indirect-call.ll
compressed-profile-symbol-list.ll
cov-zero-samples.ll
coverage-warning.ll
csspgo-import-list.ll [CSSPGO] Turn on Profi by default 2021-12-02 17:56:38 -08:00
csspgo-inline-debug.ll
csspgo-inline-icall.ll [CSSPGO] Enable loading MD5 CS profile. 2021-09-01 09:19:47 -07:00
csspgo-inline.ll [CSSPGO] Use nested context-sensitive profile. 2021-12-14 14:40:25 -08:00
csspgo-summary.ll [CSSPGO] Turn on Profi by default 2021-12-02 17:56:38 -08:00
csspgo-use-preinliner.ll [CSSPGO] Use nested context-sensitive profile. 2021-12-14 14:40:25 -08:00
ctxsplit.ll
discriminator.ll [test] Fixup tests with -analyze in llvm/test/Transforms 2021-09-04 16:45:51 -07:00
early-inline.ll
entry_counts.ll
entry_counts_cold.ll
entry_counts_missing_dbginfo.ll
flattened.ll
fnptr.ll [test] Fixup tests with -analyze in llvm/test/Transforms 2021-09-04 16:45:51 -07:00
fsafdo_test.ll [test] Fixup tests with -analyze in llvm/test/Transforms 2021-09-04 16:45:51 -07:00
function_metadata.ll [SampleProfile] Add all callsites to AllCandidates if InlineReplay is in effect 2021-10-29 12:04:52 -07:00
gcc-simple.ll
indirect-call-gcc.ll
indirect-call.ll
inline-act.ll
inline-callee-update.ll
inline-cold-callsite-samplepgo.ll
inline-cold.ll
inline-combine.ll
inline-coverage.ll
inline-mergeprof-dup.ll
inline-mergeprof.ll [CSSPGO] Use nested context-sensitive profile. 2021-12-14 14:40:25 -08:00
inline-noduplicate.ll Fix getInlineCost with ComputeFullInlineCost enabled 2021-10-14 17:41:41 -07:00
inline-replay.ll [InlineAdvisor] Add fallback/format switches and negative remark processing to Replay Inliner 2021-10-29 12:32:03 -07:00
inline-stats.ll
inline-topdown.ll
inline.ll [CSSPGO] Use nested context-sensitive profile. 2021-12-14 14:40:25 -08:00
merge-function-attributes.ll [AFDO] Require x86_64-linux in a testcase 2021-07-10 07:52:20 -07:00
nodebug-error.ll
nodebug.ll
nolocinfo.ll
norepeated-icp-2.ll
norepeated-icp-3.ll
norepeated-icp-4.ll
norepeated-icp.ll
offset.ll [test] Fixup tests with -analyze in llvm/test/Transforms 2021-09-04 16:45:51 -07:00
profile-context-order.ll [CSSPGO] Sorting nodes in a cycle of profiled call graph. 2021-11-30 09:01:08 -08:00
profile-context-tracker-debug.ll [CSSPGO] Split context string to deduplicate function name used in the context. 2021-08-30 20:09:29 -07:00
profile-context-tracker.ll [CSSPGO] Turn on Profi by default 2021-12-02 17:56:38 -08:00
profile-correlation-irreducible-loops.ll [test] Fixup tests with -analyze in llvm/test/Transforms 2021-09-04 16:45:51 -07:00
profile-format-compress.ll [SamplePGO] Fix callsite sample lookup to use dwarf names when dwarf linkage name isn't available. 2021-11-01 21:24:33 -07:00
profile-format.ll [SamplePGO] Fix callsite sample lookup to use dwarf names when dwarf linkage name isn't available. 2021-11-01 21:24:33 -07:00
profile-inference-islands.ll profi - a flow-based profile inference algorithm: Part II (out of 3) 2021-12-02 11:04:21 -08:00
profile-inference-noprobes.ll profi - a flow-based profile inference algorithm: Part III (out of 3) 2021-12-02 12:01:30 -08:00
profile-inference-rebalance.ll profi - a flow-based profile inference algorithm: Part III (out of 3) 2021-12-02 12:01:30 -08:00
profile-inference.ll profi - a flow-based profile inference algorithm: Part III (out of 3) 2021-12-02 12:01:30 -08:00
profile-sample-accurate.ll
profile-topdown-order.ll
propagate.ll [test] Fixup tests with -analyze in llvm/test/Transforms 2021-09-04 16:45:51 -07:00
pseudo-probe-cse.ll [CSSPGO] Unblock optimizations with pseudo probe instrumentation part 3. 2021-10-12 09:44:12 -07:00
pseudo-probe-dangle.ll [CSSPGO] Set PseudoProbeInserter as a default pass. 2021-09-22 09:09:48 -07:00
pseudo-probe-dangle2.ll [CSSPGO] Undoing the concept of dangling pseudo probe 2021-06-18 15:14:11 -07:00
pseudo-probe-dangle3.ll [CSSPGO] Undoing the concept of dangling pseudo probe 2021-06-18 15:14:11 -07:00
pseudo-probe-discriminator.ll [CSSPGO] Allow the use of debug-info-for-profiling and pseudo-probe-for-profiling together 2021-08-12 08:52:49 -07:00
pseudo-probe-emit-inline.ll [CSSPGO] Set PseudoProbeInserter as a default pass. 2021-09-22 09:09:48 -07:00
pseudo-probe-emit.ll [CSSPGO] Set PseudoProbeInserter as a default pass. 2021-09-22 09:09:48 -07:00
pseudo-probe-icp-factor.ll
pseudo-probe-inline.ll [CSSPGO] Turn on Profi by default 2021-12-02 17:56:38 -08:00
pseudo-probe-instcombine.ll
pseudo-probe-instsched.ll [CSSPGO] Set PseudoProbeInserter as a default pass. 2021-09-22 09:09:48 -07:00
pseudo-probe-loop-deletion.ll [CSSPGO] Unblock optimizations with pseudo probe instrumentation part 3. 2021-10-12 09:44:12 -07:00
pseudo-probe-memset.ll
pseudo-probe-peep.ll
pseudo-probe-profile-metadata-2.ll
pseudo-probe-profile-metadata.ll
pseudo-probe-profile.ll
pseudo-probe-selectionDAG.ll
pseudo-probe-slotindex.ll
pseudo-probe-twoaddr.ll
pseudo-probe-update-2.ll
pseudo-probe-update.ll
pseudo-probe-verify.ll
pseudo-probe.mir [X86] Update RET/LRET instruction to use the same naming convention as IRET (PR36876). NFC 2021-11-07 15:06:54 +00:00
remap-2.ll
remap.ll
remarks-hotness.ll [NewPM][test] Avoid using -enable-new-pm=1 since -passes implies new PM 2021-10-20 15:16:17 +02:00
remarks.ll [InlineAdvisor] Add single quotes around caller/callee names 2021-08-10 11:51:31 -07:00
section-accurate-samplepgo.ll
summary.ll
syntax.ll
uncompressed-profile-symbol-list.ll
uniqname.ll
use-sample-profile-attr.ll
warm-inline-instance.ll