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

    <tr>
        <th>Summary</th>
        <td>
            llvm::isPotentiallyReachable() returned an incorrect result
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          tr4v3ler
      </td>
    </tr>
</table>

<pre>
    LLVM version: 14.0.0

target source code:
```c
if (cd->compat_flag == true) {
    if (copy_from_user(&data_compat, argp,  // if.then.i189
 sizeof(data_compat))) {
        return -EFAULT;
    }
} else {
 if (copy_from_user(&data, argp,  // if.then.i
        sizeof(data))) {
        return -EFAULT;
    }
}
```

my code:
```cpp
for (auto bb: bbs) {
    dbgs() << "[+] bb: " << bb->getName() << '\n';
    if (isPotentiallyReachable(bb, current_bb, nullptr, this->dom_tree, this->loopinfo)) {
        dbgs() << current_bb->getName() << " is reachable from " << bb->getName() << '\n';
        return false;
    }
}
dbgs() << "[+] " << current_bb->getName() << " is not reachable from all\n";
return true;
```

my log:
```shell
[+] current_bb: if.then.i
[+] bb: if.then.i189
[+] if.then.i is reachable from if.then.i189
```

I checked CFG and sure that if.then.i is not reachable from if.then.i189 but llvm::isPotentiallyReachable() returned an incorrect result:
![image](https://github.com/llvm/llvm-project/assets/59732577/77d3dfd8-67e7-4932-81e1-6881a47dc34c)

Did I use it incorrectly? Is there a problem with the implementation of the function itself? Is there any other function that can accomplish this?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVV1vrDYQ_TXmZbQrsPl84CHZvVSR0qqq2r6ujBnArcHINrna_vrKsMl-Jbmt7o1QwDOemTNzjr3cWtmNiCVJHkmyD_jsem1KZ-IXptAEtW6O5fPznz_DCxor9UjYA0TxNtyGJNyT8GH977jp0IHVsxEIQjdI2MlF0nB9xLqWLRCai2ZD2Behh4m7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