Teach the IR Sink pass to (conservatively) respect convergent annotations.
[oota-llvm.git] / lib / Transforms / Scalar / Sink.cpp
index b169d5612f002674b03565e8d336d4363439a5f9..ec3a0186641efbdaaad7b0790d9d541cb7f4a29f 100644 (file)
@@ -172,6 +172,12 @@ static bool isSafeToMove(Instruction *Inst, AliasAnalysis *AA,
   if (isa<TerminatorInst>(Inst) || isa<PHINode>(Inst))
     return false;
 
+  // Convergent operations can only be moved to control equivalent blocks.
+  if (auto CS = CallSite(Inst)) {
+    if (CS.hasFnAttr(Attribute::Convergent))
+      return false;
+  }
+
   return true;
 }