Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang][CMake] Use perf-training for Clang-BOLT
Leverage perf-training flow for BOLT profile collection, enabling reproducible BOLT optimization. Remove the use of bootstrapped build for profile collection. Test Plan: - Regular (single-stage) build ``` $ cmake ... -C .../clang/cmake/caches/BOLT.cmake $ ninja clang-bolt ... [21/24] Instrumenting clang binary with BOLT [21/24] Generating BOLT profile for Clang [23/24] Merging BOLT fdata Profile from 2 files merged. [24/24] Optimizing Clang with BOLT ... 1291202496 : executed instructions (-1.1%) 27005133 : taken branches (-71.5%) ... ``` - Two stage build (ThinLTO+InstPGO) ``` $ cmake ... -C .../clang/cmake/caches/BOLT.cmake -C .../clang/cmake/caches/BOLT-PGO.cmake $ ninja clang-bolt $ ninja stage2-clang-bolt ... [2756/2759] Instrumenting clang binary with BOLT [2756/2759] Generating BOLT profile for Clang [2758/2759] Merging BOLT fdata [2759/2759] Optimizing Clang with BOLT ... BOLT-INFO: 7092 out of 184104 functions in the binary (3.9%) have non-empty execution profile 756531927 : executed instructions (-0.5%) 15399400 : taken branches (-40.3%) ... ``` Reviewed By: beanz Differential Revision: https://reviews.llvm.org/D143553
- Loading branch information
Showing
5 changed files
with
60 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- Python -*- | ||
|
||
from lit import Test | ||
import lit.formats | ||
import lit.util | ||
import os | ||
import subprocess | ||
|
||
config.clang = os.path.realpath(lit.util.which('clang-bolt.inst', config.clang_tools_dir)).replace('\\', '/') | ||
|
||
config.name = 'Clang Perf Training' | ||
config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test'] | ||
|
||
use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL") | ||
config.test_format = lit.formats.ShTest(use_lit_shell == "0") | ||
config.substitutions.append( ('%clang_cpp_skip_driver', ' %s --driver-mode=g++ ' % (config.clang))) | ||
config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=g++ ' % (config.clang))) | ||
config.substitutions.append( ('%clang_skip_driver', ' %s ' % (config.clang))) | ||
config.substitutions.append( ('%clang', ' %s ' % (config.clang) ) ) | ||
config.substitutions.append( ('%test_root', config.test_exec_root ) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@LIT_SITE_CFG_IN_HEADER@ | ||
|
||
import sys | ||
|
||
config.clang_tools_dir = lit_config.substitute("@CURRENT_TOOLS_DIR@") | ||
config.perf_helper_dir = "@CMAKE_CURRENT_SOURCE_DIR@" | ||
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@" | ||
config.test_source_root = "@CLANG_PGO_TRAINING_DATA@" | ||
config.target_triple = "@LLVM_TARGET_TRIPLE@" | ||
config.python_exe = "@Python3_EXECUTABLE@" | ||
config.clang_obj_root = path(r"@CLANG_BINARY_DIR@") | ||
|
||
# Let the main config do the real work. | ||
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/bolt.lit.cfg") |