<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/139866>139866</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
AArch64 ISel(?) miscompilation from weird Rust MIR
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
saethlin
</td>
</tr>
</table>
<pre>
The reproducer for this is a bit large, I've (mostly) reduced an output from https://github.com/cbeuw/rustlantis, so what I have is Rust MIR, but I'm linking a godbolt that has the LLVM IR: https://godbolt.org/z/sP7qG363b
The structure of this program is that it hashes some locals, and prints a hash at the end. At some point in the optimization pipeline, the hash changes.
We (me and @nikic, who walked me through some opt-bisect use) are pretty confident this is an Aarch64 ISel issue because this produces the good hash:
```
rustc +nightly main.rs -Copt-level=2 -Cllvm-args=-opt-bisect-limit=3642 && ./main
```
And this produces the bad hash:
```
rustc +nightly main.rs -Copt-level=2 -Cllvm-args=-opt-bisect-limit=3647 && ./main
```
And the passes in that bisect range are:
```
BISECT: running pass (3643) AArch64 Instruction Selection on function (_ZN4main4main17he1f737bca831c768E)
BISECT: running pass (3644) SME Peephole Optimization pass on function (_ZN4main4main17he1f737bca831c768E)
BISECT: running pass (3645) Early Tail Duplication on function (_ZN4main4main17he1f737bca831c768E)
BISECT: running pass (3646) Optimize machine instruction PHIs on function (_ZN4main4main17he1f737bca831c768E)
BISECT: running pass (3647) Merge disjoint stack slots on function (_ZN4main4main17he1f737bca831c768E)
```
We've already checked that
```
rustc +nightly main.rs -Copt-level=2 -Cllvm-args=-no-stack-coloring=1 && ./main
```
produces the bad hash, so it doesn't seem like this is related to stack coloring.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VdFu4zYQ_Br6ZWFDomTJftCDEsetgUsbJEEL9KWgqLXIC0Wq5MqG7-sLSm5yvR56RdEUMCwBpDizM8NdEYLuLGLF1jdsvVuIk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