(The profile format change is split into a standalone change into https://github.com/llvm/llvm-project/pull/81691) * For InstrFDO value profiling, implement instrumentation and lowering for virtual table address. * This is controlled by `-enable-vtable-value-profiling` and off by default. * When the option is on, raw profiles will carry serialized `VTableProfData` structs and compressed vtables as payloads. * Implement profile reader and writer support * Raw profile reader is used by `llvm-profdata` but not compiler. Raw profile reader will construct InstrProfSymtab with symbol names, and map profiled runtime address to vtable symbols. * Indexed profile reader is used by `llvm-profdata` and compiler. When initialized, the reader stores a pointer to the beginning of in-memory compressed vtable names and the length of string. When used in `llvm-profdata`, reader decompress the string to show symbols of a profiled site. When used in compiler, string decompression doesn't happen since IR is used to construct InstrProfSymtab. * Indexed profile writer collects the list of vtable names, and stores that to index profiles. * Text profile reader and writer support are added but mostly follow the implementation for indirect-call value type. * `llvm-profdata show -show-vtables <args> <profile>` is implemented. rfc in https://discourse.llvm.org/t/rfc-dynamic-type-profiling-and-optimizations-in-llvm/74600#pick-instrumentation-points-and-instrument-runtime-types-7
84 lines
3.4 KiB
Plaintext
84 lines
3.4 KiB
Plaintext
; RUN: rm -rf %t && mkdir %t && cd %t
|
|
|
|
; Generate indexed profiles from text profiles
|
|
RUN: llvm-profdata merge %S/Inputs/vtable-value-prof.proftext -o indexed.profdata
|
|
|
|
; Show indexed profiles
|
|
RUN: llvm-profdata show --function=main --ic-targets --show-vtables indexed.profdata | FileCheck %s --check-prefix=INDEXED
|
|
|
|
; Show text profiles
|
|
RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text %S/Inputs/vtable-value-prof.proftext | FileCheck %s --check-prefix=ICTEXT
|
|
|
|
; Convert indexed profiles to its textual output and show it.
|
|
RUN: llvm-profdata merge --text -o text-from-indexed.proftext indexed.profdata
|
|
RUN: llvm-profdata show --function=main --ic-targets --show-vtables text-from-indexed.proftext | FileCheck %s --check-prefix=INDEXED
|
|
RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text text-from-indexed.proftext | FileCheck %s --check-prefix=ICTEXT
|
|
|
|
INDEXED: Counters:
|
|
INDEXED-NEXT: main:
|
|
INDEXED-NEXT: Hash: 0x0f9a16fe6d398548
|
|
INDEXED-NEXT: Counters: 2
|
|
INDEXED-NEXT: Indirect Call Site Count: 2
|
|
INDEXED-NEXT: Number of instrumented vtables: 2
|
|
INDEXED-NEXT: Indirect Target Results:
|
|
INDEXED-NEXT: [ 0, {{.*}}vtable_prof.cc;_ZN12_GLOBAL__N_18Derived25func1Eii, 750 ] (75.00%)
|
|
INDEXED-NEXT: [ 0, _ZN8Derived15func1Eii, 250 ] (25.00%)
|
|
INDEXED-NEXT: [ 1, {{.*}}vtable_prof.cc;_ZN12_GLOBAL__N_18Derived25func2Eii, 750 ] (75.00%)
|
|
INDEXED-NEXT: [ 1, _ZN8Derived15func2Eii, 250 ] (25.00%)
|
|
INDEXED-NEXT: VTable Results:
|
|
INDEXED-NEXT: [ 0, {{.*}}vtable_prof.cc;_ZTVN12_GLOBAL__N_18Derived2E, 750 ] (75.00%)
|
|
INDEXED-NEXT: [ 0, _ZTV8Derived1, 250 ] (25.00%)
|
|
INDEXED-NEXT: [ 1, {{.*}}vtable_prof.cc;_ZTVN12_GLOBAL__N_18Derived2E, 750 ] (75.00%)
|
|
INDEXED-NEXT: [ 1, _ZTV8Derived1, 250 ] (25.00%)
|
|
INDEXED-NEXT: Instrumentation level: IR entry_first = 0
|
|
INDEXED-NEXT: Functions shown: 1
|
|
INDEXED-NEXT: Total functions: 6
|
|
INDEXED-NEXT: Maximum function count: 1000
|
|
INDEXED-NEXT: Maximum internal block count: 250
|
|
INDEXED-NEXT: Statistics for indirect call sites profile:
|
|
INDEXED-NEXT: Total number of sites: 2
|
|
INDEXED-NEXT: Total number of sites with values: 2
|
|
INDEXED-NEXT: Total number of profiled values: 4
|
|
INDEXED-NEXT: Value sites histogram:
|
|
INDEXED-NEXT: NumTargets, SiteCount
|
|
INDEXED-NEXT: 2, 2
|
|
INDEXED-NEXT: Statistics for vtable profile:
|
|
INDEXED-NEXT: Total number of sites: 2
|
|
INDEXED-NEXT: Total number of sites with values: 2
|
|
INDEXED-NEXT: Total number of profiled values: 4
|
|
INDEXED-NEXT: Value sites histogram:
|
|
INDEXED-NEXT: NumTargets, SiteCount
|
|
INDEXED-NEXT: 2, 2
|
|
|
|
ICTEXT: :ir
|
|
ICTEXT: main
|
|
ICTEXT: # Func Hash:
|
|
ICTEXT: 1124236338992350536
|
|
ICTEXT: # Num Counters:
|
|
ICTEXT: 2
|
|
ICTEXT: # Counter Values:
|
|
ICTEXT: 1000
|
|
ICTEXT: 1
|
|
ICTEXT: # Num Value Kinds:
|
|
ICTEXT: 2
|
|
ICTEXT: # ValueKind = IPVK_IndirectCallTarget:
|
|
ICTEXT: 0
|
|
ICTEXT: # NumValueSites:
|
|
ICTEXT: 2
|
|
ICTEXT: 2
|
|
ICTEXT: {{.*}}vtable_prof.cc;_ZN12_GLOBAL__N_18Derived25func1Eii:750
|
|
ICTEXT: _ZN8Derived15func1Eii:250
|
|
ICTEXT: 2
|
|
ICTEXT: {{.*}}vtable_prof.cc;_ZN12_GLOBAL__N_18Derived25func2Eii:750
|
|
ICTEXT: _ZN8Derived15func2Eii:250
|
|
ICTEXT: # ValueKind = IPVK_VTableTarget:
|
|
ICTEXT: 2
|
|
ICTEXT: # NumValueSites:
|
|
ICTEXT: 2
|
|
ICTEXT: 2
|
|
ICTEXT: {{.*}}vtable_prof.cc;_ZTVN12_GLOBAL__N_18Derived2E:750
|
|
ICTEXT: _ZTV8Derived1:250
|
|
ICTEXT: 2
|
|
ICTEXT: {{.*}}vtable_prof.cc;_ZTVN12_GLOBAL__N_18Derived2E:750
|
|
ICTEXT: _ZTV8Derived1:250
|