-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[CMake][PGO] Add option for using an external project to generate profile data #78879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
0719f49
5c60223
4f9fa29
552d251
80d98a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
include(LLVMExternalProjectUtils) | ||
|
||
set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH | ||
"The path to a lit testsuite containing samples for PGO and order file generation" | ||
) | ||
set(CLANG_PGO_TRAINING_DATA_SOURCE_DIR OFF CACHE STRING "Path to source directory containing cmake project with source files to use for generating pgo data") | ||
set(CLANG_PGO_TRAINING_DEPS "" CACHE STRING "Extra dependencies needed to build the PGO training data.") | ||
|
||
if(LLVM_BUILD_INSTRUMENTED) | ||
configure_lit_site_cfg( | ||
|
@@ -11,11 +15,11 @@ if(LLVM_BUILD_INSTRUMENTED) | |
add_lit_testsuite(generate-profraw "Generating clang PGO data" | ||
${CMAKE_CURRENT_BINARY_DIR}/pgo-data/ | ||
EXCLUDE_FROM_CHECK_ALL | ||
DEPENDS clang clear-profraw ${CLANG_PERF_TRAINING_DEPS} | ||
DEPENDS clang clear-profraw ${CLANG_PGO_TRAINING_DEPS} | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @petrhosek CLANG_PERF_TRAINING_DEPS was an existing variable that's used here. I think it was meant to be added to cache files, but I added it to CMakeLists.txt file here so that it could be passed on the command line without modifying the cache files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like I added that in https://reviews.llvm.org/D138974 but I'm not aware of it being used anywhere at the moment. I'd still prefer renaming it to |
||
|
||
add_custom_target(clear-profraw | ||
COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} profraw | ||
COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/profiles/ profraw | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does this new path ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aaupov That's the directory where clang will write it's profiles to by default. |
||
COMMENT "Clearing old profraw data") | ||
|
||
if(NOT LLVM_PROFDATA) | ||
|
@@ -26,9 +30,14 @@ if(LLVM_BUILD_INSTRUMENTED) | |
message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to llvm-profdata") | ||
else() | ||
add_custom_target(generate-profdata | ||
COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} | ||
COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/profiles/ | ||
COMMENT "Merging profdata" | ||
DEPENDS generate-profraw) | ||
if (CLANG_PGO_TRAINING_DATA_SOURCE_DIR) | ||
llvm_ExternalProject_Add(generate-profraw-external ${CLANG_PGO_TRAINING_DATA_SOURCE_DIR} | ||
USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS generate-profraw) | ||
add_dependencies(generate-profdata generate-profraw-external) | ||
endif() | ||
endif() | ||
endif() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to avoid touching to prevent conflicts with #78869.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaupov How does this look now?