Version 8 to 9
There have been a number of changes to the profile output since
LLVM17 that need to be taken account of:
ELF targets no longer do self-registration.
The profile version has been raised to 9.
In addition we want the sample to visualize the profile with
the run command so that we can more easily be alerted to
changes in the profile format.
The largest change is the removal of self-registration. When
this was in operation each object file has a .init_array entry
with a pointer to a registration function that would be called
prior to main. This registration function would register the
names and counters of all the functions, allowing the program
to calculate at run-time the extent of the counter and names
section. Without self-registration we need to use
linker defined _start and _stop section symbols to find
the extent.
The profile version increasing to 9 has added a bitmap section
that we need to account for. This section should be empty unless
MC/DC coverage is used.
The majority of the source code has been adapted from files in
llvm-project/compiler-rt/lib/profile and
llvm-project/compiler-rt/include/profile
To replicate the behaviour of the previous example, we make
a C attribute((constructor)) function that runs before
main to register an atexit handler that writes out the
profile after exiting main.
version 9 to 10
Version 10 introduces dynamic type profiling. This seems to
be used for IRPGO so should not affect code-coverage using
front-end instrumentation.
This patch:
Bumps the version number to 10.
Adds new fields to the Header file.
Defines names for the new sections.
Adds linker defined symbols for the new sections.
Writes out the new sections.
We expect the new sections to be empty, size 0 when
using front-end based instrumentation.
Port proflib.c to LLVM-19 INSTR_PROF_RAW_VERSION 10
This patch includes the update of proflib to INSTR_PROF_RAW_VERSION_VERSION 9 committed to the llvm-18 branch in (https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/pull/422)
Version 8 to 9 There have been a number of changes to the profile output since LLVM17 that need to be taken account of:
In addition we want the sample to visualize the profile with the run command so that we can more easily be alerted to changes in the profile format.
The largest change is the removal of self-registration. When this was in operation each object file has a .init_array entry with a pointer to a registration function that would be called prior to main. This registration function would register the names and counters of all the functions, allowing the program to calculate at run-time the extent of the counter and names section. Without self-registration we need to use linker defined _start and _stop section symbols to find the extent.
The profile version increasing to 9 has added a bitmap section that we need to account for. This section should be empty unless MC/DC coverage is used.
The majority of the source code has been adapted from files in llvm-project/compiler-rt/lib/profile and llvm-project/compiler-rt/include/profile
To replicate the behaviour of the previous example, we make a C attribute((constructor)) function that runs before main to register an atexit handler that writes out the profile after exiting main.
version 9 to 10 Version 10 introduces dynamic type profiling. This seems to be used for IRPGO so should not affect code-coverage using front-end instrumentation.
This patch:
We expect the new sections to be empty, size 0 when using front-end based instrumentation.