Speed up codegen prepare from 3.58s to 0.488s.
[oota-llvm.git] / lib / Transforms / Utils / DemoteRegToStack.cpp
index bbe804fc5518d9d089bbefa24b703d4c95c7d065..c908b4a55914266e041f9ddd00c6d92b05b38a4e 100644 (file)
@@ -39,7 +39,8 @@ AllocaInst* llvm::DemoteRegToStack(Instruction &I, bool VolatileLoads,
   // Create a stack slot to hold the value.
   AllocaInst *Slot;
   if (AllocaPoint) {
-    Slot = new AllocaInst(I.getType(), 0, I.getName()+".reg2mem", AllocaPoint);
+    Slot = new AllocaInst(I.getType(), 0,
+                          I.getName()+".reg2mem", AllocaPoint);
   } else {
     Function *F = I.getParent()->getParent();
     Slot = new AllocaInst(I.getType(), 0, I.getName()+".reg2mem",
@@ -116,7 +117,8 @@ AllocaInst* llvm::DemotePHIToStack(PHINode *P, Instruction *AllocaPoint) {
   // Create a stack slot to hold the value.
   AllocaInst *Slot;
   if (AllocaPoint) {
-    Slot = new AllocaInst(P->getType(), 0, P->getName()+".reg2mem", AllocaPoint);
+    Slot = new AllocaInst(P->getType(), 0,
+                          P->getName()+".reg2mem", AllocaPoint);
   } else {
     Function *F = P->getParent()->getParent();
     Slot = new AllocaInst(P->getType(), 0, P->getName()+".reg2mem",
@@ -127,17 +129,13 @@ AllocaInst* llvm::DemotePHIToStack(PHINode *P, Instruction *AllocaPoint) {
   for (unsigned i = 0, e = P->getNumIncomingValues(); i < e; ++i) {
     if (InvokeInst *II = dyn_cast<InvokeInst>(P->getIncomingValue(i))) {
       assert(II->getParent() != P->getIncomingBlock(i) && 
-             "Invoke edge not supported yet");
+             "Invoke edge not supported yet"); II=II;
     }
     new StoreInst(P->getIncomingValue(i), Slot, 
                   P->getIncomingBlock(i)->getTerminator());
   }
   
   // Insert load in place of the phi and replace all uses.
-  BasicBlock::iterator InsertPt;
-  for (InsertPt = P->getParent()->getInstList().begin(); 
-       isa<PHINode>(InsertPt); ++InsertPt)
-    ; /*noop */
   Value *V = new LoadInst(Slot, P->getName()+".reload", P);
   P->replaceAllUsesWith(V);