<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/125563>125563</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            False branch coverage
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          amal-khailtash
      </td>
    </tr>
</table>

<pre>
    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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8Vk1v2zgQ_TX0ZRCBoix_HHSwaxjoZbeHAD0uRtJY5JYiDZKyN_9-QUlOY9dKmm6zhC-05uu94ZAPvVeNISpYvmX5boZdkNYV2KJ--CZR6YBezkpbPxVfCc7kCDqvTAMncl5ZA2zBtT61TOzTdZImOVtwQFPDmQC1t9DaE9UQLGgM5MOU3_LiFySBx5bg6GypqYVjdPDBJwBfCSSeCIJUHo6KKgJ7gMrWBOjhiC7EPUKpmoYctJ0O6iFIR1hTPdgFiQE8UetjTV7aM-AlFQZVQenQVBIqeyKHzejwGSo0xgagf44alUkY3zC-eZQUcXjb0l-HzlRBWRNxWKOfwFHonPGgDmBNX2iQ1vcOeEKlo-FBY-NB-fhncB2xBU8AHmWkWXn44084Wu9VqbQKT0MIDHBJNaaI3TirIAG1vop-Qt2Rh5KiBVvwA2o_pHiMBEqM38hAZc1BuZZqKJ8A6zqao_fkYpKep9iUC80laXseCWALPvw-ffkSt2LPxAayZJ1-AybiHuIqrdUwlJVvM5bvWLadML_mUqwGL7EePOBmseVUnMtSB2Bi9ZxcsHwHMdyPsfp4MdIetv0ZYNkGWL59jH3JNsCZ-AT7nsJsTBaRvJ7-7QLjSpJkqqDlbmT6lRCkPd0C5b8OdID2Euz89wK9Z3ULdD6W-SbQ9Hd19Bokv5f_CuSVxRWwCd-fBDhhcpX7rnNcw9gyseKTM_MaM3ur4035AJ8bYx3VV5RMJr0Cf9dqBH-xePH1zQP-st3Ash3LdsAnGv5fxveHpk03-yNJ5m8SfKfQ3cur-PvTdHlBle8v8DlIFTxY0-_6WRofu_jesGzz2p3-S_P4kcP3bprunbb3DuHdWt41jP_H1N1M288cl2eB42mUPGcCR1jJUWxZZcIgQPpz1Thse7kmVQhRL9wcKSZSgG0XLjLvobKnKEmelZcytaowfE9W22RWF1m9ztY4oyJdZqtFKtI8nckiX1SHwzpbYibWKzzgHFfVMsP5sqyWeVqnM1UILnIueJau5-uUJ_Nqla7EkrAslwu-WLE5pxaVTmIxiXXNTHnfUZGKPF9kM40lad9rYCEMnaH_ykSUCzNX9AjKrvFsznWvRZ_DBBU0Ff05vpWOs87pQoZw9HG2-r43KsiuTCobde8of_vgR2f_piowse8z-yiLh9JOhfg3AAD__xx5_i8">