Add new BreakCriticalEdges pass
[oota-llvm.git] / lib / Transforms / Utils / PromoteMemoryToRegister.cpp
index 5fcab9703523eaf55de06a20263ecf269bd52301..b84f1a378fa2970409e05a66e87ced6e050f01d7 100644 (file)
@@ -196,14 +196,12 @@ bool PromotePass::QueuePhiNode(BasicBlock *BB, unsigned AllocaNo) {
   // If the BB already has a phi node added for the i'th alloca then we're done!
   if (BBPNs[AllocaNo]) return false;
 
-  // Create a PhiNode using the dereferenced type...
+  // Create a PhiNode using the dereferenced type... and add the phi-node to the
+  // BasicBlock
   PHINode *PN = new PHINode(Allocas[AllocaNo]->getAllocatedType(),
-                            Allocas[AllocaNo]->getName()+".mem2reg");
+                            Allocas[AllocaNo]->getName()+".mem2reg",
+                            BB->begin());
   BBPNs[AllocaNo] = PN;
-
-  // Add the phi-node to the basic-block
-  BB->getInstList().push_front(PN);
-
   PhiNodes[AllocaNo].push_back(BB);
   return true;
 }