[clang] 076240f - [CMake] Disable BOLT instrumentation of Clang on instrumented build
Amir Ayupov via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 19 18:24:10 PDT 2022
Author: Amir Ayupov
Date: 2022-10-19T18:24:05-07:00
New Revision: 076240fa062415b6470b79413559aff2bf5bf208
URL: https://github.com/llvm/llvm-project/commit/076240fa062415b6470b79413559aff2bf5bf208
DIFF: https://github.com/llvm/llvm-project/commit/076240fa062415b6470b79413559aff2bf5bf208.diff
LOG: [CMake] Disable BOLT instrumentation of Clang on instrumented build
This enables multi-stage PGO build optimized by BOLT using BOLT.cmake cache.
The issue is that `-DPGO_BUILD_CONFIGURATION` cache file is passed to both
stage2-instrumented and stage2-optimized builds (for them to be identical),
but in case of BOLT.cmake, it doesn't make sense to BOLT-instrument the
instrumented binary (it's not going to be optimized). Hence turn off
`CLANG_BOLT_INSTRUMENT` code if `LLVM_BUILD_INSTRUMENTED` is enabled.
The final workflow that enables multi-stage InstrPGO+ThinLTO+BOLT Clang build:
```
cmake <llvm-project>/llvm -GNinja -DLLVM_ENABLE_LLD=ON \
-DBOOTSTRAP_LLVM_ENABLE_LLD=ON -DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
-DPGO_INSTRUMENT_LTO=Thin -C llvm-project/clang/cmake/caches/BOLT-PGO.cmake
ninja stage2-clang++-bolt
```
Reviewed By: rafauler
Differential Revision: https://reviews.llvm.org/D136023
Added:
clang/cmake/caches/BOLT-PGO.cmake
Modified:
clang/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 87ce418424c96..202a5d2667943 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -868,7 +868,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
endforeach()
endif()
-if (CLANG_BOLT_INSTRUMENT)
+if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
set(CLANG_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
set(CLANGXX_PATH ${CLANG_PATH}++)
set(CLANG_INSTRUMENTED ${CLANG_PATH}-bolt.inst)
diff --git a/clang/cmake/caches/BOLT-PGO.cmake b/clang/cmake/caches/BOLT-PGO.cmake
new file mode 100644
index 0000000000000..54827c124bcb1
--- /dev/null
+++ b/clang/cmake/caches/BOLT-PGO.cmake
@@ -0,0 +1,11 @@
+set(LLVM_ENABLE_PROJECTS "bolt;clang;lld" CACHE STRING "")
+
+set(CLANG_BOOTSTRAP_TARGETS
+ stage2-clang++-bolt
+ CACHE STRING "")
+set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
+ clang++-bolt
+ CACHE STRING "")
+
+set(PGO_BUILD_CONFIGURATION ${CMAKE_CURRENT_LIST_DIR}/BOLT.cmake CACHE STRING "")
+include(${CMAKE_CURRENT_LIST_DIR}/PGO.cmake)
More information about the cfe-commits
mailing list