<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54577>54577</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LLVM-COV] While loop coverage error caused by calling exit() function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zhangxy-97
</td>
</tr>
</table>
<pre>
When the exit function is called in the while loop, the execution times of the while will be wrong.
`clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9.3.0
Found candidate GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.2.0
Selected GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.2.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
1| 1|#define TRUE 1
2| |#include <stdlib.h>
3| 1|void myExit() { exit(0); }
4| |
5| |int tmp = 0;
6| 1|int main() {
7| 1| if (1) {
8| 1| tmp++;
9| 1| tmp++;
10| 1| } else {
11| 0| ;
12| 0| }
13| 2| while (1) {
14| 1| int counter = 0;
15| 1| myExit();
16| 1| while (counter < 5) {
17| 0| return 0;
18| 0| counter++;
19| 0| }
20| 1| ;
21| 1| tmp = TRUE;
22| 1| }
23| 1|}
24| |
`
Line 13 should be executed only once.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1Vttu2zAM_RrlRYhhyXZsP_ihTdphQIcBu7SPgy-KrU2RAl3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