Skip to content

[CMake] Add TEST_SUITE_SAMPLE_PROFILE_USE for sample-based PGO#380

Open
mustartt wants to merge 1 commit intomainfrom
users/hjiang/sample-profile-use
Open

[CMake] Add TEST_SUITE_SAMPLE_PROFILE_USE for sample-based PGO#380
mustartt wants to merge 1 commit intomainfrom
users/hjiang/sample-profile-use

Conversation

@mustartt
Copy link
Copy Markdown
Member

Add support for sample profile support (-fprofile-sample-use) to the test suite with two new CMake flags:

  • TEST_SUITE_SAMPLE_PROFILE_USE=On|Off: enables sample profile use.
  • TEST_SUITE_SAMPLE_PROFILE_DIR=<path>: a directory containing <target>.spgo sample profile files.

Unlike instrumentation PGO which requires a two-phase generate + use workflow, sample profiles are collected externally, and the collection method various widely between platforms. For each benchmark target, the build system looks for <dir>/<target>.spgo and passes -fprofile-sample-use=<path> to the compile flags. In case, the target does not have an associated sample profile, an warning is emitted.

# collection
cmake -DTEST_SUITE_BENCHMARKING_ONLY=On \
      -DTEST_SUITE_RUN_UNDER=<collection tool> \
      ../llvm-test-suite
make 
llvm-lit .

# merge sample profiles into /path/to/profiles
/path/to/profiles/ contains:
401.bzip2.spgo
429.mcf.spgo
456.hmmer.spgo
470.lbm.spgo
...

# final build
cmake -DTEST_SUITE_BENCHMARKING_ONLY=On \
      -DTEST_SUITE_SAMPLE_PROFILE_USE=On \
      -DTEST_SUITE_SAMPLE_PROFILE_DIR=/path/to/profiles \
      ../llvm-test-suite
...

@mustartt mustartt changed the title [CMake] Add TEST_SUITE_SAMPLE_PROFILE_USE for sample-based PGO [CMake] Add TEST_SUITE_SAMPLE_PROFILE_USE for sample-based PGO Apr 10, 2026
@mustartt mustartt requested review from MatzeB and tomershafir April 10, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant