mirror of
https://github.com/YosysHQ/yosys
synced 2026-06-02 15:18:07 +00:00
Convert to using LLVM code coverage
This commit is contained in:
parent
6ac8758e7e
commit
8022b5445b
3 changed files with 22 additions and 10 deletions
9
.github/workflows/test-verific.yml
vendored
9
.github/workflows/test-verific.yml
vendored
|
|
@ -44,6 +44,14 @@ jobs:
|
||||||
- name: Runtime environment
|
- name: Runtime environment
|
||||||
run: |
|
run: |
|
||||||
echo "procs=$(nproc)" >> $GITHUB_ENV
|
echo "procs=$(nproc)" >> $GITHUB_ENV
|
||||||
|
mkdir -p "${GITHUB_WORKSPACE}/coverage"
|
||||||
|
echo "LLVM_PROFILE_FILE=${GITHUB_WORKSPACE}/coverage/coverage_%p.profraw" >> $GITHUB_ENV
|
||||||
|
echo "LLVM_PROFILE_FILE_BUFFER_SIZE=0" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Skip generating files
|
||||||
|
if: ${{ github.event_name != 'merge_group' && github.event_name != 'workflow_dispatch' }}
|
||||||
|
run: |
|
||||||
|
echo "LLVM_PROFILE_FILE=/dev/null" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build Yosys
|
- name: Build Yosys
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -89,6 +97,7 @@ jobs:
|
||||||
if: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
|
if: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
|
||||||
run: |
|
run: |
|
||||||
make coverage
|
make coverage
|
||||||
|
make clean_coverage
|
||||||
|
|
||||||
- name: Push coverage
|
- name: Push coverage
|
||||||
if: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
|
if: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
|
||||||
|
|
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -65,10 +65,10 @@
|
||||||
/viz.js
|
/viz.js
|
||||||
|
|
||||||
# other
|
# other
|
||||||
/coverage.info
|
/yosys.profdata
|
||||||
|
/coverage
|
||||||
/coverage_html
|
/coverage_html
|
||||||
|
|
||||||
|
|
||||||
# these really belong in global gitignore since they're not specific to this project but rather to user tool choice
|
# these really belong in global gitignore since they're not specific to this project but rather to user tool choice
|
||||||
# but too many people don't have a global gitignore configured:
|
# but too many people don't have a global gitignore configured:
|
||||||
# https://docs.github.com/en/get-started/git-basics/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
|
# https://docs.github.com/en/get-started/git-basics/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
|
||||||
|
|
|
||||||
19
Makefile
19
Makefile
|
|
@ -456,8 +456,11 @@ endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_GCOV),1)
|
ifeq ($(ENABLE_GCOV),1)
|
||||||
CXXFLAGS += --coverage
|
LLVM_PROFILE_FILE ?= $(realpath $(YOSYS_SRC))/coverage/coverage_%p.profraw
|
||||||
LINKFLAGS += --coverage
|
export LLVM_PROFILE_FILE
|
||||||
|
export LLVM_PROFILE_FILE_BUFFER_SIZE=0
|
||||||
|
CXXFLAGS += -fprofile-instr-generate -fcoverage-mapping
|
||||||
|
LINKFLAGS+= -fprofile-instr-generate
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_GPROF),1)
|
ifeq ($(ENABLE_GPROF),1)
|
||||||
|
|
@ -1115,13 +1118,13 @@ mrproper: clean
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
./$(PROGRAM_PREFIX)yosys -qp 'help; help -all'
|
./$(PROGRAM_PREFIX)yosys -qp 'help; help -all'
|
||||||
rm -rf coverage.info coverage_html
|
rm -rf coverage_html
|
||||||
lcov --capture -d . --no-external -o coverage.info
|
llvm-profdata merge -sparse coverage/coverage_*.profraw -o yosys.profdata
|
||||||
lcov --remove coverage.info '*/tests/various/*' '*/libs/*' -o coverage.info --ignore-errors unused
|
llvm-cov show ./$(PROGRAM_PREFIX)yosys -instr-profile=yosys.profdata -format=html -output-dir=coverage_html --compilation-dir=. -ignore-filename-regex='(^|.*/)Verific/.*|(^|.*/)libs/.*'
|
||||||
genhtml coverage.info --output-directory coverage_html
|
|
||||||
|
|
||||||
clean_coverage:
|
clean_coverage:
|
||||||
find . -name "*.gcda" -type f -delete
|
rm -rf coverage
|
||||||
|
rm -f yosys.profdata
|
||||||
|
|
||||||
FUNC_KERNEL := functional.cc functional.h sexpr.cc sexpr.h compute_graph.h
|
FUNC_KERNEL := functional.cc functional.h sexpr.cc sexpr.h compute_graph.h
|
||||||
FUNC_INCLUDES := $(addprefix --include *,functional/* $(FUNC_KERNEL))
|
FUNC_INCLUDES := $(addprefix --include *,functional/* $(FUNC_KERNEL))
|
||||||
|
|
@ -1183,7 +1186,7 @@ config-msys2-64: clean
|
||||||
echo "PREFIX := $(MINGW_PREFIX)" >> Makefile.conf
|
echo "PREFIX := $(MINGW_PREFIX)" >> Makefile.conf
|
||||||
|
|
||||||
config-gcov: clean
|
config-gcov: clean
|
||||||
echo 'CONFIG := gcc' > Makefile.conf
|
echo 'CONFIG := clang' > Makefile.conf
|
||||||
echo 'ENABLE_GCOV := 1' >> Makefile.conf
|
echo 'ENABLE_GCOV := 1' >> Makefile.conf
|
||||||
echo 'ENABLE_DEBUG := 1' >> Makefile.conf
|
echo 'ENABLE_DEBUG := 1' >> Makefile.conf
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue