[runtimes] Aggregate per-target runtime checks in top-level check-${runtime_name} (#191743)

When a per-target runtime build exports a
check-${runtime_name}-${target} proxy, make the top-level
check-${runtime_name} target depend on it, creating
check-${runtime_name} on demand (it may not exist).

This applies regardless of whether the runtime comes from the default
LLVM_ENABLE_RUNTIMES set or from a target-specific
RUNTIMES_<target>_LLVM_ENABLE_RUNTIMES override.

This allows a single `check-${runtime_name}` command to trigger all
per-target tests for that runtime.
diff --git a/.ci/compute_projects.py b/.ci/compute_projects.py
index e4532adc..178ebc6 100644
--- a/.ci/compute_projects.py
+++ b/.ci/compute_projects.py
@@ -153,7 +153,7 @@
     "flang": "check-flang",
     "flang-rt": "check-flang-rt",
     "libc": "check-libc",
-    "libclc": "check-libclc-amdgcn-amd-amdhsa-llvm",
+    "libclc": "check-libclc",
     "lld": "check-lld",
     "lldb": "check-lldb",
     "mlir": "check-mlir",
diff --git a/.ci/compute_projects_test.py b/.ci/compute_projects_test.py
index b8504a5..63fed49 100644
--- a/.ci/compute_projects_test.py
+++ b/.ci/compute_projects_test.py
@@ -268,7 +268,7 @@
         self.assertEqual(env_variables["runtimes_to_build"], "")
         self.assertEqual(
             env_variables["runtimes_check_targets"],
-            "check-libclc-amdgcn-amd-amdhsa-llvm",
+            "check-libclc",
         )
         self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
 
@@ -310,7 +310,7 @@
         )
         self.assertEqual(
             env_variables["runtimes_check_targets"],
-            "check-compiler-rt check-flang-rt check-libc check-libclc-amdgcn-amd-amdhsa-llvm",
+            "check-compiler-rt check-flang-rt check-libc check-libclc",
         )
         self.assertEqual(
             env_variables["runtimes_check_targets_needs_reconfig"],
@@ -335,7 +335,7 @@
         )
         self.assertEqual(
             env_variables["runtimes_check_targets"],
-            "check-compiler-rt check-libclc-amdgcn-amd-amdhsa-llvm",
+            "check-compiler-rt check-libclc",
         )
         self.assertEqual(
             env_variables["runtimes_check_targets_needs_reconfig"],
@@ -384,7 +384,7 @@
         )
         self.assertEqual(
             env_variables["runtimes_check_targets"],
-            "check-compiler-rt check-flang-rt check-libc check-libclc-amdgcn-amd-amdhsa-llvm",
+            "check-compiler-rt check-flang-rt check-libc check-libclc",
         )
         self.assertEqual(
             env_variables["runtimes_check_targets_needs_reconfig"],
@@ -419,7 +419,7 @@
         )
         self.assertEqual(
             env_variables["runtimes_check_targets"],
-            "check-compiler-rt check-flang-rt check-libc check-libclc-amdgcn-amd-amdhsa-llvm",
+            "check-compiler-rt check-flang-rt check-libc check-libclc",
         )
         self.assertEqual(
             env_variables["runtimes_check_targets_needs_reconfig"],
diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh
index 9d9c3de..29b0bdb 100755
--- a/.ci/monolithic-linux.sh
+++ b/.ci/monolithic-linux.sh
@@ -32,7 +32,7 @@
 lit_args="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-output-file-name --timeout=1200 --time-tests --succinct"
 
 runtime_cmake_args=()
-if [[ " ${runtime_targets} " == *" check-libclc-amdgcn-amd-amdhsa-llvm "* ]]; then
+if [[ " ${runtime_targets} " == *" check-libclc "* ]]; then
   runtime_cmake_args+=(
     -D RUNTIMES_amdgcn-amd-amdhsa-llvm_LLVM_ENABLE_RUNTIMES=libclc
     -D LLVM_RUNTIME_TARGETS="default;amdgcn-amd-amdhsa-llvm"
diff --git a/.ci/monolithic-windows.sh b/.ci/monolithic-windows.sh
index 795893c..67cbebb 100755
--- a/.ci/monolithic-windows.sh
+++ b/.ci/monolithic-windows.sh
@@ -21,7 +21,7 @@
 runtimes_targets="${4}"
 
 runtime_cmake_args=()
-if [[ " ${runtimes_targets} " == *" check-libclc-amdgcn-amd-amdhsa-llvm "* ]]; then
+if [[ " ${runtimes_targets} " == *" check-libclc "* ]]; then
   runtime_cmake_args+=(
     -D RUNTIMES_amdgcn-amd-amdhsa-llvm_LLVM_ENABLE_RUNTIMES=libclc
     -D LLVM_RUNTIME_TARGETS="default;amdgcn-amd-amdhsa-llvm"
diff --git a/libclc/README.md b/libclc/README.md
index f50a931..81ce155 100644
--- a/libclc/README.md
+++ b/libclc/README.md
@@ -85,11 +85,22 @@
 DESTDIR=/path/for/staged/install ninja install
 ```
 
-## Run tests
+## Testing
+libclc utilizes the LLVM testing infrastructure.
+#### Run all tests
+To execute all per-target tests for libclc.
+```
+ninja check-libclc
+```
+`check-libclc` is a top-level target that aggregates all per-target tests.
+
+#### Run target-specific tests
+If you are working on a specific target, you can run tests for just that target triple:
 ```
 ninja check-libclc-<target-triple>
 ```
-or
+Alternatively, you can run target-specific tests via the runtimes build by
+pointing to the target-specific build directory:
 ```
 ninja -C runtimes/runtimes-<target-triple>-bins check-libclc
 ```
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index dfa8369..c447955 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -462,6 +462,15 @@
     if(TARGET builtins-${name})
       add_dependencies(check-builtins check-builtins-${name})
     endif()
+
+    foreach(runtime_name ${runtime_names})
+      if(TARGET check-${runtime_name}-${name})
+        if(NOT TARGET check-${runtime_name})
+          add_custom_target(check-${runtime_name})
+        endif()
+        add_dependencies(check-${runtime_name} check-${runtime_name}-${name})
+      endif()
+    endforeach()
   endif()
   foreach(runtime_name ${runtime_names})
     if(NOT TARGET ${runtime_name})