Both GCC and clang offer the option of generating code that is optimized
with CPU programming counter data by tools like Linux perf or FreeBSD
pmc(3).
With Linux perf, the recommendation is to use the -b flag to use the
Last Branch Record (LBR) to record call chains: on FreeBSD, enhance the
pmcstat(8) tool with a new -B option that generates a similar profile.
hwpmc sample
│ ├── timestamp ───────→ perf-script timestamp ├── PID ──────────────→ PID ├── CPU ──────────────→ CPU ├── PMC ──────────────→ event name ├── PC ───────────────→ IP/callchain └── process mappings ─→ MMAP2