llvm / llvm/llvm-project

Code coverage issue - unreachable code is incorrectly being marked as hit by code coverage tool

Open
#175,281 7 comments 0 reactions 0 assignees View on GitHub
clang:codegen coverage question
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

llvm-cov code coverage tool incorrectly marks the following code as reachable.
This example illustrates the issue: https://godbolt.org/z/ha8PMGGG9

```
#include
#include

void good() {
exit(0);
puts("never get here"); // Code coverage correctly says this is not reached
}

void inner() {
exit(0);
}

void bad() {
inner();
puts("never get here"); // Code coverage says we reach this
}
```

This commit terminates region when noreturn funtion is hit: https://github.com/llvm/llvm-project/commit/181dfe4c92ad2671a4ff5c2d91d927dd5a9958b8

Additional instructions to reproduce this issue in a local workspace:
o clang -c code-cov-issue.c -fprofile-instr-generate -fcoverage-mapping
o clang -o app.exe code-cov-issue.o -fprofile-instr-generate
o ./app.exe
o llvm-profdata merge -o app.profdata *.profraw
o llvm-cov show --instr-profile=app.profdata ./app.exe

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.