<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99887>99887</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
WRONG code. FE:@llvm.lifetime.end? DeadStoreElim?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JonPsson1
</td>
</tr>
</table>
<pre>
This program:
```
int printf(const char *, ...);
long RES;
unsigned ****c;
unsigned *****volatile P5 = &c;
static unsigned ****P4;
unsigned **P2a, **P2b;
int main() {
{
unsigned ***P3 = &P2a;
for (unsigned IV = -8; IV; IV = IV + 4) {
unsigned ***i = &P2b;
long *P = &RES;
*P5 = &i;
*P = ( (P4 = &P3) == *P5 );
}
}
printf("%d\n", RES);
}
```
should print '0', which it does, except if compiled with -Os on SystemZ:
clang -march=z15 -Os wrong0.i -o a.out -w; ./a.out
1
If I remove the extra curly braces around the loop, 0 is printed also with -Os. I see from the front-end only one slight difference with the braces in a block:
```
for.end: ; pred for.end: ; pred
> call void @llvm.lifetime.end.p0(i64 8, ptr %P3) #3
%6 = load i64, ptr @RES, align 8, !tbaa !10 %6 = load i64, ptr @RES, align 8, !tbaa !10
%call = call signext i32 (ptr, ...) @printf(ptr nounde %call = call signext i32 (ptr, ...) @printf(ptr nounde
call void @llvm.lifetime.end.p0(i64 8, ptr %P3) #3 <
%7 = load i32, ptr %retval, align 4 %7 = load i32, ptr %retval, align 4
ret i32 %7 ret i32 %7
}
```
Many passes later, the next change then is after DSE where a store now has been removed:
```
; *** IR Dump After DSEPass on main *** ; *** IR Dump After DSEPass on main ***
; Function Attrs: nounwind optsize ; Function Attrs: nounwind optsize
define dso_local signext i32 @main() local_unnamed_addr define dso_local signext i32 @main() local_unnamed_addr
entry: entry:
%P3 = alloca ptr, align 8 %P3 = alloca ptr, align 8
%i = alloca ptr, align 8 %i = alloca ptr, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull % call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %
store ptr @P2a, ptr %P3, align 8, !tbaa !4 <
br label %for.body br label %for.body
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVlGP4jYQ_jXmZUQUnATIAw-7y1JtpfbQbXWV-nIy9oS4dezIdpbb-_WVnQRyiNuuugiI7Zn5Zjyeb2LmnDxqxA0p7kmxnbHO18ZufjV675zRi9nBiNfNH7V00FpztKwh2R1JtyQd_5fp8I1TqT20VmpfEbrmRjsPvGYWCL0j9AGSJCG0JNn9FEIZfYTPj8_n5U7HoERvNXz522JC716MYl4qhH0BJNsCocuLkfPMSw43bff5VURXWnvKQvDj5HClHfbcMKkJXRNaAlkNUpgO4YbrfTbGGTxkE93KhJStzyZPX6LmfE2ye3j60v_HpfCg95Bfeb7tUF78HX7wBxAPIcQ0qkwPpFcJ0nNm5Q3hIFuH3z4_-8pibNm2n0eMSQ1E49V2mFxGlzIilBJaCFI86Dh8iMUyLaPR6GZJDudfm06JHhQIXaWErgLUqZa8BulBGHRhAb9xbD3ICrhpWqlQwEn6GuafHBgNz6_OY_PXFQu4YvoI84ZZXpNs-31RRP2TNfqYJhLmBlhiOg_zUzi7hNBdnPfWiynUUwVPYLExLwi-RsBv3jLgnVWvcLCMowNmTadFlCpj2hB1CpGhUnsUwJQz56ATeAKHCJU1TTSprNF-jlqA0eoVjEZwSh5rD0JWFVrUHHvroD24lBoYHJTh_7zN_8rYBLUg2R2EjbYWBQyfG6Lx0LPHXoUzpeDFSAEkT5V6aRIlK_SywWCZtCmha7nMYR223PrAkWIoL5plIxotlrH2lGEC5DI_K-dpLJwHYEoedY9C6MIfGAvPRQq3Ph_AO_cBWsStBZQ4iMT85kFmNJCl9fbSHQPuufaDHx1OG38I6MNoY2Qfy_gYUPZwyf1qkquMTsws-hemLunKb2Z7ssn3I427sTgmoVj9MLnuE7c6xG9Mv0LLnEMHinmMSQwUiLnlNdPHyEg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