From 3cc8445f85497cd1147c31d13ea4be1d2a629293 Mon Sep 17 00:00:00 2001 From: Gor Nishanov Date: Sat, 8 Apr 2017 00:49:46 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299809 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Coroutines/CoroFrame.cpp | 2 -- test/Transforms/Coroutines/coro-spill-after-phi.ll | 10 ++++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/Transforms/Coroutines/CoroFrame.cpp b/lib/Transforms/Coroutines/CoroFrame.cpp index c95291e9346..19e6789dfa7 100644 --- a/lib/Transforms/Coroutines/CoroFrame.cpp +++ b/lib/Transforms/Coroutines/CoroFrame.cpp @@ -705,7 +705,6 @@ void coro::buildCoroutineFrame(Function &F, Shape &Shape) { Spills.emplace_back(&I, U); // Rewrite materializable instructions to be materialized at the use point. - std::sort(Spills.begin(), Spills.end()); DEBUG(dump("Materializations", Spills)); rewriteMaterializableInstructions(Builder, Spills); @@ -737,7 +736,6 @@ void coro::buildCoroutineFrame(Function &F, Shape &Shape) { Spills.emplace_back(&I, U); } } - std::sort(Spills.begin(), Spills.end()); DEBUG(dump("Spills", Spills)); moveSpillUsesAfterCoroBegin(F, Spills, Shape.CoroBegin); Shape.FrameTy = buildFrameType(F, Shape, Spills); diff --git a/test/Transforms/Coroutines/coro-spill-after-phi.ll b/test/Transforms/Coroutines/coro-spill-after-phi.ll index 8e75256f581..3c7e050c09e 100644 --- a/test/Transforms/Coroutines/coro-spill-after-phi.ll +++ b/test/Transforms/Coroutines/coro-spill-after-phi.ll @@ -38,12 +38,10 @@ suspend: ; CHECK: store void (%f.Frame*)* @f.destroy, void (%f.Frame*)** %destroy.addr ; CHECK: %phi1 = select i1 %n, i32 0, i32 2 ; CHECK: %phi2 = select i1 %n, i32 1, i32 3 -; FIXME: The ordering of these spills is non-determinstic. Remove -DAG and the -; (4|5) regex when that's fixed. -; CHECK-DAG: %phi2.spill.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 {{(4|5)}} -; CHECK-DAG: store i32 %phi2, i32* %phi2.spill.addr -; CHECK-DAG: %phi1.spill.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 {{(4|5)}} -; CHECK-DAG: store i32 %phi1, i32* %phi1.spill.addr +; CHECK: %phi2.spill.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 5 +; CHECK: store i32 %phi2, i32* %phi2.spill.addr +; CHECK: %phi1.spill.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32 0, i32 4 +; CHECK: store i32 %phi1, i32* %phi1.spill.addr ; CHECK: ret i8* %hdl declare i8* @llvm.coro.free(token, i8*) -- 2.40.0