Skip to content

Commit 74af442

Browse files
authored
[LIBCLC] Correctly track remangler test dependencies (#7829)
Make sure that remanger is tested with all of the following: * builtins.opt.clc- * builtins.link.clc- * clc-
1 parent abdc0fe commit 74af442

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ macro(add_libclc_builtin_set arch_suffix)
105105
install(
106106
FILES ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/${obj_suffix}
107107
DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
108-
108+
109109
# Generate remangled variants if requested
110110
if( LIBCLC_GENERATE_REMANGLED_VARIANTS )
111111
set(dummy_in "${CMAKE_BINARY_DIR}/lib/clc/libclc_dummy_in.cc")
@@ -149,6 +149,29 @@ macro(add_libclc_builtin_set arch_suffix)
149149
DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
150150
endforeach()
151151
endforeach()
152+
153+
# For remangler tests we do not care about long_width, or signedness, as it
154+
# performs no substitutions.
155+
# Collect all remangler tests in libclc-remangler-tests to later add
156+
# dependency against check-libclc.
157+
set(libclc-remangler-tests)
158+
set(libclc-remangler-test-no 0)
159+
set(libclc-remangler-target-ir
160+
"$<TARGET_PROPERTY:opt.${obj_suffix},TARGET_FILE>"
161+
"${LIBCLC_LIBRARY_OUTPUT_INTDIR}/builtins.link.${obj_suffix}"
162+
"$<TARGET_PROPERTY:prepare-${obj_suffix},TARGET_FILE>")
163+
foreach(target-ir ${libclc-remangler-target-ir})
164+
math(EXPR libclc-remangler-test-no "${libclc-remangler-test-no}+1")
165+
set(current-test "libclc-remangler-test-${obj_suffix}-${libclc-remangler-test-no}")
166+
add_custom_target(${current-test}
167+
COMMAND libclc-remangler
168+
--long-width=l32
169+
--char-signedness=signed
170+
--input-ir=${target-ir}
171+
${dummy_in} -t -o -
172+
DEPENDS "${builtins_obj_path}" "prepare-${obj_suffix}" "${dummy_in}" libclc-remangler)
173+
list(APPEND libclc-remangler-tests ${current-test})
174+
endforeach()
152175
endif()
153176

154177
# nvptx-- targets don't include workitem builtins

libclc/test/CMakeLists.txt

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,9 @@ foreach( t ${LIBCLC_TARGET_TO_TEST} )
4545
endforeach( t )
4646

4747
if(LIBCLC_GENERATE_REMANGLED_VARIANTS)
48-
# Run remangler in test mode if generating remangled variants and make sure
49-
# it depends on check-libclc target.
50-
# Both `long_widths` and `char_signedness` are set in AddLibclc.cmake and can
51-
# be used here.
52-
foreach(long_width ${long_widths})
53-
foreach(signedness ${char_signedness})
54-
# In `-t` (TestRun) the remangler does not perform any substitutions, it
55-
# needs to make sure that the remangled name matches the original mangled
56-
# one.
57-
set (test_target_name "test-remangled-${long_width}-${signedness}_char")
58-
add_custom_target(${test_target_name}
59-
COMMAND libclc-remangler
60-
--long-width=${long_width}
61-
--char-signedness=${signedness}
62-
--input-ir="$<TARGET_PROPERTY:prepare-${obj_suffix},TARGET_FILE>"
63-
${dummy_in} -t -o -
64-
DEPENDS "${builtins_obj_path}" "prepare-${obj_suffix}" "${dummy_in}" libclc-remangler)
65-
66-
add_dependencies(check-libclc ${test_target_name})
67-
endforeach()
48+
#Now that check-libclc is defined make sure that all remangler targets depend
49+
# on it.
50+
foreach(remangler-test ${libclc-remangler-tests})
51+
add_dependencies(check-libclc ${remangler-test})
6852
endforeach()
6953
endif()

0 commit comments

Comments
 (0)