Fix PR3784: If the source of a phi comes from a bb ended with an invoke, make sure...
[oota-llvm.git] / lib / Transforms / Scalar / CodeGenPrepare.cpp
index 1f3a13cc9cec2193da4c804ba484878deefed8f3..85e57661c1545b975a9d8acb1d5548099f52d934 100644 (file)
@@ -327,6 +327,12 @@ static void SplitEdgeNicely(TerminatorInst *TI, unsigned SuccNum,
   assert(isa<PHINode>(Dest->begin()) &&
          "This should only be called if Dest has a PHI!");
 
+  // Do not split edges to EH landing pads.
+  if (InvokeInst *Invoke = dyn_cast<InvokeInst>(TI)) {
+    if (Invoke->getSuccessor(1) == Dest)
+      return;
+  }
+
   // As a hack, never split backedges of loops.  Even though the copy for any
   // PHIs inserted on the backedge would be dead for exits from the loop, we
   // assume that the cost of *splitting* the backedge would be too high.