Amir created this revision. Amir added a reviewer: bolt. Herald added a project: All. Amir requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Split up and refactor CLANG_BOLT_INSTRUMENT into pieces that would work with other profiling modes, namely perf no-LBR and perf with LBR. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D143617 Files: clang/CMakeLists.txt clang/cmake/caches/BOLT.cmake clang/utils/perf-training/CMakeLists.txt Index: clang/utils/perf-training/CMakeLists.txt =================================================================== --- clang/utils/perf-training/CMakeLists.txt +++ clang/utils/perf-training/CMakeLists.txt @@ -60,7 +60,7 @@ DEPENDS generate-dtrace-logs) endif() -if(CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED) +if(CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/bolt.lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/lit.site.cfg @@ -69,7 +69,7 @@ add_lit_testsuite(generate-bolt-fdata "Generating BOLT profile for Clang" ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/ EXCLUDE_FROM_CHECK_ALL - DEPENDS clang-instrumented clear-bolt-fdata + DEPENDS clang-bolt-training-deps clear-bolt-fdata ) add_custom_target(clear-bolt-fdata Index: clang/cmake/caches/BOLT.cmake =================================================================== --- clang/cmake/caches/BOLT.cmake +++ clang/cmake/caches/BOLT.cmake @@ -1,12 +1,6 @@ set(CMAKE_BUILD_TYPE Release CACHE STRING "") -set(CLANG_BOLT_INSTRUMENT ON CACHE BOOL "") +set(CLANG_BOLT "INSTRUMENT" CACHE STRING "") set(CMAKE_EXE_LINKER_FLAGS "-Wl,--emit-relocs,-znow" CACHE STRING "") set(LLVM_ENABLE_PROJECTS "bolt;clang" CACHE STRING "") set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") - -# Disable function splitting enabled by default in GCC8+ -if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-reorder-blocks-and-partition") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-reorder-blocks-and-partition") -endif() Index: clang/CMakeLists.txt =================================================================== --- clang/CMakeLists.txt +++ clang/CMakeLists.txt @@ -851,7 +851,12 @@ endforeach() endif() -if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED) +set(CLANG_BOLT "INSTRUMENT" CACHE STRING "Apply BOLT optimization to Clang. \ + May be specified as Instrument or Perf or LBR to use a particular profiling \ + mechanism.") +string(TOUPPER "${CLANG_BOLT}" uppercase_CLANG_BOLT) + +if (uppercase_CLANG_BOLT STREQUAL "INSTRUMENT" AND NOT LLVM_BUILD_INSTRUMENTED) set(CLANG_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) set(CLANG_INSTRUMENTED ${CLANG_PATH}-bolt.inst) @@ -868,8 +873,11 @@ COMMENT "Instrumenting clang binary with BOLT" VERBATIM ) + add_custom_target(clang-bolt-training-deps DEPENDS clang-instrumented) +endif() - # Optimize original (pre-bolt) Clang using the collected profile +if (CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED) + # Optimize original Clang using the collected profile set(CLANG_OPTIMIZED ${CMAKE_CURRENT_BINARY_DIR}/clang.bolt) add_custom_target(clang-bolt DEPENDS merge-bolt-fdata
Index: clang/utils/perf-training/CMakeLists.txt =================================================================== --- clang/utils/perf-training/CMakeLists.txt +++ clang/utils/perf-training/CMakeLists.txt @@ -60,7 +60,7 @@ DEPENDS generate-dtrace-logs) endif() -if(CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED) +if(CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/bolt.lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/lit.site.cfg @@ -69,7 +69,7 @@ add_lit_testsuite(generate-bolt-fdata "Generating BOLT profile for Clang" ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/ EXCLUDE_FROM_CHECK_ALL - DEPENDS clang-instrumented clear-bolt-fdata + DEPENDS clang-bolt-training-deps clear-bolt-fdata ) add_custom_target(clear-bolt-fdata Index: clang/cmake/caches/BOLT.cmake =================================================================== --- clang/cmake/caches/BOLT.cmake +++ clang/cmake/caches/BOLT.cmake @@ -1,12 +1,6 @@ set(CMAKE_BUILD_TYPE Release CACHE STRING "") -set(CLANG_BOLT_INSTRUMENT ON CACHE BOOL "") +set(CLANG_BOLT "INSTRUMENT" CACHE STRING "") set(CMAKE_EXE_LINKER_FLAGS "-Wl,--emit-relocs,-znow" CACHE STRING "") set(LLVM_ENABLE_PROJECTS "bolt;clang" CACHE STRING "") set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") - -# Disable function splitting enabled by default in GCC8+ -if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-reorder-blocks-and-partition") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-reorder-blocks-and-partition") -endif() Index: clang/CMakeLists.txt =================================================================== --- clang/CMakeLists.txt +++ clang/CMakeLists.txt @@ -851,7 +851,12 @@ endforeach() endif() -if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED) +set(CLANG_BOLT "INSTRUMENT" CACHE STRING "Apply BOLT optimization to Clang. \ + May be specified as Instrument or Perf or LBR to use a particular profiling \ + mechanism.") +string(TOUPPER "${CLANG_BOLT}" uppercase_CLANG_BOLT) + +if (uppercase_CLANG_BOLT STREQUAL "INSTRUMENT" AND NOT LLVM_BUILD_INSTRUMENTED) set(CLANG_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) set(CLANG_INSTRUMENTED ${CLANG_PATH}-bolt.inst) @@ -868,8 +873,11 @@ COMMENT "Instrumenting clang binary with BOLT" VERBATIM ) + add_custom_target(clang-bolt-training-deps DEPENDS clang-instrumented) +endif() - # Optimize original (pre-bolt) Clang using the collected profile +if (CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED) + # Optimize original Clang using the collected profile set(CLANG_OPTIMIZED ${CMAKE_CURRENT_BINARY_DIR}/clang.bolt) add_custom_target(clang-bolt DEPENDS merge-bolt-fdata
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits