<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [LLVM-COV] Dead code following a call site has wrong coverage."
   href="https://bugs.llvm.org/show_bug.cgi?id=50839">50839</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[LLVM-COV] Dead code following a call site has wrong coverage.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Runtime Libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>libprofile library
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>cnwy1996@outlook.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ 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<stdio.h>
typedef unsigned int dev_t;
typedef unsigned int kdev_t;

static inline kdev_t to_kdev_t(int dev) {
  int major, minor;

  if (sizeof(kdev_t) == 16)
    return (kdev_t)dev;
  major = (dev >> 8);
  minor = (dev & 0xff);
  return (((major) << 22) | (minor));
}

void do_mknod(const char *filename, int mode, kdev_t dev) {
  if (dev == 0x15800078)
    exit(0);
  else
    abort();
}

int sys_mknod(const char *filename, int mode, dev_t dev) {
  int error;
  char *tmp;

  tmp = (char *)((unsigned int)filename*5+1);
  error = ((long)(tmp));
  do_mknod(tmp, mode, to_kdev_t(dev));
  printf("Executed!\n");
  return error;
}

int main(void) {
  if (sizeof(int) != 4)
    exit(0);

  return sys_mknod("test", 1, 0x12345678);
}

$ 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|       |#include<stdio.h>
    2|       |typedef unsigned int dev_t;
    3|       |typedef unsigned int kdev_t;
    4|       |
    5|      1|static inline kdev_t to_kdev_t(int dev) {
    6|      1|  int major, minor;
    7|      1|
    8|      1|  if (sizeof(kdev_t) == 16)
    9|      0|    return (kdev_t)dev;
   10|      1|  major = (dev >> 8);
   11|      1|  minor = (dev & 0xff);
   12|      1|  return (((major) << 22) | (minor));
   13|      1|}
   14|       |
   15|      1|void do_mknod(const char *filename, int mode, kdev_t dev) {
   16|      1|  if (dev == 0x15800078)
   17|      1|    exit(0);
   18|      0|  else
   19|      0|    abort();
   20|      1|}
   21|       |
   22|      1|int sys_mknod(const char *filename, int mode, dev_t dev) {
   23|      1|  int error;
   24|      1|  char *tmp;
   25|      1|
   26|      1|  tmp = (char *)((unsigned int)filename*5+1);
   27|      1|  error = ((long)(tmp));
   28|      1|  do_mknod(tmp, mode, to_kdev_t(dev));
   29|      1|  printf("Executed!\n");
   30|      1|  return error;
   31|      1|}
   32|       |
   33|      1|int main(void) {
   34|      1|  if (sizeof(int) != 4)
   35|      0|    exit(0);
   36|      1|
   37|      1|  return sys_mknod("test", 1, 0x12345678);
   38|      1|}

Line 29 and 30 were not executed.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>