Unstable order of `-pass-remarks-analysis=stack-frame-layout` output
The llvm/test/CodeGen/AArch64/sve-stack-frame-layout.ll test added in 6ae4014befbc16c63c31922d8462afcaae51e260 uncovers a non-determinism in LLVM. There seems to be a dependency on the order of iteration over an unordered container or something like that. The lines printed by emitStackSlotRemark have unstable order (the easiest way to reproduce is to build libc++ and llc with -D_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY, see https://libcxx.llvm.org/DesignDocs/UnspecifiedBehaviorRandomization.html):
$ diff -u \
<(llc <llvm/test/CodeGen/AArch64/sve-stack-frame-layout.ll -mtriple=aarch64 -mattr=+sve2 -pass-remarks-analysis=stack-frame-layout 2>&1 >/dev/null) \
<(llc <llvm/test/CodeGen/AArch64/sve-stack-frame-layout.ll -mtriple=aarch64 -mattr=+sve2 -pass-remarks-analysis=stack-frame-layout 2>&1 >/dev/null)
--- /dev/fd/63 2024-07-29 16:49:54.964017882 +0200
+++ /dev/fd/62 2024-07-29 16:49:54.964017882 +0200
@@ -1,23 +1,23 @@
remark: <unknown>:0:0:
Function: csr_d8_allocnxv4i32i32f64
Offset: [SP-8], Type: Spill, Align: 8, Size: 8
-Offset: [SP-16], Type: Spill, Align: 8, Size: 8
Offset: [SP-16], Type: Variable, Align: 16, Size: 16
+Offset: [SP-16], Type: Spill, Align: 8, Size: 8
Offset: [SP-20], Type: Variable, Align: 4, Size: 4
Offset: [SP-32], Type: Variable, Align: 8, Size: 8
remark: <unknown>:0:0:
Function: csr_d8_allocnxv4i32i32f64_fp
Offset: [SP-8], Type: Spill, Align: 8, Size: 8
-Offset: [SP-16], Type: Spill, Align: 8, Size: 8
Offset: [SP-16], Type: Variable, Align: 16, Size: 16
+Offset: [SP-16], Type: Spill, Align: 8, Size: 8
Offset: [SP-20], Type: Variable, Align: 4, Size: 4
Offset: [SP-32], Type: Spill, Align: 16, Size: 8
Offset: [SP-40], Type: Variable, Align: 8, Size: 8
remark: <unknown>:0:0:
Function: svecc_z8_allocnxv4i32i32f64_fp
Offset: [SP-8], Type: Spill, Align: 8, Size: 8
-Offset: [SP-16], Type: Spill, Align: 8, Size: 8
Offset: [SP-16], Type: Spill, Align: 16, Size: 16
+Offset: [SP-16], Type: Spill, Align: 8, Size: 8
Offset: [SP-20], Type: Variable, Align: 4, Size: 4
Offset: [SP-32], Type: Variable, Align: 16, Size: 16
Offset: [SP-32], Type: Variable, Align: 8, Size: 8
@llvm/issue-subscribers-backend-aarch64
Author: Alexander Kornienko (alexfh)
Does this still happen with the latest trunk? #99883 should have updated the order, and it has changed again since.
Oh - do you mean this happens on the branch but not trunk? If so yes we should probably port the patches over.
It looks like the branch should have #99883 too.
You're right, https://github.com/llvm/llvm-project/pull/99883 fixes this particular issue. However, the llvm/test/CodeGen/AArch64/sve-stack-frame-layout.ll test is still flaky at a later revision (51d4980a133db12888207698e39c469cb7055cac) in our setup for some reason. I'll investigate and come back with the details.
Preliminary analysis shows that dc1c00f6b13f724154f9883990f8b21fb8dcccef introduced flakiness again.
And e31794f99d72dd764c4bc5c5583a0a4c89df22c3 fixes the flakiness again. Seems to be resolved.