Skip to content

Commit 07a1fbe

Browse files
[docs][TypeProf]Update instrumentation file format document (#83309)
This is a follow-up to the profile format change in #82711
1 parent d0b4780 commit 07a1fbe

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

llvm/docs/InstrProfileFormat.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ Header
150150
Records the in-memory address of name section. Not used except for raw profile
151151
reader error checking.
152152

153+
``NumVTables``
154+
Records the number of instrumented vtable entries in the binary. Used for
155+
`type profiling`_.
156+
157+
``VNamesSize``
158+
Records the byte size in the virtual table names section. Used for `type profiling`_.
159+
153160
``ValueKindLast``
154161
Records the number of value kinds. Macro `VALUE_PROF_KIND`_ defines the value
155162
kinds with a description of the kind.
@@ -323,6 +330,8 @@ for the design.
323330
.. _`Modified Condition/Decision Coverage`: https://en.wikipedia.org/wiki/Modified_condition/decision_coverage
324331
.. _`Bitmap RFC`: https://discourse.llvm.org/t/rfc-source-based-mc-dc-code-coverage/59244
325332

333+
.. _`function names`:
334+
326335
Names
327336
^^^^^^
328337

@@ -333,6 +342,37 @@ Function names serve as keys in the PGO data hash table when raw profiles are
333342
converted into indexed profiles. They are also crucial for ``llvm-profdata`` to
334343
show the profiles in a human-readable way.
335344

345+
Virtual Table Profile Data
346+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
347+
348+
This section is used for `type profiling`_. Each entry corresponds to one virtual
349+
table and is defined by the following C++ struct
350+
351+
.. code-block:: c++
352+
353+
struct VTableProfData {
354+
// The start address of the vtable, collected at runtime.
355+
uint64_t StartAddress;
356+
// The byte size of the vtable. `StartAddress` and `ByteSize` specifies an address range to look up.
357+
uint32_t ByteSize;
358+
// The hash of vtable's (PGO) name
359+
uint64_t MD5HashOfName;
360+
};
361+
362+
At profile use time, the compiler looks up a profiled address in the sorted vtable
363+
address ranges and maps the address to a specific vtable through hashed name.
364+
365+
Virtual Table Names
366+
^^^^^^^^^^^^^^^^^^^^
367+
368+
This section is similar to `function names`_ section above, except it contains the PGO
369+
names of profiled virtual tables. It's a standalone section such that raw profile
370+
readers could directly find each name set by accessing the corresponding profile
371+
data section.
372+
373+
This section is stored in raw profiles such that `llvm-profdata` could show the
374+
profiles in a human-readable way.
375+
336376
Value Profile Data
337377
^^^^^^^^^^^^^^^^^^^^
338378

@@ -426,6 +466,8 @@ This section is right after profile header. It stores the serialized profile
426466
summary. For context-sensitive IR-based instrumentation PGO, this section stores
427467
an additional profile summary corresponding to the context-sensitive profiles.
428468

469+
.. _`function data`:
470+
429471
Function data
430472
^^^^^^^^^^^^^^^^^^
431473
This section stores functions and their profiling data as an on-disk hash table.
@@ -453,6 +495,16 @@ Temporal Profile Traces
453495
The section is used to carry on temporal profile information from raw profiles.
454496
See `temporal profiling`_ for the design.
455497

498+
Virtual Table Names
499+
^^^^^^^^^^^^^^^^^^^^
500+
This section is used to store the names of vtables from raw profile in the indexed
501+
profile.
502+
503+
Unlike function names which are stored as keys of `function data`_ hash table,
504+
vtable names need to be stored in a standalone section in indexed profiles.
505+
This way, `llvm-profdata` could show the profiled vtable information in a
506+
human-readable way.
507+
456508
Profile Data Usage
457509
=======================================
458510

@@ -476,3 +528,4 @@ based profile data. For supported usages, check out `llvm-profdata documentation
476528
.. _`single-byte counters`: https://discourse.llvm.org/t/rfc-single-byte-counters-for-source-based-code-coverage/75685
477529
.. _`binary profile correlation`: https://discourse.llvm.org/t/rfc-add-binary-profile-correlation-to-not-load-profile-metadata-sections-into-memory-at-runtime/74565
478530
.. _`binary id`: https://lists.llvm.org/pipermail/llvm-dev/2021-June/151154.html
531+
.. _`type profiling`: https://discourse.llvm.org/t/rfc-dynamic-type-profiling-and-optimizations-in-llvm/74600

0 commit comments

Comments
 (0)