<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115986>115986</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Bug]clang performed incorrect inline optimization
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
park671
</td>
</tr>
</table>
<pre>
### clang version:
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.1.0
Thread model: posix
### Issue Summary:
After enabling optimization, Clang consistently generates incorrect inline-optimized code, leading to a crash in the compiled output (jumping to a null address).
### Reproduction Steps:
Compile the dalvik-darwin code and run it; the issue is 100% reproducible. However, if a line of arbitrary log output code is added, the compiled result works as expected, and the bug disappears, as shown in the image:
![image](https://github.com/user-attachments/assets/1b3189be-0417-454d-8d4f-1f2ca5d8d487)
source code: https://github.com/park671/dalvik-darwin
### Preliminary Disassembly Results:
The prepareCpe method, without the added "log" line, is incorrectly inlined by Clang, ultimately leading to a jump to a null address.
![image](https://github.com/user-attachments/assets/33a554be-748a-452d-9d97-5810a2f80ded)
![image](https://github.com/user-attachments/assets/56a4dfe4-8b6e-4856-bc7e-b087a6257166)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVMuO3DgM_Br1hbAhye-DD_PAYPe2SPIDtEXbysiWIckz6f36heROZwcJcgrQ6G5IRbJYRRG91_NG1LPqkVXPFzzCYl2_o3utG3EZrLr2TBbnB0aD2wxv5Ly2GyseGH9m_OFh3w19vANR5TznwGSbzjNRcZ6LnOcyr5jszsAv6GYKrHgAdGtdZhgTZQrdu95kEeE33OIIFaxWkYno3Xr97by6fd8Z_u39QfD5WFd014i9UZwCOaANB6O3Gewe9Kr_xRDbkE_wlLiPdvPaB9qCucJMGzkM5EFvo3WOxgB6M3qj7BZNCkarKMYbQhXzBgsIo0O_gN4gLASjXXdtSIE9wn6EKMjX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