From 70d185c2e23073a6b26777fc2ee0666f9df7eee8 Mon Sep 17 00:00:00 2001 From: Jordan Patterson Date: Fri, 7 Nov 2025 13:16:48 -0500 Subject: [PATCH 1/2] cmake: Enable coverage when linking HIP. HIP linker will be used when linking C++ and HIP code together. --- cmake/AISCompilerOptions.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/AISCompilerOptions.cmake b/cmake/AISCompilerOptions.cmake index e5b2a02b..2f013be9 100644 --- a/cmake/AISCompilerOptions.cmake +++ b/cmake/AISCompilerOptions.cmake @@ -34,6 +34,7 @@ function (ais_set_compiler_flags target) if(BUILD_CODE_COVERAGE) target_compile_options(${target} PRIVATE $<$:-fprofile-instr-generate -fcoverage-mapping>) target_link_options(${target} PRIVATE $<$:-fprofile-instr-generate>) + target_link_options(${target} PRIVATE $<$:-fprofile-instr-generate>) endif() endforeach() From c6c7d26a8c124c97fc7bcbdd5fa539c03be3298a Mon Sep 17 00:00:00 2001 From: Jordan Patterson Date: Fri, 7 Nov 2025 13:19:26 -0500 Subject: [PATCH 2/2] util: Pass a file listing raw coverage files into llvm-profdata. --- util/llvm-coverage.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/llvm-coverage.sh b/util/llvm-coverage.sh index 98e2d318..f7fed53d 100755 --- a/util/llvm-coverage.sh +++ b/util/llvm-coverage.sh @@ -39,12 +39,14 @@ while getopts "b:ch" o; do esac done -readarray -d '' COV_FILES < <(find "$BUILD_DIR" -name "*.profraw" -print0) -if [ ${#COV_FILES[@]} -eq 0 ]; then +COV_FILES="$BUILD_DIR/coverage-files.txt" + +find "$BUILD_DIR" -name "*.profraw" >"$COV_FILES" +if [ ! -s "$COV_FILES" ]; then echo "No coverage files found" >>/dev/stderr exit 1 fi -llvm-profdata merge -output="$BUILD_DIR"/coverage.profdata "${COV_FILES[@]}" +llvm-profdata merge -output="$BUILD_DIR"/coverage.profdata --input-files="$COV_FILES" llvm-cov report "$COLOR_ARG" -instr-profile="$BUILD_DIR"/coverage.profdata -object="$BUILD_DIR"/rocfile/src/librocfile.so -object="$BUILD_DIR"/hipfile/src/amd_detail/libhipfile.so >"$BUILD_DIR"/coverage-report.txt llvm-cov show "$COLOR_ARG" -instr-profile="$BUILD_DIR"/coverage.profdata -object="$BUILD_DIR"/rocfile/src/librocfile.so -object="$BUILD_DIR"/hipfile/src/amd_detail/libhipfile.so >"$BUILD_DIR"/coverage-lines.txt