When inserting code, make sure not to insert it before PHI nodes.  This
fixes PR612 and Transforms/LowerInvoke/2005-08-03-InvokeWithPHI.ll

llvm-svn: 22626
diff --git a/llvm/lib/Transforms/Scalar/LowerInvoke.cpp b/llvm/lib/Transforms/Scalar/LowerInvoke.cpp
index fe22b4b..96d5b98 100644
--- a/llvm/lib/Transforms/Scalar/LowerInvoke.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerInvoke.cpp
@@ -283,7 +283,9 @@
       // Create the receiver block if there is a critical edge to the normal
       // destination.
       SplitCriticalEdge(II, 0, this);
-      Instruction *InsertLoc = II->getNormalDest()->begin();
+      BasicBlock::iterator InsertLoc = II->getNormalDest()->begin();
+      while (isa<PHINode>(InsertLoc)) ++InsertLoc;
+      
 
       // Insert a normal call instruction on the normal execution path.
       std::string Name = II->getName(); II->setName("");