<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/70703>70703</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LTO] Fat LTO pipeline miss-optimizes indirect goto.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:core,
LTO
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mandlebug
</td>
</tr>
</table>
<pre>
test-suite test `SingleSource/Regression/C/2004-03-15-IndirectGoto.c` exhibits the problem.
Input:
```
#include <stdio.h>
int main() {
static const void *L[] = {&&L1, &&L2, &&L3, &&L4, 0 };
unsigned i = 0;
printf("A\n");
L1:
printf("B\n");
L2:
printf("C\n");
L3:
printf("D\n");
goto *L[i++];
L4:
printf("E\n");
return 0;
}
```
Compile commands to reproduce:
```
clang -flto -ffat-lto-objects -O2 -c IndirectGoto.c
clang -flto IndirectGoto.o -o no_clone.out
clang -flto -ffat-lto-objects IndirectGoto.o -o clone.out
./no_clone.out
A
B
C
D
B
C
D
C
D
D
E
./clone.out
A
B
C
D
Illegal instruction (core dumped)
```
test-suite test `SingleSource/Benchmarks/Misc/evalloop.c` is also failing likely due to the same underlying issue.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVF-PozYQ_zTDywhkhoQsDzxskqNaKdVKvXuvHNuQ6RkbYbPq9tNXEO4228u2Pcmyx_bP8_fnkSFw54ypYbuH7TGRU7z4se6l09acpy45e_1aRxNiGiaOBmcRoRSf2XXWfPbTqAxQ85vpRhMCewfUHIAaEmKTiiLNt-mT0zwaFX_x0WcKSoHmzwufOQaMF4PD6M_W9BmII4jH6_zkhilCse6gFOu4bqlgp-ykDUJxCFGzzy5QfLresovYS3ZAD0AVwm5_PccQZWSFyrsQ8cWzRqDH0zVuhOK4QKkEKk850AFXmW7k4kbezLJA2B2h-GYCJ7ekUyMvGsXN1TCyi-3iFT3C9uCACKj6jjjl3-N9D97fA9Mb-BZ7uIctPlB8vANG7Hz03zLDQPt5bN9iPG3uW_50V9lo4jS6mzzM6bpb02U--H5ga1D5fmZgwOhxNMPo9aTMR3RQVroO09ZGj2nbypja6FN__sOoGDB9JkwVvucg_vjyHcBj6tH535X1zmR-iv_H0o8a_vE8A2pula5erFGtCTpcl-O_HL7frcvKfpyN_IyFJ2tNJy2yC3GcVGTvEOhB-dGgnvrB6LmiH5fsv1vD3jh16eX4NQA1v3JQQI15kdZ6P1zbAQeUNnhsJVt2HVr-auwr6snMBJh7RJC9wclpM9rXGcEhTCZLdF3oqqhkYuq8rB7KKqe8SC61anVJVblpVaVJl5UsN5KE3JKS20KSTrgmQUUuCpE_bESeZ62udm3RtmctWpFXBBthesk2s_alz_zYJYvJeid2okisPBsblp5JNCOgeJwztvD_AESnL8-zvD0mYz3fp-epC7ARlkMMbzojR7u03hm_PWIjI56-POPAg7HsDPYcQuqHyD3_ZQLySrHlk2bJNNr6EuMQ5q9BDVDTcbxM50z5HqhZHLsu6TD6maVAzRLHXIollL8DAAD__-j4uOU">