Skip to content

Commit dca7306

Browse files
authored
[clang][perf-training] Support excluding LLVM build from PGO training (#126876)
Using LLVM build itself for PGO training is convenient and a great starting point but it also has several issues: * LLVM build implicitly depends on tools other than CMake and C/C++ compiler and if those tools aren't available in PATH, the build will fail. * LLVM build also requires standard headers and libraries which may not always be available in the default location requiring an explicit sysroot. * Building a single configuration (-DCMAKE_BUILD_TYPE=Release) only exercises the -O3 pipeline and can pesimize other configurations. * Building for the host target doesn't exercise all other targets. * Since LLVMSupport is a static library, this doesn't exercise the linker (beyond what the CMake itself does). Rather than using LLVM build, ideally we would provide a more minimal, purpose built corpus. While we're working on building such a corpus, provide a CMake option that lets vendors disable the use LLVM build for PGO training.
1 parent 851177c commit dca7306

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

clang/utils/perf-training/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH
66
set(CLANG_PGO_TRAINING_DATA_SOURCE_DIR OFF CACHE STRING "Path to source directory containing cmake project with source files to use for generating pgo data")
77
set(CLANG_PGO_TRAINING_DEPS "" CACHE STRING "Extra dependencies needed to build the PGO training data.")
88

9+
option(CLANG_PGO_TRAINING_USE_LLVM_BUILD "Use LLVM build for generating PGO data" ON)
10+
11+
llvm_canonicalize_cmake_booleans(
12+
CLANG_PGO_TRAINING_USE_LLVM
13+
)
14+
915
if(LLVM_BUILD_INSTRUMENTED)
1016
configure_lit_site_cfg(
1117
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in

clang/utils/perf-training/lit.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ config.clang = lit.util.which('clang', config.clang_tools_dir).replace('\\', '/'
2727
config.name = 'Clang Perf Training'
2828
config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test']
2929

30+
if not config.use_llvm_build:
31+
config.excludes = ['llvm-support']
32+
3033
cc1_wrapper = '%s %s/perf-helper.py cc1' % (config.python_exe, config.perf_helper_dir)
3134

3235
use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")

clang/utils/perf-training/lit.site.cfg.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ config.python_exe = "@Python3_EXECUTABLE@"
1111
config.cmake_exe = "@CMAKE_COMMAND@"
1212
config.llvm_src_dir ="@CMAKE_SOURCE_DIR@"
1313
config.cmake_generator ="@CMAKE_GENERATOR@"
14+
config.use_llvm_build = @CLANG_PGO_TRAINING_USE_LLVM_BUILD@
1415

1516
# Let the main config do the real work.
1617
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/lit.cfg")

0 commit comments

Comments
 (0)