<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89543>89543</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[CLANG] Optimization level changes program output
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
maxomatic458
</td>
</tr>
</table>
<pre>
this program in IR should exit with code 80
```llvm
define i64* @int_Index_int_int(i64* %_self,i64 %_idx) {
entry:
%_idx_0 = alloca i64
store i64 %_idx, i64* %_idx_0
%_4 = load i64, i64* %_self
%_5 = load i64, i64* %_idx_0
%_6 = mul i64 %_4, %_5
%_3 = alloca i64
store i64 %_6, i64* %_3
%_2 = alloca i64*
store i64* %_3, i64** %_2
%_1 = load i64*, i64** %_2
ret i64* %_1
}
define i64 @main() {
entry:
%_9 = alloca i64
store i64 10, i64* %_9
%_8 = load i64, i64* %_9
%_a_7 = alloca i64
store i64 %_8, i64* %_a_7
%_12 = alloca i64
store i64 20, i64* %_12
%_11 = load i64, i64* %_12
%_b_10 = alloca i64
store i64 %_11, i64* %_b_10
%_17 = alloca i64
store i64 2, i64* %_17
%_16 = load i64, i64* %_17
%_22 = alloca i64
store i64 2, i64* %_22
%_21 = load i64, i64* %_22
%_19 = call i64* @int_Index_int_int(i64* %_a_7,i64 %_21)
%_14 = load i64, i64* %_19
%_c_13 = alloca i64
store i64 %_14, i64* %_c_13
%_27 = alloca i64
store i64 3, i64* %_27
%_26 = load i64, i64* %_27
%_32 = alloca i64
store i64 3, i64* %_32
%_31 = load i64, i64* %_32
%_29 = call i64* @int_Index_int_int(i64* %_b_10,i64 %_31)
%_24 = load i64, i64* %_29
%_d_23 = alloca i64
store i64 %_24, i64* %_d_23
%_34 = load i64, i64* %_c_13
%_35 = load i64, i64* %_d_23
%_36 = add i64 %_34, %_35
ret i64 %_36
}
```
but it will only exit with ``80`` when the opt level is ``1`` or ``0``
the exit code for ``-O2`` and ``-O3`` will change every time the IR is compiled
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVt1uozgYfRpzY7WyP5sELrjINMqq0mpHmhdADnaCVwZHYDrtPv0KQ8H17pBopKot5pzz_Rxjf6Lv9bVVqkDpN5QeEzG42nZFI95tI5yueJolZys_ClfrHt86e-1Eg3WLX3_gvraDkVi9a4d_alfjykqFM4LIEZED2pHpx5i3ZlqS6qJbhfWOIzhgxIluXfnaSvVejv_p1iHIPt9CWvbKXBC86B33j1q-I8gxRvtvk55qXfeB2GEOOEFKghE7YmGMrYSP5d_2znY-9Cr1goNYnrkKcS9irJAT6AvW57VA0y1oJLvz2GYwSyae4GVWFHuggl0UiK10iOlwiBRW0iLyuQSrDo0KO_wS3SkXytJZY3-MfR9Nb4RuEWSjlRtO5nd6QEnUgHzlZluOBDhR7h_odBYJiHIf9Og_zY4UIM6Thh2OW_xL5Lmkj-xrSiONkRfEu1cvxCmEpe42kw2QcLcpERmCSmGzJyGSTnukEsY8fqaM7q1HClAEwYagm589DZBVSR_5SmmsMfKCWu_5weLywy5v-hEi2T0_4jAs6DLb9CNEwu_44Tfoagj7aghsGhIiZQmPGAKxxsgLit2M99U8tnnwR7qTV0LKJRO2nPws_XKKTmu76AxdrtP50f8-Dw77y9cYbFvzEdzFEzibSfhnrVrsaoXtzWGj3pTBup9BdMbYbl74n0gj1Yv7O_6yQJ--w8wWrVzW2GfUMbGqFu1VYfWmug_sdKN8Hq8_xgQq29y0UTKRBZM5y0WiCrqnbE845ySpC3oBllHIBZdpJlLFKlHteQaCV3l2ri6JLoAAJxwoZYRw8pxd0gtUl5SRXDJFFeJENUKb53EOebbdNdF9P6giy1POEiPOyvR--gGojGivCGAchLpixD-dh2uPODG6d_2q4LQzfmR6-fPw1x8oPeLvN6cb_Y9w2rZzf6e616HJDu42uGToTFE7d-vH6w5OCE5X7erh_FzZBsHJT0vTn6dbZ_9WlUNw8in3CE4-638DAAD__w69jjI">