This CL adds "BBLabels" support for LLVM_BUILD_INSTRUMENTED.
"BBLabels" adds -fbasic-block-sections=labels to C/CXX flags as well as LD flags when doing ThinLTO. With this option, CMAKE builds binaries with auxiliary basic block meta data that later guide propeller[1] profile generation.
With this patch (and its to-be-uploaded child patch that adds support for passing propeller profiles using LLVM_PROFDATA_FILE), it enables people to build propeller optimized llvm tools in a formalized way.
Here is the proposed workflow to build a propeller optimized clang binary (similar to PGO build).
- Build instrumented clang binary:
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_INSTRUMENTED=BBLabels -DLLVM_ENABLE_PROJECTS="clang" llvm-project/llvm ninja build
- Using the above built binary in day-to-day routine and collect perf.data file and then convert it to propeller profiles.
- Build the optimized clang binary:
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_PROPELLER_PROFILES=<profile_name> -DLLVM_ENABLE_PROJECTS="clang" llvm-project/llvm
The experiment data show propeller optimized clang has a 5% compiler time improvement over PGO build.
[1]. Propeller, submitted in 2021.
Suggestion: Maybe say "Use BBLabels for Propeller instrumentation via basic block labels"