1 set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH
2 "The path to a lit testsuite containing samples for PGO and order file generation"
5 if(LLVM_BUILD_INSTRUMENTED)
6 configure_lit_site_cfg(
7 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
8 ${CMAKE_CURRENT_BINARY_DIR}/pgo-data/lit.site.cfg
11 add_lit_testsuite(generate-profraw "Generating clang PGO data"
12 ${CMAKE_CURRENT_BINARY_DIR}/pgo-data/
13 EXCLUDE_FROM_CHECK_ALL
14 DEPENDS clang clear-profraw
17 add_custom_target(clear-profraw
18 COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} profraw
19 COMMENT "Clearing old profraw data")
22 find_program(LLVM_PROFDATA llvm-profdata)
26 message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to llvm-profdata")
28 add_custom_target(generate-profdata
29 COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
30 COMMENT "Merging profdata"
31 DEPENDS generate-profraw)
35 find_program(DTRACE dtrace)
37 configure_lit_site_cfg(
38 ${CMAKE_CURRENT_SOURCE_DIR}/order-files.lit.site.cfg.in
39 ${CMAKE_CURRENT_BINARY_DIR}/order-files/lit.site.cfg
42 add_lit_testsuite(generate-dtrace-logs "Generating clang dtrace data"
43 ${CMAKE_CURRENT_BINARY_DIR}/order-files/
44 EXCLUDE_FROM_CHECK_ALL
46 DEPENDS clang clear-dtrace-logs
49 add_custom_target(clear-dtrace-logs
50 COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
51 COMMENT "Clearing old dtrace data")
53 if(NOT CLANG_ORDER_FILE)
54 message(FATAL_ERROR "Output clang order file is not set")
57 add_custom_target(generate-order-file
58 COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py gen-order-file --binary $<TARGET_FILE:clang> --output ${CLANG_ORDER_FILE} ${CMAKE_CURRENT_BINARY_DIR}
59 COMMENT "Generating order file"
60 DEPENDS generate-dtrace-logs)