Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -94,6 +94,8 @@ endif() endif() +option(TEST_SUITE_USE_IR_PGO + "Use IR PGO instrumentation (requires TEST_SUITE_PROFILE_GENERATE)" OFF) # Enable profile generate mode in lit. Note that this does not automatically # add something like -fprofile-instr-generate to the compiler flags. @@ -109,9 +111,15 @@ endif() set(TEST_SUITE_PROFILE_GENERATE "True") - list(APPEND CFLAGS -fprofile-instr-generate) - list(APPEND CXXFLAGS -fprofile-instr-generate) - list(APPEND LDFLAGS -fprofile-instr-generate) + + set(profile_instrumentation_flags -fprofile-instr-generate) + if(TEST_SUITE_USE_IR_PGO) + set(profile_instrumentation_flags -fprofile-generate) + endif() + + list(APPEND CFLAGS ${profile_instrumentation_flags}) + list(APPEND CXXFLAGS ${profile_instrumentation_flags}) + list(APPEND LDFLAGS ${profile_instrumentation_flags}) else() set(TEST_SUITE_PROFILE_GENERATE "False") endif() Index: litsupport/README.md =================================================================== --- litsupport/README.md +++ litsupport/README.md @@ -70,7 +70,8 @@ ssh to run benchmarks on a remote device (assuming shared file systems). - `cmake -DTEST_SUITE_PROFILE_GENERATE` compiles benchmark with `-fprofile-instr-generate` and enables the `profilegen` module that runs - `llvm-profdata` after running the benchmarks. + `llvm-profdata` after running the benchmarks. To use LLVM IR PGO instead of + the clang frontend's PGO feature, set `-DTEST_SUITE_USE_IR_PGO=On`. Available modules are found in the `litsupport/modules` directory.