Skip to content

Commit 55c971b

Browse files
committed
Pre-commit reproducer for argument copy elison related bug
Adding test case related to #89060 It shows that after argument copy elison the scheduler may reorder a load of the input argument and a store to the same fixed stack entry (the fixed stack entry that is reused for the local variable).
1 parent 19a625a commit 55c971b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2+
; RUN: llc -mtriple hexagon-- -O3 -o - %s | FileCheck %s
3+
4+
; Reproducer for https://github.com/llvm/llvm-project/issues/89060
5+
;
6+
; Problem was a bug in argument copy elison. Given that the %alloca is
7+
; eliminated, the same frame index will be used for accessing %alloca and %a
8+
; on the fixed stack. Care must be taken when setting up
9+
; MachinePointerInfo/MemOperands for those accesses to either make sure that
10+
; we always refer to the fixed stack slot the same way (not using the
11+
; ir.alloca name), or make sure that we still detect that they alias each
12+
; other if using different kinds of MemOperands to identify the same fixed
13+
; stack entry.
14+
;
15+
define i32 @f(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 %q1, i32 %a, i32 %q2) {
16+
; CHECK-LABEL: f:
17+
; CHECK: .cfi_startproc
18+
; CHECK-NEXT: // %bb.0:
19+
; CHECK-NEXT: {
20+
; CHECK-NEXT: r0 = memw(r29+#36)
21+
; CHECK-NEXT: memw(r29+#32) = ##666
22+
; CHECK-NEXT: }
23+
; CHECK-NEXT: {
24+
; CHECK-NEXT: r1 = memw(r29+#28)
25+
; CHECK-NEXT: r2 = memw(r29+#32)
26+
; CHECK-NEXT: }
27+
; CHECK-NEXT: {
28+
; CHECK-NEXT: r0 = sub(r1,r0)
29+
; CHECK-NEXT: }
30+
; CHECK-NEXT: {
31+
; CHECK-NEXT: r0 = xor(r0,r2)
32+
; CHECK-NEXT: jumpr r31
33+
; CHECK-NEXT: }
34+
%alloca = alloca i32
35+
store i32 %a, ptr %alloca ; Should be elided.
36+
store i32 666, ptr %alloca
37+
%x = sub i32 %q1, %q2
38+
%y = xor i32 %x, %a ; Results in a load of %a from fixed stack.
39+
; Using same frame index as elided %alloca.
40+
ret i32 %y
41+
}

0 commit comments

Comments
 (0)