llvm-project/clang/utils
Amir Ayupov 3dab7fede2 [CMake] Add clang-bolt target
This patch adds `CLANG_BOLT_INSTRUMENT` option that applies BOLT instrumentation
to Clang, performs a bootstrap build with the resulting Clang, merges resulting
fdata files into a single profile file, and uses it to perform BOLT optimization
on the original Clang binary.

The projects and targets used for bootstrap/profile collection are configurable via
`CLANG_BOLT_INSTRUMENT_PROJECTS` and `CLANG_BOLT_INSTRUMENT_TARGETS`.
The defaults are "llvm" and "count" respectively, which results in a profile with
~5.3B dynamically executed instructions.

The intended use of the functionality is through BOLT CMake cache file, similar
to PGO 2-stage build:
```
cmake <llvm-project>/llvm -C <llvm-project>/clang/cmake/caches/BOLT.cmake
ninja clang++-bolt # pulls clang-bolt
```

Stats with a recent checkout (clang-16), pre-built BOLT and Clang, 72vCPU/224G
| CMake configure with host Clang + BOLT.cmake | 1m6.592s
| Instrumenting Clang with BOLT | 2m50.508s
| CMake configure `llvm` with instrumented Clang | 5m46.364s (~5x slowdown)
| CMake build `not` with instrumented Clang |0m6.456s
| Merging fdata files | 0m9.439s
| Optimizing Clang with BOLT | 0m39.201s

Building Clang:
```cmake ../llvm-project/llvm -DCMAKE_C_COMPILER=... -DCMAKE_CXX_COMPILER=...
  -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang
  -DLLVM_TARGETS_TO_BUILD=Native -GNinja```

| | Release | BOLT-optimized
| cmake | 0m24.016s | 0m22.333s
| ninja clang | 5m55.692s | 4m35.122s

I know it's not rigorous, but shows a ballpark figure.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D132975
2022-09-23 10:10:31 +02:00
..
ABITest
CIndex
ClangVisualizers [clang] adds unary type transformations as compiler built-ins 2022-08-22 03:03:32 +00:00
TableGen [clang][Interp] Implement function calls 2022-09-08 07:31:07 +02:00
TestUtils Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk 2021-02-25 11:32:27 +01:00
VtableTest
analyzer [analyzer] Add more information to the Exploded Graph 2022-09-03 00:21:05 +02:00
check_cfc [NFC][clang]Inclusive language: remove remaining uses of sanity 2021-11-24 14:20:13 -05:00
hmaptool Fix one stray `{LLVM -> CLANG}_TOOLS_INSTALL_DIR` 2022-07-23 16:26:32 +00:00
perf-training [CMake] Add clang-bolt target 2022-09-23 10:10:31 +02:00
valgrind
CaptureCmd
ClangDataFormat.py [clang][utils] Remove StringRef lldb summary provider 2022-02-03 15:16:31 -08:00
CmpDriver
FindSpecRefs
FuzzTest
bash-autocomplete.sh
builtin-defines.c
clangdiag.py Harmonize Python shebang 2020-07-16 21:53:45 +02:00
convert_arm_neon.py [NFC][clang] Inclusive language: replace master with main in convert_arm_neon.py 2021-11-16 10:11:06 -06:00
creduce-clang-crash.py [Utils] Add an option to specify number of cores to use in creduce-clang-crash.py 2021-02-22 12:43:09 -08:00
find-unused-diagnostics.sh
make-ast-dump-check.sh [clang] Use portable "#!/usr/bin/env bash" shebang for tools and utils. 2021-09-23 21:16:43 +05:30
modfuzz.py Harmonize Python shebang 2020-07-16 21:53:45 +02:00
module-deps-to-rsp.py Reapply "[clang][deps] Split translation units into individual -cc1 or other commands" 2022-08-31 09:45:11 -07:00
token-delta.py