Skip to content

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

@schittir

Description

@schittir

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

#include <stdlib.h>
#include <stdio.h>

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: 181dfe4

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.coveragequestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions