]> granicus.if.org Git - llvm/commitdiff
[coroutines] Make CoroSplit pass deterministic
authorGor Nishanov <GorNishanov@gmail.com>
Sat, 8 Apr 2017 00:49:46 +0000 (00:49 +0000)
committerGor Nishanov <GorNishanov@gmail.com>
Sat, 8 Apr 2017 00:49:46 +0000 (00:49 +0000)
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
test/Transforms/Coroutines/coro-spill-after-phi.ll

index c95291e93465f1fef45732694f104780be5e72b2..19e6789dfa74a09b7c01c8f0e37070c07c49c5c2 100644 (file)
@@ -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);
index 8e75256f581df11263b0acc31ec37427da32374a..3c7e050c09e951524fd9549ba61571fd3cdbe850 100644 (file)
@@ -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*)