From af61d5f16154ae9a56305e3bf888ff337b5fdff4 Mon Sep 17 00:00:00 2001 From: Rahul Joshi Date: Mon, 25 Aug 2025 19:16:35 -0700 Subject: [PATCH 1/3] Trim test deps --- llvm/cmake/modules/AddLLVM.cmake | 94 ++++++++++++++++++++++++++------ llvm/test/CMakeLists.txt | 33 +++++++++++ 2 files changed, 109 insertions(+), 18 deletions(-) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 835750e2d2a13..5a3866039816f 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2192,13 +2192,39 @@ endfunction() function(add_lit_testsuites project directory) if (NOT LLVM_ENABLE_IDE) - cmake_parse_arguments(ARG "EXCLUDE_FROM_CHECK_ALL" "FOLDER;BINARY_DIR" "PARAMS;DEPENDS;ARGS" ${ARGN}) + cmake_parse_arguments(ARG "EXCLUDE_FROM_CHECK_ALL" "FOLDER;BINARY_DIR" + "PARAMS;DEPENDS;ARGS;EXCLUDE_DIR;INCLUDE_DIR" ${ARGN}) if (NOT ARG_FOLDER) get_subproject_title(subproject_title) set(ARG_FOLDER "${subproject_title}/Tests/LIT Testsuites") endif() + # Create a list of excluded paths. If not empty, any directory that begins + # with one of the excluded paths will excluded, others will be included. + set(excluded_dirs "") + if (ARG_EXCLUDE_DIR) + foreach(path ${ARG_EXCLUDE_DIR}) + list(APPEND excluded_dirs ${path}) + endforeach() + endif() + + # Create a list of included paths. If not empty, any directory that begins + # with any of the included paths will included, others will be excluded. + # If both included and excluded lists are empty, all directories will be + # included. + set(included_dirs "") + if (ARG_INCLUDE_DIR) + foreach(path ${ARG_INCLUDE_DIR}) + list(APPEND included_dirs ${path}) + endforeach() + endif() + + if (excluded_dirs AND included_dirs) + message(FATAL_ERROR, "Cannot specify both include and exclude directories") + endif() + + # Search recursively for test directories by assuming anything not # in a directory called Inputs contains tests. file(GLOB_RECURSE to_process LIST_DIRECTORIES true ${directory}/*) @@ -2214,24 +2240,56 @@ function(add_lit_testsuites project directory) # Create a check- target for the directory. string(REPLACE "${directory}/" "" name_slash ${lit_suite}) - if (name_slash) - set(filter ${name_slash}) - string(REPLACE "/" "-" name_slash ${name_slash}) - string(REPLACE "\\" "-" name_dashes ${name_slash}) - string(TOLOWER "${project}-${name_dashes}" name_var) - set(lit_args ${lit_suite}) - if (ARG_BINARY_DIR) - set(lit_args ${ARG_BINARY_DIR} --filter=${filter}) - endif() - add_lit_target("check-${name_var}" "Running lit suite ${lit_suite}" - ${lit_args} - ${EXCLUDE_FROM_CHECK_ALL} - PARAMS ${ARG_PARAMS} - DEPENDS ${ARG_DEPENDS} - ARGS ${ARG_ARGS} - ) - set_target_properties(check-${name_var} PROPERTIES FOLDER ${ARG_FOLDER}) + if (NOT name_slash) + continue() endif() + + # Determine whether to skip this directory. + if (excluded_dirs) + # Include by default, unless in the exclude list. + set(is_skipped false) + foreach (excluded_dir ${excluded_dirs}) + string(FIND "${name_slash}" "${excluded_dir}" exclude_index) + if (exclude_index EQUAL 0) + set(is_skipped true) + break() + endif() + endforeach() + elseif(included_dirs) + # Exclude by default, unless in the include list. + set(is_skipped true) + foreach (included_dir ${included_dirs}) + string(FIND "${name_slash}" "${included_dir}" include_index) + if (include_index EQUAL 0) + set(is_skipped false) + break() + endif() + endforeach() + else() + # Neither include nor exclude list specified. Include + set(is_skipped false) + endif() + + if (is_skipped) + continue() + endif() + + set(filter ${name_slash}) + string(REPLACE "/" "-" name_slash ${name_slash}) + string(REPLACE "\\" "-" name_dashes ${name_slash}) + string(TOLOWER "${project}-${name_dashes}" name_var) + set(lit_args ${lit_suite}) + if (ARG_BINARY_DIR) + set(lit_args ${ARG_BINARY_DIR} --filter=${filter}) + endif() + add_lit_target("check-${name_var}" "Running lit suite ${lit_suite}" + ${lit_args} + ${EXCLUDE_FROM_CHECK_ALL} + PARAMS ${ARG_PARAMS} + DEPENDS ${ARG_DEPENDS} + ARGS ${ARG_ARGS} + ) + set_target_properties(check-${name_var} PROPERTIES FOLDER ${ARG_FOLDER}) endforeach() endif() endfunction() diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt index f6333d68a8ea5..ab299cc4d53a0 100644 --- a/llvm/test/CMakeLists.txt +++ b/llvm/test/CMakeLists.txt @@ -259,10 +259,43 @@ add_lit_testsuite(check-llvm "Running the LLVM regression tests" ) set_target_properties(check-llvm PROPERTIES FOLDER "LLVM/Tests") +# Note, exclude TableGen and FileCheck directories as we define handle +# them with a reduced set of dependencies below. add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR} ${exclude_from_check_all} DEPENDS ${LLVM_TEST_DEPENDS} FOLDER "Tests/Subdirectories" + EXCLUDE_DIR TableGen + EXCLUDE_DIR FileCheck + ) + +# Subset of dependencies for TableGen lit test. +set(LLVM_TEST_TABLEGEN_DEPENDS + FileCheck + count + llvm-config + llvm-tblgen + not + ) + +add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR} + ${exclude_from_check_all} + DEPENDS ${LLVM_TEST_TABLEGEN_DEPENDS} + FOLDER "Tests/Subdirectories" + INCLUDE_DIR TableGen + ) + +# Subset of dependencies for FileCheck lit test. +set(LLVM_TEST_FILECHECK_DEPENDS + FileCheck + not + ) + +add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR} + ${exclude_from_check_all} + DEPENDS ${LLVM_TEST_FILECHECK_DEPENDS} + FOLDER "Tests/Subdirectories" + INCLUDE_DIR FileCheck ) # Setup an alias for 'check-all'. From 03c8d0d667125d154bbc017b71f8ab5171800372 Mon Sep 17 00:00:00 2001 From: Rahul Joshi Date: Fri, 29 Aug 2025 10:30:28 -0700 Subject: [PATCH 2/3] Review feedback --- llvm/cmake/modules/AddLLVM.cmake | 47 +++---- llvm/test/CMakeLists.txt | 213 +++++++++++++++---------------- 2 files changed, 124 insertions(+), 136 deletions(-) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 5a3866039816f..71587b939f922 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2192,35 +2192,20 @@ endfunction() function(add_lit_testsuites project directory) if (NOT LLVM_ENABLE_IDE) - cmake_parse_arguments(ARG "EXCLUDE_FROM_CHECK_ALL" "FOLDER;BINARY_DIR" - "PARAMS;DEPENDS;ARGS;EXCLUDE_DIR;INCLUDE_DIR" ${ARGN}) + cmake_parse_arguments(ARG "EXCLUDE_FROM_CHECK_ALL" + "FOLDER;BINARY_DIR;EXCLUDE_DIRS;INCLUDE_DIRS" + "PARAMS;DEPENDS;ARGS" + ${ARGN}) if (NOT ARG_FOLDER) get_subproject_title(subproject_title) set(ARG_FOLDER "${subproject_title}/Tests/LIT Testsuites") endif() - # Create a list of excluded paths. If not empty, any directory that begins - # with one of the excluded paths will excluded, others will be included. - set(excluded_dirs "") - if (ARG_EXCLUDE_DIR) - foreach(path ${ARG_EXCLUDE_DIR}) - list(APPEND excluded_dirs ${path}) - endforeach() - endif() - - # Create a list of included paths. If not empty, any directory that begins - # with any of the included paths will included, others will be excluded. - # If both included and excluded lists are empty, all directories will be - # included. - set(included_dirs "") - if (ARG_INCLUDE_DIR) - foreach(path ${ARG_INCLUDE_DIR}) - list(APPEND included_dirs ${path}) - endforeach() - endif() + separate_arguments(ARG_EXCLUDE_DIRS) + separate_arguments(ARG_INCLUDE_DIRS) - if (excluded_dirs AND included_dirs) + if (ARG_EXCLUDE_DIRS AND ARG_INCLUDE_DIRS) message(FATAL_ERROR, "Cannot specify both include and exclude directories") endif() @@ -2245,20 +2230,28 @@ function(add_lit_testsuites project directory) endif() # Determine whether to skip this directory. - if (excluded_dirs) + # + # If the exclude list is specified, any directory that begins with one of + # the excluded paths will be excluded, others will be included. + # + # If the include list is specified, any directory that begins with one of + # the included paths will be included, others will be excluded. + # + # If neither is specified, all directories will be included. + if (ARG_EXCLUDE_DIRS) # Include by default, unless in the exclude list. set(is_skipped false) - foreach (excluded_dir ${excluded_dirs}) + foreach (excluded_dir ${ARG_EXCLUDE_DIRS}) string(FIND "${name_slash}" "${excluded_dir}" exclude_index) if (exclude_index EQUAL 0) set(is_skipped true) break() endif() endforeach() - elseif(included_dirs) + elseif(ARG_INCLUDE_DIRS) # Exclude by default, unless in the include list. set(is_skipped true) - foreach (included_dir ${included_dirs}) + foreach (included_dir ${ARG_INCLUDE_DIRS}) string(FIND "${name_slash}" "${included_dir}" include_index) if (include_index EQUAL 0) set(is_skipped false) @@ -2266,7 +2259,7 @@ function(add_lit_testsuites project directory) endif() endforeach() else() - # Neither include nor exclude list specified. Include + # If neither include nor exclude list is specified, include all. set(is_skipped false) endif() diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt index ab299cc4d53a0..270881e51da9a 100644 --- a/llvm/test/CMakeLists.txt +++ b/llvm/test/CMakeLists.txt @@ -59,100 +59,104 @@ configure_lit_site_cfg( # Set the depends list as a variable so that it can grow conditionally. # NOTE: Sync the substitutions in test/lit.cfg when adding to this list. + +set(LLVM_TEST_DEPENDS_COMMON + FileCheck + count + llvm-config + not + ) + set(LLVM_TEST_DEPENDS - BugpointPasses - FileCheck - LLVMWindowsDriver - UnitTests - bugpoint - count - llc - lli - lli-child-target - llvm-addr2line - llvm-ar - llvm-as - llvm-bcanalyzer - llvm-bitcode-strip - llvm-c-test - llvm-cat - llvm-cfi-verify - llvm-cgdata - llvm-config - llvm-cov - llvm-ctxprof-util - llvm-cvtres - llvm-cxxdump - llvm-cxxfilt - llvm-cxxmap - llvm-debuginfo-analyzer - llvm-debuginfod-find - llvm-diff - llvm-dis - llvm-dlltool - dsymutil - llvm-dwarfdump - llvm-dwarfutil - llvm-dwp - llvm-exegesis - llvm-extract - llvm-gsymutil - llvm-ir2vec - llvm-isel-fuzzer - llvm-ifs - llvm-install-name-tool - llvm-jitlink - llvm-lib - llvm-libtool-darwin - llvm-link - llvm-lipo - llvm-locstats - llvm-lto2 - llvm-mc - llvm-mca - llvm-ml - llvm-ml64 - llvm-modextract - llvm-nm - llvm-objcopy - llvm-objdump - llvm-opt-fuzzer - llvm-opt-report - llvm-offload-wrapper - llvm-otool - llvm-pdbutil - llvm-profdata - llvm-profgen - llvm-ranlib - llvm-rc - llvm-readobj - llvm-readelf - llvm-reduce - llvm-remarkutil - llvm-rtdyld - llvm-sim - llvm-size - llvm-split - llvm-stress - llvm-strings - llvm-strip - llvm-symbolizer - llvm-tblgen - llvm-readtapi - llvm-tli-checker - llvm-undname - llvm-windres - llvm-xray - not - obj2yaml - opt - sancov - sanstats - split-file - verify-uselistorder - yaml-bench - yaml2obj - ) + BugpointPasses + LLVMWindowsDriver + UnitTests + bugpoint + llc + lli + lli-child-target + llvm-addr2line + llvm-ar + llvm-as + llvm-bcanalyzer + llvm-bitcode-strip + llvm-c-test + llvm-cat + llvm-cfi-verify + llvm-cgdata + llvm-cov + llvm-ctxprof-util + llvm-cvtres + llvm-cxxdump + llvm-cxxfilt + llvm-cxxmap + llvm-debuginfo-analyzer + llvm-debuginfod-find + llvm-diff + llvm-dis + llvm-dlltool + dsymutil + llvm-dwarfdump + llvm-dwarfutil + llvm-dwp + llvm-exegesis + llvm-extract + llvm-gsymutil + llvm-ir2vec + llvm-isel-fuzzer + llvm-ifs + llvm-install-name-tool + llvm-jitlink + llvm-lib + llvm-libtool-darwin + llvm-link + llvm-lipo + llvm-locstats + llvm-lto2 + llvm-mc + llvm-mca + llvm-ml + llvm-ml64 + llvm-modextract + llvm-nm + llvm-objcopy + llvm-objdump + llvm-opt-fuzzer + llvm-opt-report + llvm-offload-wrapper + llvm-otool + llvm-pdbutil + llvm-profdata + llvm-profgen + llvm-ranlib + llvm-rc + llvm-readobj + llvm-readelf + llvm-reduce + llvm-remarkutil + llvm-rtdyld + llvm-sim + llvm-size + llvm-split + llvm-stress + llvm-strings + llvm-strip + llvm-symbolizer + llvm-tblgen + llvm-readtapi + llvm-tli-checker + llvm-undname + llvm-windres + llvm-xray + obj2yaml + opt + sancov + sanstats + split-file + verify-uselistorder + yaml-bench + yaml2obj + ) if(TARGET llvm-lto) set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-lto) @@ -263,39 +267,30 @@ set_target_properties(check-llvm PROPERTIES FOLDER "LLVM/Tests") # them with a reduced set of dependencies below. add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR} ${exclude_from_check_all} + DEPENDS ${LLVM_TEST_DEPENDS_COMMON} DEPENDS ${LLVM_TEST_DEPENDS} FOLDER "Tests/Subdirectories" - EXCLUDE_DIR TableGen - EXCLUDE_DIR FileCheck + EXCLUDE_DIRS "TableGen FileCheck" ) # Subset of dependencies for TableGen lit test. set(LLVM_TEST_TABLEGEN_DEPENDS - FileCheck - count - llvm-config - llvm-tblgen - not + llvm-tblgen ) add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR} ${exclude_from_check_all} + DEPENDS ${LLVM_TEST_DEPENDS_COMMON} DEPENDS ${LLVM_TEST_TABLEGEN_DEPENDS} FOLDER "Tests/Subdirectories" - INCLUDE_DIR TableGen - ) - -# Subset of dependencies for FileCheck lit test. -set(LLVM_TEST_FILECHECK_DEPENDS - FileCheck - not + INCLUDE_DIRS "TableGen" ) add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR} ${exclude_from_check_all} - DEPENDS ${LLVM_TEST_FILECHECK_DEPENDS} + DEPENDS ${LLVM_TEST_DEPENDS_COMMON} FOLDER "Tests/Subdirectories" - INCLUDE_DIR FileCheck + INCLUDE_DIRS "FileCheck" ) # Setup an alias for 'check-all'. From 9690778b9c81477003af3451cae47d09d55bea1f Mon Sep 17 00:00:00 2001 From: Rahul Joshi Date: Sun, 31 Aug 2025 05:38:29 -0700 Subject: [PATCH 3/3] Review feedback --- llvm/test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt index 270881e51da9a..45772c1360c63 100644 --- a/llvm/test/CMakeLists.txt +++ b/llvm/test/CMakeLists.txt @@ -263,8 +263,8 @@ add_lit_testsuite(check-llvm "Running the LLVM regression tests" ) set_target_properties(check-llvm PROPERTIES FOLDER "LLVM/Tests") -# Note, exclude TableGen and FileCheck directories as we define handle -# them with a reduced set of dependencies below. +# Note, exclude TableGen and FileCheck directories as we define them with a +# reduced set of dependencies below. add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR} ${exclude_from_check_all} DEPENDS ${LLVM_TEST_DEPENDS_COMMON}