https://bugs.llvm.org/show_bug.cgi?id=50777

            Bug ID: 50777
           Summary: [LLVM-COV] No coverage with goto and label
           Product: Runtime Libraries
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libprofile library
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

$ clang -v
clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/wangyang/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ cat test.c
#include <stdlib.h>
#include<stdio.h>

short a = 65531;
int b = 3, f;
signed char c, d;
static void fn1(int p1) {
  short e;
  b = f;
  if (f > p1 && p1)
  L:
    for (printf("Executed!\n"); 0;)
      ;
  else if (d)
    b = 0 >= b;
  for (; e <= 3; e++) {
    if (b)
      continue;
    b = 3;
    goto L;
  }
}

int main() {
  for (; c >= 0; c--) {
    fn1(a);
  }
  return 0;
}

$ clang -w -O0 -g -fcoverage-mapping -fprofile-instr-generate=test.profraw
test.c; ./a.out; llvm-profdata merge test.profraw -o test.profdata; llvm-cov
show a.out -instr-profile=test.profdata test.c > test.lcov; cat test.lcov
Executed!
Executed!
    1|       |#include <stdlib.h>
    2|       |#include<stdio.h>
    3|       |
    4|       |short a = 65531;
    5|       |int b = 3, f;
    6|       |signed char c, d;
    7|      1|static void fn1(int p1) {
    8|      1|  short e;
    9|      1|  b = f;
   10|      1|  if (f > p1 && p1)
   11|      3|  L:
   12|      3|    for (printf("Executed!\n"); 0;)
   13|      0|      ;
   14|      0|  else if (d)
   15|      0|    b = 0 >= b;
   16|      6|  for (; e <= 3; e++) {
   17|      5|    if (b)
   18|      4|      continue;
   19|      1|    b = 3;
   20|      1|    goto L;
   21|      1|  }
   22|      2|}
   23|       |
   24|      1|int main() {
   25|      2|  for (; c >= 0; c--) {
   26|      1|    fn1(a);
   27|      1|  }
   28|      1|  return 0;
   29|      1|}

Line 11 and 12 should only be executed 2 twice

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to