[PATCH] D136023: [CMake] Disable BOLT instrumentation of Clang on instrumented build

Amir Ayupov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 15 11:05:46 PDT 2022


Amir created this revision.
Amir added reviewers: phosek, nikic, beanz.
Herald added a subscriber: wenlei.
Herald added a project: All.
Amir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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 -DCMAKE_BUILD_TYPE=Release \
    -DLLVM_ENABLE_PROJECTS="bolt;clang;lld" -DLLVM_ENABLE_LLD=ON \
    -DBOOTSTRAP_LLVM_ENABLE_LLD=ON -DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
    -DPGO_INSTRUMENT_LTO=Thin  -DCLANG_BOOTSTRAP_TARGETS="stage2-clang++-bolt" \
    -DBOOTSTRAP_CLANG_BOOTSTRAP_TARGETS=clang++-bolt \
    -DPGO_BUILD_CONFIGURATION=/path/to/llvm-project/clang/cmake/caches/BOLT.cmake \
    -C llvm-project/clang/cmake/caches/PGO.cmake
  ninja stage2-clang++-bolt


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136023

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -874,7 +874,7 @@
   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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136023.468029.patch
Type: text/x-patch
Size: 424 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221015/9053e6ea/attachment.bin>


More information about the cfe-commits mailing list