[test-suite] Add cmake option to use IR PGO (TEST_SUITE_USE_IR_PGO)
This allows building programs in the test suite with LLVM's IR PGO
feature. Support for re-building programs with the collected profdata is
already present.
Differential Revision: https://reviews.llvm.org/D57985
llvm-svn: 353591
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f57a1ec..9e801c1 100644
--- a/CMakeLists.txt
+++ b/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()
diff --git a/litsupport/README.md b/litsupport/README.md
index f555632..c5edf20 100644
--- a/litsupport/README.md
+++ b/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.