[llvm-bugs] [Bug 49429] New: [LLVM-COV] Execute once and return twice

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 4 00:16:55 PST 2021


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

            Bug ID: 49429
           Summary: [LLVM-COV] Execute once and return twice
           Product: Runtime Libraries
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: libprofile library
          Assignee: unassignedbugs at nondot.org
          Reporter: cnwy1996 at outlook.com
                CC: llvm-bugs at lists.llvm.org

$ 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
union U {
  int f0;
  unsigned char f1;
};

int main() {
  int i = 0;
  union U u = {0};
  for (u.f1 = 0; u.f1 != -2; ++u.f1) {
    i ^= u.f1;  
    if (i < 1)  
      return 0; 
  }
  return 1;
}

$ 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
    1|       |union U {
    2|       |  int f0;
    3|       |  unsigned char f1;
    4|       |};
    5|       |
    6|      1|int main() {
    7|      1|  int i = 0;
    8|      1|  union U u = {0};
    9|      1|  for (u.f1 = 0; u.f1 != -2; ++u.f1) {
   10|      1|    i ^= u.f1;  
   11|      1|    if (i < 1)  
   12|      1|      return 0; 
   13|      1|  }
   14|      1|  return 1;
   15|      1|}
   16|       |

Line #14 should not be executed

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210304/9740710f/attachment-0001.html>


More information about the llvm-bugs mailing list