[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / utils / perf-training / CMakeLists.txt
blob57c974072d24607263364c02700b10923cc25978
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"
3   )
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
9     )
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
15     )
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")
21   if(NOT LLVM_PROFDATA)
22     find_program(LLVM_PROFDATA llvm-profdata)
23   endif()
25   if(NOT LLVM_PROFDATA)
26     message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to llvm-profdata")
27   else()
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)
32   endif()
33 endif()
35 find_program(DTRACE dtrace)
36 if(APPLE AND 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
40     )
42   add_lit_testsuite(generate-dtrace-logs "Generating clang dtrace data"
43     ${CMAKE_CURRENT_BINARY_DIR}/order-files/
44     EXCLUDE_FROM_CHECK_ALL
45     ARGS -j 1
46     DEPENDS clang clear-dtrace-logs
47     )
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")
55   endif()
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)
61 endif()