Skip to content

Commit 40cb962

Browse files
committed
[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
1 parent eb249d0 commit 40cb962

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ Make sure it is in your path or set TEST_SUITE_COLLECT_CODE_SIZE to OFF")
9494
endif()
9595
endif()
9696

97+
option(TEST_SUITE_USE_IR_PGO
98+
"Use IR PGO instrumentation (requires TEST_SUITE_PROFILE_GENERATE)" OFF)
9799

98100
# Enable profile generate mode in lit. Note that this does not automatically
99101
# add something like -fprofile-instr-generate to the compiler flags.
@@ -109,9 +111,15 @@ Make sure it is in your path or set TEST_SUITE_PROFILE_GENERATE to OFF")
109111
endif()
110112

111113
set(TEST_SUITE_PROFILE_GENERATE "True")
112-
list(APPEND CFLAGS -fprofile-instr-generate)
113-
list(APPEND CXXFLAGS -fprofile-instr-generate)
114-
list(APPEND LDFLAGS -fprofile-instr-generate)
114+
115+
set(profile_instrumentation_flags -fprofile-instr-generate)
116+
if(TEST_SUITE_USE_IR_PGO)
117+
set(profile_instrumentation_flags -fprofile-generate)
118+
endif()
119+
120+
list(APPEND CFLAGS ${profile_instrumentation_flags})
121+
list(APPEND CXXFLAGS ${profile_instrumentation_flags})
122+
list(APPEND LDFLAGS ${profile_instrumentation_flags})
115123
else()
116124
set(TEST_SUITE_PROFILE_GENERATE "False")
117125
endif()

litsupport/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ code; typical examples are:
7070
ssh to run benchmarks on a remote device (assuming shared file systems).
7171
- `cmake -DTEST_SUITE_PROFILE_GENERATE` compiles benchmark with
7272
`-fprofile-instr-generate` and enables the `profilegen` module that runs
73-
`llvm-profdata` after running the benchmarks.
73+
`llvm-profdata` after running the benchmarks. To use LLVM IR PGO instead of
74+
the clang frontend's PGO feature, set `-DTEST_SUITE_USE_IR_PGO=On`.
7475

7576
Available modules are found in the `litsupport/modules` directory.
7677

0 commit comments

Comments
 (0)