Skip to content

Commit d22d235

Browse files
kasuga-fjmahesh-attarde
authored andcommitted
[MachinePipeliner] Fix incorrect dependency direction (llvm#149436)
This patch fixes a bug introduced in llvm#145878. A dependency was added in the wrong direction, causing an assertion failure due to broken topological order.
1 parent 5ba9a78 commit d22d235

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

llvm/lib/CodeGen/MachinePipeliner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4279,8 +4279,8 @@ void LoopCarriedEdges::modifySUnits(std::vector<SUnit> &SUnits,
42794279
!TII->isGlobalMemoryObject(FromMI) &&
42804280
!TII->isGlobalMemoryObject(ToMI) && !isSuccOrder(From, To)) {
42814281
SDep Pred = Dep;
4282-
Pred.setSUnit(Src);
4283-
Dst->addPred(Pred);
4282+
Pred.setSUnit(From);
4283+
To->addPred(Pred);
42844284
}
42854285
}
42864286
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# RUN: llc -mtriple=hexagon -run-pass pipeliner %s -o /dev/null
2+
3+
# Check that edges that violate topological order are not added to the
4+
# SwingSchedulerDAG. This is a case where the crash was caused by PR 145878.
5+
6+
--- |
7+
target triple = "hexagon"
8+
9+
define void @crash_145878() {
10+
entry:
11+
br label %loop
12+
13+
loop: ; preds = %loop, %entry
14+
%lsr.iv2 = phi i32 [ %lsr.iv.next, %loop ], [ 1, %entry ]
15+
%lsr.iv = phi ptr [ %cgep3, %loop ], [ inttoptr (i32 -8 to ptr), %entry ]
16+
%cgep = getelementptr i8, ptr %lsr.iv, i32 12
17+
%load = load i32, ptr %cgep, align 4
18+
store i32 %load, ptr %lsr.iv, align 4
19+
%lsr.iv.next = add nsw i32 %lsr.iv2, -1
20+
%iv.cmp.not = icmp eq i32 %lsr.iv.next, 0
21+
%cgep3 = getelementptr i8, ptr %lsr.iv, i32 -8
22+
br i1 %iv.cmp.not, label %exit, label %loop
23+
24+
exit: ; preds = %loop
25+
ret void
26+
}
27+
...
28+
---
29+
name: crash_145878
30+
tracksRegLiveness: true
31+
body: |
32+
bb.0.entry:
33+
successors: %bb.1(0x80000000)
34+
35+
%5:intregs = A2_tfrsi -8
36+
J2_loop0i %bb.1, 1, implicit-def $lc0, implicit-def $sa0, implicit-def $usr
37+
38+
bb.1.loop (machine-block-address-taken):
39+
successors: %bb.2(0x04000000), %bb.1(0x7c000000)
40+
41+
%1:intregs = PHI %5, %bb.0, %3, %bb.1
42+
%6:intregs = L2_loadri_io %1, 12 :: (load (s32) from %ir.cgep)
43+
S2_storeri_io %1, 0, killed %6 :: (store (s32) into %ir.lsr.iv)
44+
%3:intregs = A2_addi %1, -8
45+
ENDLOOP0 %bb.1, implicit-def $pc, implicit-def $lc0, implicit $sa0, implicit $lc0
46+
J2_jump %bb.2, implicit-def dead $pc
47+
48+
bb.2.exit:
49+
PS_jmpret $r31, implicit-def dead $pc
50+
...

0 commit comments

Comments
 (0)