Skip to content

[LIBCLC] Correctly track remangler test dependencies #7829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion libclc/cmake/modules/AddLibclc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ macro(add_libclc_builtin_set arch_suffix)
install(
FILES ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/${obj_suffix}
DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )

# Generate remangled variants if requested
if( LIBCLC_GENERATE_REMANGLED_VARIANTS )
set(dummy_in "${CMAKE_BINARY_DIR}/lib/clc/libclc_dummy_in.cc")
Expand Down Expand Up @@ -149,6 +149,29 @@ macro(add_libclc_builtin_set arch_suffix)
DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
endforeach()
endforeach()

# For remangler tests we do not care about long_width, or signedness, as it
# performs no substitutions.
# Collect all remangler tests in libclc-remangler-tests to later add
# dependency against check-libclc.
set(libclc-remangler-tests)
set(libclc-remangler-test-no 0)
set(libclc-remangler-target-ir
"$<TARGET_PROPERTY:opt.${obj_suffix},TARGET_FILE>"
"${LIBCLC_LIBRARY_OUTPUT_INTDIR}/builtins.link.${obj_suffix}"
"$<TARGET_PROPERTY:prepare-${obj_suffix},TARGET_FILE>")
foreach(target-ir ${libclc-remangler-target-ir})
math(EXPR libclc-remangler-test-no "${libclc-remangler-test-no}+1")
set(current-test "libclc-remangler-test-${obj_suffix}-${libclc-remangler-test-no}")
add_custom_target(${current-test}
COMMAND libclc-remangler
--long-width=l32
--char-signedness=signed
--input-ir=${target-ir}
${dummy_in} -t -o -
DEPENDS "${builtins_obj_path}" "prepare-${obj_suffix}" "${dummy_in}" libclc-remangler)
list(APPEND libclc-remangler-tests ${current-test})
endforeach()
endif()

# nvptx-- targets don't include workitem builtins
Expand Down
24 changes: 4 additions & 20 deletions libclc/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,9 @@ foreach( t ${LIBCLC_TARGET_TO_TEST} )
endforeach( t )

if(LIBCLC_GENERATE_REMANGLED_VARIANTS)
# Run remangler in test mode if generating remangled variants and make sure
# it depends on check-libclc target.
# Both `long_widths` and `char_signedness` are set in AddLibclc.cmake and can
# be used here.
foreach(long_width ${long_widths})
foreach(signedness ${char_signedness})
# In `-t` (TestRun) the remangler does not perform any substitutions, it
# needs to make sure that the remangled name matches the original mangled
# one.
set (test_target_name "test-remangled-${long_width}-${signedness}_char")
add_custom_target(${test_target_name}
COMMAND libclc-remangler
--long-width=${long_width}
--char-signedness=${signedness}
--input-ir="$<TARGET_PROPERTY:prepare-${obj_suffix},TARGET_FILE>"
${dummy_in} -t -o -
DEPENDS "${builtins_obj_path}" "prepare-${obj_suffix}" "${dummy_in}" libclc-remangler)

add_dependencies(check-libclc ${test_target_name})
endforeach()
#Now that check-libclc is defined make sure that all remangler targets depend
# on it.
foreach(remangler-test ${libclc-remangler-tests})
add_dependencies(check-libclc ${remangler-test})
endforeach()
endif()