Issue 179662
Summary llvm-cov / clang reports unreachable code as executed when function exits via exit()
Labels clang
Assignees
Reporter ankurrj7
    We have observed cases where code coverage reports generated using icx and llvm-cov mark unreachable code as executed, even though control flow cannot reach those lines at runtime.

In particular, when a function calls exit(), the compiler and coverage tools do not treat this call as a non-returning path, resulting in incorrect basic block / region coverage.

This leads to misleading coverage reports.

basic_block.c
 1|       |#include <stdio.h>
    2|       |#include <unistd.h>
    3|       |#include <stdlib.h>
    4|       |
    5|       |
    6|       |void fun1()
    7| 1|{
    8|      1|    printf("In some func never return\n");
    9| 1|    exit(0);
   10|      1|}
   11|       |
   12|       |int main(void)
   13|      1|{
   14|      1|    puts("This is a shared library test...");
   15|      1|    fun1();   // this will never return 
 16|      1|    printf("Hello 1\n"); // This is not reachable code , and cannot be marked as Hit
   17|      1|    if (1) {
   18|      0| printf("Hello 2\n");
   19|      0|    }
   20|      1|    return 0;
 21|      1|}
   22|       |

Here by no chance line number 16 should be marked as hit as func1 never returns . 
problem here is icx is not treating function call as end of previous region /block
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to