Lines Matching +full:- +full:- +full:pgo
2 How To Build Clang and LLVM with Profile-Guided Optimizations
8 PGO (Profile-Guided Optimization) allows your compiler to better optimize code
12 This guide walks you through how to build Clang with PGO, though it also applies
15 If you want to build other software with PGO, see the `end-user documentation
16 for PGO <https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization>`_.
22 See https://llvm.org/docs/AdvancedBuilds.html#multi-stage-pgo
29 compiler-rt. Despite the name, it performs four clean builds of Clang, so it
30 can take a while to run to completion. Please see the script's ``--help`` for
32 If you want to get the most out of PGO for a particular use-case (e.g. compiling
39 This script also supports a ``--dry-run`` option, which causes it to print
46 PGO does best when the profiles gathered represent how the user plans to use the
52 - runs all of Clang and LLVM's lit tests, and
53 - uses the instrumented Clang to build Clang, LLVM, and all of the other
58 - solid coverage of building C++,
59 - good coverage of building C,
60 - great coverage of running optimizations,
61 - great coverage of the backend for your host's architecture, and
62 - some coverage of other architectures (if other arches are supported backends).
70 Building Clang with PGO
74 how to build Clang/LLVM with PGO.
76 First, you should have at least LLVM, Clang, and compiler-rt checked out
85 - Running the instrumented Clang/LLVM/lld/etc. on tasks that represent how
87 - Using a tool to convert the "raw" profiles generated above into a single,
88 final PGO profile.
98 to build the ``all`` target (e.g. ``ninja all`` or ``make -j4 all``).
102 - ``-DLLVM_BUILD_INSTRUMENTED=IR`` -- This causes us to build everything
104 - ``-DLLVM_BUILD_RUNTIME=No`` -- A few projects have bad interactions when
107 - ``-DCMAKE_C_COMPILER=/path/to/stage1/clang`` - Use the Clang we built in
109 - ``-DCMAKE_CXX_COMPILER=/path/to/stage1/clang++`` - Same as above.
118 benchmark recommended is to run ``check-clang`` and ``check-llvm`` in your
123 - ``-DCMAKE_C_COMPILER=/path/to/stage2/clang`` - Use the Clang we built in
125 - ``-DCMAKE_CXX_COMPILER=/path/to/stage2/clang++`` - Same as above.
128 ``-DCMAKE_BUILD_TYPE=RelWithDebInfo`` instead of
129 ``-DCMAKE_BUILD_TYPE=Release``. This will grant better coverage of
138 ``llvm-profdata`` (even if you only have one! The profile merge transforms
140 ``/path/to/stage1/llvm-profdata merge
141 -output=/path/to/output/profdata.prof path/to/stage2/profiles/*.profraw``.
143 4. Now, build your final, PGO-optimized Clang. To do this, you'll want to pass
146 - ``-DLLVM_PROFDATA_FILE=/path/to/output/profdata.prof`` - Use the PGO
148 - ``-DCMAKE_C_COMPILER=/path/to/stage1/clang`` - Use the Clang we built in
150 - ``-DCMAKE_CXX_COMPILER=/path/to/stage1/clang++`` - Same as above.
157 ``-DCMAKE_C_FLAGS='-Wno-backend-plugin'
158 -DCMAKE_CXX_FLAGS='-Wno-backend-plugin'`` to your CMake invocation.
161 Congrats! You now have a Clang built with profile-guided optimizations, and you
169 ``-DCLANG_TABLEGEN=/path/to/stage1/bin/clang-tblgen
170 -DLLVM_TABLEGEN=/path/to/stage1/bin/llvm-tblgen`` to steps 2 and onward to avoid