[clang] [CIR] Minimize dependencies of check-clang-cir (PR #227957)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 1 22:58:40 PDT 2026
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/227957
>From 6f25d991371237b5eb4939c88c0a3e9f3d49af3f Mon Sep 17 00:00:00 2001
From: Andy Kaylor <akaylor at nvidia.com>
Date: Wed, 30 Sep 2026 22:06:04 -0700
Subject: [PATCH 1/3] [CIR] Minimize dependencies for check-clang-cir
This adds special handling for the CIR test directories so that they
depend only on the components needed to run those tests. The goal of
this is to minimize what needs to be built to verify that MLIR changes
haven't broken CIR. There is no need to run the full set of Clang tests
to verify an MLIR change, since only CIR depends on MLIR.
Assisted-by: Cursor / various models
---
clang/test/CMakeLists.txt | 43 +++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index b8adfa799bcae52..1aaafde1d576f73 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -238,11 +238,54 @@ add_lit_testsuite(check-clang "Running the Clang regression tests"
ARGS ${CLANG_TEST_EXTRA_ARGS}
)
+# Skip CIR here. check-clang above still runs these tests. The check-clang-cir
+# target is created explicitly below so that it (and its subdirectory-based
+# sub-targets) depend only on the tools those tests invoke and the tools
+# required to load clang/test/lit.cfg.py.
add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${CLANG_TEST_DEPS}
FOLDER "Clang tests/Suites"
+ SKIP "^CIR"
)
+# These tools are resolved while loading clang/test/lit.cfg.py, or invoked
+# directly by tests under clang/test/CIR.
+set(CLANG_CIR_TEST_DEPS
+ clang
+ )
+if(CLANG_ENABLE_CIR)
+ list(APPEND CLANG_CIR_TEST_DEPS
+ cir-opt
+ cir-translate
+ )
+endif()
+if(NOT CLANG_BUILT_STANDALONE)
+ list(APPEND CLANG_CIR_TEST_DEPS
+ FileCheck
+ count
+ llvm-config
+ llvm-dis
+ llvm-objdump
+ not
+ opt
+ split-file
+ )
+endif()
+
+# add_lit_testsuites creates no targets when LLVM_ENABLE_IDE is on.
+if(NOT LLVM_ENABLE_IDE)
+ add_lit_target(check-clang-cir "Running the CIR regression tests"
+ ${CMAKE_CURRENT_SOURCE_DIR}/CIR
+ DEPENDS ${CLANG_CIR_TEST_DEPS}
+ )
+ set_target_properties(check-clang-cir PROPERTIES FOLDER "Clang tests/Suites")
+
+ add_lit_testsuites(CLANG-CIR ${CMAKE_CURRENT_SOURCE_DIR}/CIR
+ DEPENDS ${CLANG_CIR_TEST_DEPS}
+ FOLDER "Clang tests/Suites"
+ )
+endif()
+
# Add a legacy target spelling: clang-test
add_custom_target(clang-test)
add_dependencies(clang-test check-clang)
>From f280ab9afb1a0b02e72c5f2671e8a2020771efde Mon Sep 17 00:00:00 2001
From: Andy Kaylor <akaylor at nvidia.com>
Date: Thu, 1 Oct 2026 12:29:25 -0700
Subject: [PATCH 2/3] Don't add check-clang-cir if CIR isn't enabled
---
clang/test/CMakeLists.txt | 64 +++++++++++++++++++--------------------
1 file changed, 31 insertions(+), 33 deletions(-)
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 1aaafde1d576f73..b47ed5bf6716cdb 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -238,9 +238,9 @@ add_lit_testsuite(check-clang "Running the Clang regression tests"
ARGS ${CLANG_TEST_EXTRA_ARGS}
)
-# Skip CIR here. check-clang above still runs these tests. The check-clang-cir
-# target is created explicitly below so that it (and its subdirectory-based
-# sub-targets) depend only on the tools those tests invoke and the tools
+# Skip CIR here. check-clang above still discovers these tests, but they do
+# nothing unless CIR is enabled. When CIR is enabled, the check-clang-cir
+# targets below depend only on the tools those tests invoke and the tools
# required to load clang/test/lit.cfg.py.
add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${CLANG_TEST_DEPS}
@@ -248,42 +248,40 @@ add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}
SKIP "^CIR"
)
-# These tools are resolved while loading clang/test/lit.cfg.py, or invoked
-# directly by tests under clang/test/CIR.
-set(CLANG_CIR_TEST_DEPS
- clang
- )
if(CLANG_ENABLE_CIR)
- list(APPEND CLANG_CIR_TEST_DEPS
+ # These tools are resolved while loading clang/test/lit.cfg.py, or invoked
+ # directly by tests under clang/test/CIR.
+ set(CLANG_CIR_TEST_DEPS
+ clang
cir-opt
cir-translate
)
-endif()
-if(NOT CLANG_BUILT_STANDALONE)
- list(APPEND CLANG_CIR_TEST_DEPS
- FileCheck
- count
- llvm-config
- llvm-dis
- llvm-objdump
- not
- opt
- split-file
- )
-endif()
+ if(NOT CLANG_BUILT_STANDALONE)
+ list(APPEND CLANG_CIR_TEST_DEPS
+ FileCheck
+ count
+ llvm-config
+ llvm-dis
+ llvm-objdump
+ not
+ opt
+ split-file
+ )
+ endif()
-# add_lit_testsuites creates no targets when LLVM_ENABLE_IDE is on.
-if(NOT LLVM_ENABLE_IDE)
- add_lit_target(check-clang-cir "Running the CIR regression tests"
- ${CMAKE_CURRENT_SOURCE_DIR}/CIR
- DEPENDS ${CLANG_CIR_TEST_DEPS}
- )
- set_target_properties(check-clang-cir PROPERTIES FOLDER "Clang tests/Suites")
+ # add_lit_testsuites creates no targets when LLVM_ENABLE_IDE is on.
+ if(NOT LLVM_ENABLE_IDE)
+ add_lit_target(check-clang-cir "Running the CIR regression tests"
+ ${CMAKE_CURRENT_SOURCE_DIR}/CIR
+ DEPENDS ${CLANG_CIR_TEST_DEPS}
+ )
+ set_target_properties(check-clang-cir PROPERTIES FOLDER "Clang tests/Suites")
- add_lit_testsuites(CLANG-CIR ${CMAKE_CURRENT_SOURCE_DIR}/CIR
- DEPENDS ${CLANG_CIR_TEST_DEPS}
- FOLDER "Clang tests/Suites"
- )
+ add_lit_testsuites(CLANG-CIR ${CMAKE_CURRENT_SOURCE_DIR}/CIR
+ DEPENDS ${CLANG_CIR_TEST_DEPS}
+ FOLDER "Clang tests/Suites"
+ )
+ endif()
endif()
# Add a legacy target spelling: clang-test
>From 78509b544be25f0b675d5b3ce9c92d82334f2a1b Mon Sep 17 00:00:00 2001
From: Andy Kaylor <akaylor at nvidia.com>
Date: Thu, 1 Oct 2026 22:57:51 -0700
Subject: [PATCH 3/3] Drop LLVM_ENABLE_IDE guard
---
clang/test/CMakeLists.txt | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index b47ed5bf6716cdb..723015809332113 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -269,19 +269,16 @@ if(CLANG_ENABLE_CIR)
)
endif()
- # add_lit_testsuites creates no targets when LLVM_ENABLE_IDE is on.
- if(NOT LLVM_ENABLE_IDE)
- add_lit_target(check-clang-cir "Running the CIR regression tests"
- ${CMAKE_CURRENT_SOURCE_DIR}/CIR
- DEPENDS ${CLANG_CIR_TEST_DEPS}
- )
- set_target_properties(check-clang-cir PROPERTIES FOLDER "Clang tests/Suites")
+ add_lit_target(check-clang-cir "Running the CIR regression tests"
+ ${CMAKE_CURRENT_SOURCE_DIR}/CIR
+ DEPENDS ${CLANG_CIR_TEST_DEPS}
+ )
+ set_target_properties(check-clang-cir PROPERTIES FOLDER "Clang tests/Suites")
- add_lit_testsuites(CLANG-CIR ${CMAKE_CURRENT_SOURCE_DIR}/CIR
- DEPENDS ${CLANG_CIR_TEST_DEPS}
- FOLDER "Clang tests/Suites"
- )
- endif()
+ add_lit_testsuites(CLANG-CIR ${CMAKE_CURRENT_SOURCE_DIR}/CIR
+ DEPENDS ${CLANG_CIR_TEST_DEPS}
+ FOLDER "Clang tests/Suites"
+ )
endif()
# Add a legacy target spelling: clang-test
More information about the cfe-commits
mailing list