Skip to content

Commit bfb2a9d

Browse files
committed
[coroutines] Make CoroSplit pass deterministic
coro-split-after-phi.ll test was flaky due to non-determinism in the coroutine frame construction that was sorting the spill vector using a pointer to a def as a part of the key. The sorting was intended to make sure that spills for the same def are kept together, however, we populate the vector by processing defs in order, so the spill entires will end up together anyways. This change removes spill sorting and restores the determinism in the test. llvm-svn: 299809
1 parent a679012 commit bfb2a9d

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ void coro::buildCoroutineFrame(Function &F, Shape &Shape) {
705705
Spills.emplace_back(&I, U);
706706

707707
// Rewrite materializable instructions to be materialized at the use point.
708-
std::sort(Spills.begin(), Spills.end());
709708
DEBUG(dump("Materializations", Spills));
710709
rewriteMaterializableInstructions(Builder, Spills);
711710

@@ -737,7 +736,6 @@ void coro::buildCoroutineFrame(Function &F, Shape &Shape) {
737736
Spills.emplace_back(&I, U);
738737
}
739738
}
740-
std::sort(Spills.begin(), Spills.end());
741739
DEBUG(dump("Spills", Spills));
742740
moveSpillUsesAfterCoroBegin(F, Spills, Shape.CoroBegin);
743741
Shape.FrameTy = buildFrameType(F, Shape, Spills);

llvm/test/Transforms/Coroutines/coro-spill-after-phi.ll

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ suspend:
3838
; CHECK: store void (%f.Frame*)* @f.destroy, void (%f.Frame*)** %destroy.addr
3939
; CHECK: %phi1 = select i1 %n, i32 0, i32 2
4040
; CHECK: %phi2 = select i1 %n, i32 1, i32 3
41-
; FIXME: The ordering of these spills is non-determinstic. Remove -DAG and the
42-
; (4|5) regex when that's fixed.
43-
; CHECK-DAG: %phi2.spill.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 {{(4|5)}}
44-
; CHECK-DAG: store i32 %phi2, i32* %phi2.spill.addr
45-
; CHECK-DAG: %phi1.spill.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 {{(4|5)}}
46-
; CHECK-DAG: store i32 %phi1, i32* %phi1.spill.addr
41+
; CHECK: %phi2.spill.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 5
42+
; CHECK: store i32 %phi2, i32* %phi2.spill.addr
43+
; CHECK: %phi1.spill.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 4
44+
; CHECK: store i32 %phi1, i32* %phi1.spill.addr
4745
; CHECK: ret i8* %hdl
4846

4947
declare i8* @llvm.coro.free(token, i8*)

0 commit comments

Comments
 (0)