Issue 125563
Summary False branch coverage
Labels new issue
Assignees
Reporter amal-khailtash
    We were using version `llvm/19.1.5` and we also moved to latest version `llvm/19.1.7` and the same problem persists.  We have this piece of code as part of a bigger multi-threaded code that seems to show a problematic branch coverage that I cannot explain.

The `some_function` only returns if one of those `avail` flags is `true`.  There is NO possibility of that function returning with all `avail` values being `false`. This has been confirmed by adding assertions to the code as below.

```CPP
/* 3.91k */     bool avail[3];
/* 3.91k */ some_function(avail);
                {
/* 3.91k */         if ( avail[2] )
                    // Branch: [True: 0, False: 3.91k]
/* 3.91k */         {
/* 3.91k */             ...
                    }

/* 3.91k */         else if ( avail[0] )
                    // Branch: [True: 3.91k, False: 4]
/* 3.91k */         {
/* 3.91k */             ...
/* 3.91k */ }

/* 4     */         else if ( avail[1] )
                    // Branch: [True: 0, False: 4]
/* 0     */         {
/* 0     */ ...
/* 0     */         }

/* 4     */         else
/* 4     */ {
/* 4     */             assert(0);
                        // Branch: [Folded - Ignored]
/* 4     */             ...
/* 4     */         }
/* 4 */     }

/* 3.91k */     if ( avail == 0 )
                // Branch: [True: 0, False: 3.91k]
/* 0     */     {
/* 0     */ assert(0);
                        // Branch: [Folded - Ignored]
/* 0 */             ...
/* 0     */     }
```

The problem is the 4 hits on the else branch here:

```CPP
/* 4     */         else if ( avail[1] )
 // Branch: [True: 0, False: 4]
/* 0     */         {
/* 0 */             ...
/* 0     */         }

/* 4     */         else
/* 4     */         {
/* 4     */             assert(0);
 // Branch: [Folded - Ignored]
/* 4     */             ...
/* 4     */ }
/* 4     */     }
```

I cannot see that we reach this point of the program and hitting the else branch!  But `llvm-cov` seems to indicate that we do.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to