[clang-format] Fix a bug in aligning comments above PPDirective (#72791)
[llvm-project.git] / clang / utils / perf-training / CMakeLists.txt
blobc6d51863fb1b5c2b8eab8de7331fd81f92c71612
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 ${CLANG_PERF_TRAINING_DEPS}
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 # TODO: Look into supporting this for the driver build. It will require changing
37 # the perf-helper.py file to understand to call `llvm` as `llvm clang`.
38 if(APPLE AND DTRACE AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
39   configure_lit_site_cfg(
40     ${CMAKE_CURRENT_SOURCE_DIR}/order-files.lit.site.cfg.in
41     ${CMAKE_CURRENT_BINARY_DIR}/order-files/lit.site.cfg
42     )
44   add_lit_testsuite(generate-dtrace-logs "Generating clang dtrace data"
45     ${CMAKE_CURRENT_BINARY_DIR}/order-files/
46     EXCLUDE_FROM_CHECK_ALL
47     ARGS -j 1
48     DEPENDS clang clear-dtrace-logs
49     )
51   add_custom_target(clear-dtrace-logs
52     COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
53     COMMENT "Clearing old dtrace data")
55   if(NOT CLANG_ORDER_FILE)
56     message(FATAL_ERROR "Output clang order file is not set")
57   endif()
59   add_custom_target(generate-order-file
60     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}
61     COMMENT "Generating order file"
62     DEPENDS generate-dtrace-logs)
63 endif()
65 if(CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
66   configure_lit_site_cfg(
67     ${CMAKE_CURRENT_SOURCE_DIR}/bolt.lit.site.cfg.in
68     ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/lit.site.cfg
69     )
71   add_lit_testsuite(generate-bolt-fdata "Generating BOLT profile for Clang"
72     ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/
73     EXCLUDE_FROM_CHECK_ALL
74     DEPENDS clang-instrumented clear-bolt-fdata
75     )
77   add_custom_target(clear-bolt-fdata
78     COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} fdata
79     COMMENT "Clearing old BOLT fdata")
81   # Merge profiles into one using merge-fdata
82   add_custom_target(clang-bolt-profile
83     COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge-fdata $<TARGET_FILE:merge-fdata> ${CMAKE_CURRENT_BINARY_DIR}/prof.fdata ${CMAKE_CURRENT_BINARY_DIR}
84     COMMENT "Merging BOLT fdata"
85     DEPENDS merge-fdata generate-bolt-fdata)
86 endif()