Skip to content
Open
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
50 changes: 50 additions & 0 deletions .github/workflows/build-and-test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,53 @@ jobs:
path: aggregated-test-results/
if-no-files-found: warn
retention-days: 14

coverage-llvm:
name: LLVM Backend Code Coverage
runs-on: ubuntu-latest
timeout-minutes: 60
container:
image: docker.io/edgcpp/ci-runner:latest
defaults:
run:
shell: edg-container-exec "bash -eo pipefail {0}"
steps:
- name: Check out repository
uses: actions/checkout@v7

- name: Configure CMake with coverage
env:
EDG_BASE: ${{ github.workspace }}/bases/docker/dev-env/gcc
run: |
cmake --preset linux-gcc-debug \
-DEDG_CPFE_USE_GCOV=TRUE \
-DENABLE_LLVM_BACKEND=TRUE

- name: Build cpfe
env:
EDG_BASE: ${{ github.workspace }}/bases/docker/dev-env/gcc
run: cmake --build build/gcc --target cpfe

- name: Run LLVM Tests
env:
RUN_LLVM_LINK_TESTS: "1"
run: |
mkdir -p build/test_llvm_enabled/bin
cp build/gcc/bin/cpfe build/test_llvm_enabled/bin/
./tests/test_llvm_globals.sh
./tests/test_llvm_functions.sh
./tests/test_llvm_expressions.sh
./tests/test_llvm_control_flow.sh
./tests/test_llvm_output_generation.sh

- name: Check 100% Coverage for llvm_gen_be.cpp
run: |
cd build/gcc
gcov -r ../../src/llvm_gen_be.cpp
# Ensure coverage fails if not 100
if ! grep -q "Lines executed:100.00% of" llvm_gen_be.cpp.gcov; then
echo "FAIL: llvm_gen_be.cpp does not have 100% code coverage."
cat llvm_gen_be.cpp.gcov
exit 1
fi
echo "PASS: llvm_gen_be.cpp has 100% code coverage."
38 changes: 38 additions & 0 deletions .github/workflows/llvm_be_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: LLVM Backend Coverage

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake llvm-14-dev clang-14 lcov valgrind

- name: Run Tests with Coverage
run: |
export CXX=clang++-14
export CC=clang-14
OUTPUT=$(./dev_tools/bin/run_coverage.sh)
echo "$OUTPUT"
if ! echo "$OUTPUT" | grep -q "100%"; then
echo "Coverage is below strict 100% threshold!"
exit 1
fi

- name: Run Valgrind Tests
run: |
export CXX=clang++-14
export CC=clang-14
cmake -S . -B build/valgrind -DBUILD_TESTING=ON -DENABLE_LLVM_BACKEND=ON
cmake --build build/valgrind
cd build/valgrind
ctest -T memcheck
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ if(NOT DEFINED EDG_PREFERRED_LINKER)
endif()

# Only use lld with Clang, it doesn't understand GCC's LTO format well (at
# least at the time of writing).
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# least at the time of writing). Do not use lld on Apple due to TAPI bugs.
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT APPLE)
if(NOT DEFINED EDG_PREFERRED_LINKER_TRIAL)
find_program(LLD_LINKER ld.lld NO_CACHE)
if(NOT LLD_LINKER STREQUAL "LLD_LINKER-NOTFOUND")
Expand Down Expand Up @@ -145,3 +145,8 @@ include(${CMAKE_SOURCE_DIR}/cmake/wrapper.cmake)
# Handle wrapping eccp, needed for building the C library, and general
# development
add_edg_wrapper_script(eccp "." ${CMAKE_SOURCE_DIR}/util/eccp.sh)

if(BUILD_TESTING)
add_subdirectory(tests)
endif()
enable_testing()
Loading