<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/67138>67138</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Linker Difference before and after opt
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
LRY89757
</td>
</tr>
</table>
<pre>
code as below:
```cpp
#include <vector>
static int varargs_func2(int X,...) {
int result = 0;
int arr[] = {4, 5, 6};
result += arr[0] - arr[X];
return result;
}
int main() {
int result = varargs_func2(1);
return result;
}
```
our command is:
```
commands = {
"clang++": ["clang++", "-O0", "-mllvm", "--debug", "a.cpp", "-S", "-emit-llvm", "-o", file]
"opt":[ "opt", file, "-O3", "--debug", "-mtriple=x86_64-unknown-linux-gnu", "-o", file_after_opt],
"llc_before":[ "llc", file, "-O3","-filetype=obj", "--debug", "-mtriple=x86_64-unknown-linux-gnu", "-o", exe_before_opt + ".o"],
"llc_after":[ "llc", file_after_opt, "-O3","-filetype=obj", "--debug", "-mtriple=x86_64-unknown-linux-gnu", "-o", exe_after_opt + ".o"],
"linker_before":["clang", exe_before_opt + ".o", "-o", exe_before_opt],
"linker_after":["clang", exe_after_opt + ".o", "-o", exe_after_opt],
}
```
the linker before output is 0, but the linker after output is 1.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVMuOozgU_ZrLxgKBHV4LFpVksmpppJlNzyoyYIi7jY38qKr--5GBNFSqitqMNBFy7Ps859i61BjeS8YqSI-QngPq7E3p6ttf_xRlnuZBrdpfVaNahqhBNRPqBcgTxGeInyCL568Zx8WCCZeNcC1DQE7PrLFKA_ljcU6rsdTyBnFp0TPVVPfm2jnZYMCFt30HfIqiCHCJID_OKQihKV4z44RFQM4oBvLgpFrPDCY_5McD4BNK_ZJBfn4Tfy-Ejz52zox9argcvkO6ydDMOi2XrN9mX3TDy2MYKJeAi6_AP_JOAJcP-PYb3nXf9ldOo0YNA5Ut4ub9Ha3VlyhzF2r1-B9g3Agqey-O_zCQJ-SVfWfHJx8c_hlvDoMQz8PmHLasdv1qoJF_K6v_782eDdyGD_lq2XdcMH8nM1TAWI12xgbpcXO-h96xkR0s4WA1HwUDcn4tsmt2CJ38KdWLDAWX7jXspfsEyZV2lumr75meAZ9WWEI015p1SrM36IRodtD5vbfbX6MHo-of_zlq9soWXB61f_neHU3uDyhM_HYYbAT4f7j87v85lfU9Cy5_Mv14L-uD_lKhXTH3m75V8oOenzDZ4_zYcX8w2BtDMxg0g0bK2dFZxA2Kfe3aWbQJmtpsYpJoWy1oK9KWpKQBq5KsTEkZF4csuFVJ3MVFV-CUpF3DaopbTGiedzXD3pYHvMIxJnGJcULSQ5xFbdkkdZLkB3LAbV5kcIjZQLmI_AyIlO4DboxjVZYnpAgErZkw1SyiZC9ocs6XHujK54S16w0cYsGNNWsVy61g1beZ3Zl3HdNMNuyuhh-YC-fRBk6L6mbtOE1QfAF86bm9uTpq1AD4Mo-n6S8ctfrBGgv4MkExgC8T1H8DAAD__9BKBvw">