[llvm-commits] [llvm] r48820 - in /llvm/branches/ggreif/use-diet/lib: Analysis/ Transforms/IPO/ Transforms/Instrumentation/ Transforms/Scalar/ Transforms/Utils/

Gabor Greif ggreif at gmail.com
Wed Mar 26 04:50:43 PDT 2008


Author: ggreif
Date: Wed Mar 26 06:50:41 2008
New Revision: 48820

URL: http://llvm.org/viewvc/llvm-project?rev=48820&view=rev
Log:
Create-ify Analysis and Transforms

Modified:
    llvm/branches/ggreif/use-diet/lib/Analysis/ScalarEvolutionExpander.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ArgumentPromotion.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/DeadArgumentElimination.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractFunction.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractGV.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/IndMemRemoval.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/LowerSetJmp.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/PruneEH.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/RaiseAllocations.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/SimplifyLibCalls.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/IPO/StructRetPromotion.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/ProfilingUtils.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/RSProfiling.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/ADCE.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GCSE.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GVN.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GVNPRE.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/IndVarSimplify.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/InstructionCombining.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopIndexSplit.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopRotation.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopUnswitch.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/SCCP.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/ScalarReplAggregates.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/SimplifyCFG.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/TailRecursionElimination.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/BasicBlockUtils.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/BreakCriticalEdges.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneFunction.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneModule.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CodeExtractor.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/InlineFunction.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LCSSA.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/Local.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LoopSimplify.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerAllocations.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerInvoke.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerSwitch.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/branches/ggreif/use-diet/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp

Modified: llvm/branches/ggreif/use-diet/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Analysis/ScalarEvolutionExpander.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Analysis/ScalarEvolutionExpander.cpp Wed Mar 26 06:50:41 2008
@@ -143,7 +143,7 @@
     // Create and insert the PHI node for the induction variable in the
     // specified loop.
     BasicBlock *Header = L->getHeader();
-    PHINode *PN = new PHINode(Ty, "indvar", Header->begin());
+    PHINode *PN = PHINode::Create(Ty, "indvar", Header->begin());
     PN->addIncoming(Constant::getNullValue(Ty), L->getLoopPreheader());
 
     pred_iterator HPI = pred_begin(Header);
@@ -215,7 +215,7 @@
   for (unsigned i = 1; i < S->getNumOperands(); ++i) {
     Value *RHS = expand(S->getOperand(i));
     Value *ICmp = new ICmpInst(ICmpInst::ICMP_SGT, LHS, RHS, "tmp", InsertPt);
-    LHS = new SelectInst(ICmp, LHS, RHS, "smax", InsertPt);
+    LHS = SelectInst::Create(ICmp, LHS, RHS, "smax", InsertPt);
   }
   return LHS;
 }
@@ -225,7 +225,7 @@
   for (unsigned i = 1; i < S->getNumOperands(); ++i) {
     Value *RHS = expand(S->getOperand(i));
     Value *ICmp = new ICmpInst(ICmpInst::ICMP_UGT, LHS, RHS, "tmp", InsertPt);
-    LHS = new SelectInst(ICmp, LHS, RHS, "umax", InsertPt);
+    LHS = SelectInst::Create(ICmp, LHS, RHS, "umax", InsertPt);
   }
   return LHS;
 }

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ArgumentPromotion.cpp Wed Mar 26 06:50:41 2008
@@ -469,7 +469,7 @@
   FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
 
   // Create the new function body and insert it into the module...
-  Function *NF = new Function(NFTy, F->getLinkage(), F->getName());
+  Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName());
   NF->setCallingConv(F->getCallingConv());
 
   // Recompute the parameter attributes list based on the new arguments for
@@ -517,9 +517,9 @@
         Value *Idxs[2] = { ConstantInt::get(Type::Int32Ty, 0), 0 };
         for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
           Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
-          Value *Idx = new GetElementPtrInst(*AI, Idxs, Idxs+2,
-                                             (*AI)->getName()+"."+utostr(i),
-                                             Call);
+          Value *Idx = GetElementPtrInst::Create(*AI, Idxs, Idxs+2,
+                                                 (*AI)->getName()+"."+utostr(i),
+                                                 Call);
           // TODO: Tell AA about the new values?
           Args.push_back(new LoadInst(Idx, Idx->getName()+".val", Call));
         }        
@@ -531,8 +531,8 @@
           Value *V = *AI;
           LoadInst *OrigLoad = OriginalLoads[*SI];
           if (!SI->empty()) {
-            V = new GetElementPtrInst(V, SI->begin(), SI->end(),
-                                      V->getName()+".idx", Call);
+            V = GetElementPtrInst::Create(V, SI->begin(), SI->end(),
+                                          V->getName()+".idx", Call);
             AA.copyValue(OrigLoad->getOperand(0), V);
           }
           Args.push_back(new LoadInst(V, V->getName()+".val", Call));
@@ -552,13 +552,13 @@
 
     Instruction *New;
     if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
-      New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
-                           Args.begin(), Args.end(), "", Call);
+      New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
+                               Args.begin(), Args.end(), "", Call);
       cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
       cast<InvokeInst>(New)->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(),
                                                           ParamAttrsVec.end()));
     } else {
-      New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
+      New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
       cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
       cast<CallInst>(New)->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(),
                                                         ParamAttrsVec.end()));
@@ -615,9 +615,9 @@
       
       for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
         Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
-        Value *Idx = new GetElementPtrInst(TheAlloca, Idxs, Idxs+2,
-                                           TheAlloca->getName()+"."+utostr(i),
-                                           InsertPt);
+        Value *Idx = GetElementPtrInst::Create(TheAlloca, Idxs, Idxs+2,
+                                               TheAlloca->getName()+"."+utostr(i),
+                                               InsertPt);
         I2->setName(I->getName()+"."+utostr(i));
         new StoreInst(I2++, Idx, InsertPt);
       }

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/DeadArgumentElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/DeadArgumentElimination.cpp Wed Mar 26 06:50:41 2008
@@ -156,7 +156,7 @@
   unsigned NumArgs = Params.size();
 
   // Create the new function body and insert it into the module...
-  Function *NF = new Function(NFTy, Fn.getLinkage());
+  Function *NF = Function::Create(NFTy, Fn.getLinkage());
   NF->setCallingConv(Fn.getCallingConv());
   NF->setParamAttrs(Fn.getParamAttrs());
   if (Fn.hasCollector())
@@ -186,12 +186,12 @@
 
     Instruction *New;
     if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
-      New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
-                           Args.begin(), Args.end(), "", Call);
+      New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
+                               Args.begin(), Args.end(), "", Call);
       cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
       cast<InvokeInst>(New)->setParamAttrs(PAL);
     } else {
-      New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
+      New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
       cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
       cast<CallInst>(New)->setParamAttrs(PAL);
       if (cast<CallInst>(Call)->isTailCall())
@@ -549,7 +549,7 @@
   FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
 
   // Create the new function body and insert it into the module...
-  Function *NF = new Function(NFTy, F->getLinkage());
+  Function *NF = Function::Create(NFTy, F->getLinkage());
   NF->setCallingConv(F->getCallingConv());
   NF->setParamAttrs(NewPAL);
   if (F->hasCollector())
@@ -601,12 +601,12 @@
 
     Instruction *New;
     if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
-      New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
-                           Args.begin(), Args.end(), "", Call);
+      New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
+                               Args.begin(), Args.end(), "", Call);
       cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
       cast<InvokeInst>(New)->setParamAttrs(NewCallPAL);
     } else {
-      New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
+      New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
       cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
       cast<CallInst>(New)->setParamAttrs(NewCallPAL);
       if (cast<CallInst>(Call)->isTailCall())
@@ -659,7 +659,7 @@
   if (F->getReturnType() != NF->getReturnType())
     for (Function::iterator BB = NF->begin(), E = NF->end(); BB != E; ++BB)
       if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) {
-        new ReturnInst(0, RI);
+        ReturnInst::Create(0, RI);
         BB->getInstList().erase(RI);
       }
 

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractFunction.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractFunction.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractFunction.cpp Wed Mar 26 06:50:41 2008
@@ -92,8 +92,8 @@
 
       for (Module::iterator I = M.begin(); ; ++I) {
         if (&*I != Named) {
-          Function *New = new Function(I->getFunctionType(),
-                                       GlobalValue::ExternalLinkage);
+          Function *New = Function::Create(I->getFunctionType(),
+                                           GlobalValue::ExternalLinkage);
           New->setCallingConv(I->getCallingConv());
           New->setParamAttrs(I->getParamAttrs());
           if (I->hasCollector())

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractGV.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractGV.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractGV.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractGV.cpp Wed Mar 26 06:50:41 2008
@@ -121,8 +121,8 @@
 
       for (Module::iterator I = M.begin(); ; ++I) {
         if (std::find(Named.begin(), Named.end(), &*I) == Named.end()) {
-          Function *New = new Function(I->getFunctionType(),
-                                       GlobalValue::ExternalLinkage);
+          Function *New = Function::Create(I->getFunctionType(),
+                                           GlobalValue::ExternalLinkage);
           New->setCallingConv(I->getCallingConv());
           New->setParamAttrs(I->getParamAttrs());
           if (I->hasCollector())

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/GlobalOpt.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/GlobalOpt.cpp Wed Mar 26 06:50:41 2008
@@ -545,8 +545,8 @@
         Idxs.push_back(NullInt);
         for (unsigned i = 3, e = GEPI->getNumOperands(); i != e; ++i)
           Idxs.push_back(GEPI->getOperand(i));
-        NewPtr = new GetElementPtrInst(NewPtr, Idxs.begin(), Idxs.end(),
-                                       GEPI->getName()+"."+utostr(Val), GEPI);
+        NewPtr = GetElementPtrInst::Create(NewPtr, Idxs.begin(), Idxs.end(),
+                                           GEPI->getName()+"."+utostr(Val), GEPI);
       }
     }
     GEP->replaceAllUsesWith(NewPtr);
@@ -788,8 +788,8 @@
                      MI->getAlignment(), MI->getName(), MI);
     Value* Indices[2];
     Indices[0] = Indices[1] = Constant::getNullValue(Type::Int32Ty);
-    Value *NewGEP = new GetElementPtrInst(NewMI, Indices, Indices + 2,
-                                          NewMI->getName()+".el0", MI);
+    Value *NewGEP = GetElementPtrInst::Create(NewMI, Indices, Indices + 2,
+                                              NewMI->getName()+".el0", MI);
     MI->replaceAllUsesWith(NewGEP);
     MI->eraseFromParent();
     MI = NewMI;
@@ -1053,8 +1053,8 @@
     GEPIdx.push_back(GEPI->getOperand(1));
     GEPIdx.append(GEPI->op_begin()+3, GEPI->op_end());
     
-    Value *NGEPI = new GetElementPtrInst(NewPtr, GEPIdx.begin(), GEPIdx.end(),
-                                         GEPI->getName(), GEPI);
+    Value *NGEPI = GetElementPtrInst::Create(NewPtr, GEPIdx.begin(), GEPIdx.end(),
+                                             GEPI->getName(), GEPI);
     GEPI->replaceAllUsesWith(NGEPI);
     GEPI->eraseFromParent();
     return;
@@ -1069,8 +1069,8 @@
   for (unsigned i = 0, e = FieldGlobals.size(); i != e; ++i) {
     Value *LoadV = GetHeapSROALoad(Load, i, FieldGlobals, InsertedLoadsForPtr);
 
-    PHINode *FieldPN = new PHINode(LoadV->getType(),
-                                   PN->getName()+"."+utostr(i), PN);
+    PHINode *FieldPN = PHINode::Create(LoadV->getType(),
+                                       PN->getName()+"."+utostr(i), PN);
     // Fill in the predecessor values.
     for (unsigned pred = 0, e = PN->getNumIncomingValues(); pred != e; ++pred) {
       // Each predecessor either uses the load or the original malloc.
@@ -1172,13 +1172,13 @@
   
   // Create the block to check the first condition.  Put all these blocks at the
   // end of the function as they are unlikely to be executed.
-  BasicBlock *NullPtrBlock = new BasicBlock("malloc_ret_null",
-                                            OrigBB->getParent());
+  BasicBlock *NullPtrBlock = BasicBlock::Create("malloc_ret_null",
+                                                OrigBB->getParent());
   
   // Remove the uncond branch from OrigBB to ContBB, turning it into a cond
   // branch on RunningOr.
   OrigBB->getTerminator()->eraseFromParent();
-  new BranchInst(NullPtrBlock, ContBB, RunningOr, OrigBB);
+  BranchInst::Create(NullPtrBlock, ContBB, RunningOr, OrigBB);
   
   // Within the NullPtrBlock, we need to emit a comparison and branch for each
   // pointer, because some may be null while others are not.
@@ -1187,21 +1187,20 @@
     Value *Cmp = new ICmpInst(ICmpInst::ICMP_NE, GVVal, 
                               Constant::getNullValue(GVVal->getType()),
                               "tmp", NullPtrBlock);
-    BasicBlock *FreeBlock = new BasicBlock("free_it", OrigBB->getParent());
-    BasicBlock *NextBlock = new BasicBlock("next", OrigBB->getParent());
-    new BranchInst(FreeBlock, NextBlock, Cmp, NullPtrBlock);
+    BasicBlock *FreeBlock = BasicBlock::Create("free_it", OrigBB->getParent());
+    BasicBlock *NextBlock = BasicBlock::Create("next", OrigBB->getParent());
+    BranchInst::Create(FreeBlock, NextBlock, Cmp, NullPtrBlock);
 
     // Fill in FreeBlock.
     new FreeInst(GVVal, FreeBlock);
     new StoreInst(Constant::getNullValue(GVVal->getType()), FieldGlobals[i],
                   FreeBlock);
-    new BranchInst(NextBlock, FreeBlock);
+    BranchInst::Create(NextBlock, FreeBlock);
     
     NullPtrBlock = NextBlock;
   }
   
-  new BranchInst(ContBB, NullPtrBlock);
-  
+  BranchInst::Create(ContBB, NullPtrBlock);
   
   // MI is no longer needed, remove it.
   MI->eraseFromParent();
@@ -1410,7 +1409,7 @@
       if (IsOneZero)
         NSI = new ZExtInst(NLI, LI->getType(), "", LI);
       else
-        NSI = new SelectInst(NLI, OtherVal, InitVal, "", LI);
+        NSI = SelectInst::Create(NLI, OtherVal, InitVal, "", LI);
       NSI->takeName(LI);
       LI->replaceAllUsesWith(NSI);
     }

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/IndMemRemoval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/IndMemRemoval.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/IndMemRemoval.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/IndMemRemoval.cpp Wed Mar 26 06:50:41 2008
@@ -52,11 +52,11 @@
   if (Function* F = M.getFunction("free")) {
     assert(F->isDeclaration() && "free not external?");
     if (!F->use_empty()) {
-      Function* FN = new Function(F->getFunctionType(), 
-                                  GlobalValue::LinkOnceLinkage, 
-                                  "free_llvm_bounce", &M);
-      BasicBlock* bb = new BasicBlock("entry",FN);
-      Instruction* R = new ReturnInst(bb);
+      Function* FN = Function::Create(F->getFunctionType(), 
+                                      GlobalValue::LinkOnceLinkage, 
+                                      "free_llvm_bounce", &M);
+      BasicBlock* bb = BasicBlock::Create("entry",FN);
+      Instruction* R = ReturnInst::Create(bb);
       new FreeInst(FN->arg_begin(), R);
       ++NumBounce;
       NumBounceSites += F->getNumUses();
@@ -67,14 +67,14 @@
   if (Function* F = M.getFunction("malloc")) {
     assert(F->isDeclaration() && "malloc not external?");
     if (!F->use_empty()) {
-      Function* FN = new Function(F->getFunctionType(), 
-                                  GlobalValue::LinkOnceLinkage, 
-                                  "malloc_llvm_bounce", &M);
-      BasicBlock* bb = new BasicBlock("entry",FN);
+      Function* FN = Function::Create(F->getFunctionType(), 
+                                      GlobalValue::LinkOnceLinkage, 
+                                      "malloc_llvm_bounce", &M);
+      BasicBlock* bb = BasicBlock::Create("entry",FN);
       Instruction* c = CastInst::createIntegerCast(
           FN->arg_begin(), Type::Int32Ty, false, "c", bb);
       Instruction* a = new MallocInst(Type::Int8Ty, c, "m", bb);
-      new ReturnInst(a, bb);
+      ReturnInst::Create(a, bb);
       ++NumBounce;
       NumBounceSites += F->getNumUses();
       F->replaceAllUsesWith(FN);

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/LowerSetJmp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/LowerSetJmp.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/LowerSetJmp.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/LowerSetJmp.cpp Wed Mar 26 06:50:41 2008
@@ -267,7 +267,7 @@
   SmallVector<Value *, 2> Args;
   Args.push_back(CI);
   Args.push_back(Inst->getOperand(2));
-  new CallInst(ThrowLongJmp, Args.begin(), Args.end(), "", Inst);
+  CallInst::Create(ThrowLongJmp, Args.begin(), Args.end(), "", Inst);
 
   SwitchValuePair& SVP = SwitchValMap[Inst->getParent()->getParent()];
 
@@ -275,7 +275,7 @@
   // we should branch to the basic block that determines if this longjmp
   // is applicable here. Otherwise, issue an unwind.
   if (SVP.first)
-    new BranchInst(SVP.first->getParent(), Inst);
+    BranchInst::Create(SVP.first->getParent(), Inst);
   else
     new UnwindInst(Inst);
 
@@ -310,7 +310,7 @@
   // Fill in the alloca and call to initialize the SJ map.
   const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
   AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
-  new CallInst(InitSJMap, Map, "", Inst);
+  CallInst::Create(InitSJMap, Map, "", Inst);
   return SJMap[Func] = Map;
 }
 
@@ -323,7 +323,7 @@
 
   // The basic block we're going to jump to if we need to rethrow the
   // exception.
-  BasicBlock* Rethrow = new BasicBlock("RethrowExcept", Func);
+  BasicBlock* Rethrow = BasicBlock::Create("RethrowExcept", Func);
 
   // Fill in the "Rethrow" BB with a call to rethrow the exception. This
   // is the last instruction in the BB since at this point the runtime
@@ -339,7 +339,7 @@
 {
   if (SwitchValMap[Func].first) return SwitchValMap[Func];
 
-  BasicBlock* LongJmpPre = new BasicBlock("LongJmpBlkPre", Func);
+  BasicBlock* LongJmpPre = BasicBlock::Create("LongJmpBlkPre", Func);
   BasicBlock::InstListType& LongJmpPreIL = LongJmpPre->getInstList();
 
   // Keep track of the preliminary basic block for some of the other
@@ -347,24 +347,24 @@
   PrelimBBMap[Func] = LongJmpPre;
 
   // Grab the exception.
-  CallInst* Cond = new CallInst(IsLJException, "IsLJExcept");
+  CallInst* Cond = CallInst::Create(IsLJException, "IsLJExcept");
   LongJmpPreIL.push_back(Cond);
 
   // The "decision basic block" gets the number associated with the
   // setjmp call returning to switch on and the value returned by
   // longjmp.
-  BasicBlock* DecisionBB = new BasicBlock("LJDecisionBB", Func);
+  BasicBlock* DecisionBB = BasicBlock::Create("LJDecisionBB", Func);
   BasicBlock::InstListType& DecisionBBIL = DecisionBB->getInstList();
 
-  new BranchInst(DecisionBB, Rethrow, Cond, LongJmpPre);
+  BranchInst::Create(DecisionBB, Rethrow, Cond, LongJmpPre);
 
   // Fill in the "decision" basic block.
-  CallInst* LJVal = new CallInst(GetLJValue, "LJVal");
+  CallInst* LJVal = CallInst::Create(GetLJValue, "LJVal");
   DecisionBBIL.push_back(LJVal);
-  CallInst* SJNum = new CallInst(TryCatchLJ, GetSetJmpMap(Func), "SJNum");
+  CallInst* SJNum = CallInst::Create(TryCatchLJ, GetSetJmpMap(Func), "SJNum");
   DecisionBBIL.push_back(SJNum);
 
-  SwitchInst* SI = new SwitchInst(SJNum, Rethrow, 0, DecisionBB);
+  SwitchInst* SI = SwitchInst::Create(SJNum, Rethrow, 0, DecisionBB);
   return SwitchValMap[Func] = SwitchValuePair(SI, LJVal);
 }
 
@@ -385,7 +385,7 @@
     make_vector<Value*>(GetSetJmpMap(Func), BufPtr,
                         ConstantInt::get(Type::Int32Ty,
                                          SetJmpIDMap[Func]++), 0);
-  new CallInst(AddSJToMap, Args.begin(), Args.end(), "", Inst);
+  CallInst::Create(AddSJToMap, Args.begin(), Args.end(), "", Inst);
 
   // We are guaranteed that there are no values live across basic blocks
   // (because we are "not in SSA form" yet), but there can still be values live
@@ -427,7 +427,7 @@
 
   // This PHI node will be in the new block created from the
   // splitBasicBlock call.
-  PHINode* PHI = new PHINode(Type::Int32Ty, "SetJmpReturn", Inst);
+  PHINode* PHI = PHINode::Create(Type::Int32Ty, "SetJmpReturn", Inst);
 
   // Coming from a call to setjmp, the return is 0.
   PHI->addIncoming(ConstantInt::getNullValue(Type::Int32Ty), ABlock);
@@ -473,9 +473,9 @@
   // Construct the new "invoke" instruction.
   TerminatorInst* Term = OldBB->getTerminator();
   std::vector<Value*> Params(CI.op_begin() + 1, CI.op_end());
-  InvokeInst* II = new
-    InvokeInst(CI.getCalledValue(), NewBB, PrelimBBMap[Func],
-               Params.begin(), Params.end(), CI.getName(), Term);
+  InvokeInst* II =
+    InvokeInst::Create(CI.getCalledValue(), NewBB, PrelimBBMap[Func],
+                       Params.begin(), Params.end(), CI.getName(), Term);
   II->setCallingConv(CI.getCallingConv());
   II->setParamAttrs(CI.getParamAttrs());
 
@@ -506,15 +506,15 @@
   BasicBlock* ExceptBB = II.getUnwindDest();
 
   Function* Func = BB->getParent();
-  BasicBlock* NewExceptBB = new BasicBlock("InvokeExcept", Func);
+  BasicBlock* NewExceptBB = BasicBlock::Create("InvokeExcept", Func);
   BasicBlock::InstListType& InstList = NewExceptBB->getInstList();
 
   // If this is a longjmp exception, then branch to the preliminary BB of
   // the longjmp exception handling. Otherwise, go to the old exception.
-  CallInst* IsLJExcept = new CallInst(IsLJException, "IsLJExcept");
+  CallInst* IsLJExcept = CallInst::Create(IsLJException, "IsLJExcept");
   InstList.push_back(IsLJExcept);
 
-  new BranchInst(PrelimBBMap[Func], ExceptBB, IsLJExcept, NewExceptBB);
+  BranchInst::Create(PrelimBBMap[Func], ExceptBB, IsLJExcept, NewExceptBB);
 
   II.setUnwindDest(NewExceptBB);
   ++InvokesTransformed;
@@ -524,14 +524,14 @@
 // function.
 void LowerSetJmp::visitReturnInst(ReturnInst &RI) {
   Function* Func = RI.getParent()->getParent();
-  new CallInst(DestroySJMap, GetSetJmpMap(Func), "", &RI);
+  CallInst::Create(DestroySJMap, GetSetJmpMap(Func), "", &RI);
 }
 
 // visitUnwindInst - We want to destroy the setjmp map upon exit from the
 // function.
 void LowerSetJmp::visitUnwindInst(UnwindInst &UI) {
   Function* Func = UI.getParent()->getParent();
-  new CallInst(DestroySJMap, GetSetJmpMap(Func), "", &UI);
+  CallInst::Create(DestroySJMap, GetSetJmpMap(Func), "", &UI);
 }
 
 ModulePass *llvm::createLowerSetJmpPass() {

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/PruneEH.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/PruneEH.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/PruneEH.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/PruneEH.cpp Wed Mar 26 06:50:41 2008
@@ -158,8 +158,8 @@
       if (II->doesNotThrow()) {
         SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
         // Insert a call instruction before the invoke.
-        CallInst *Call = new CallInst(II->getCalledValue(),
-                                      Args.begin(), Args.end(), "", II);
+        CallInst *Call = CallInst::Create(II->getCalledValue(),
+                                          Args.begin(), Args.end(), "", II);
         Call->takeName(II);
         Call->setCallingConv(II->getCallingConv());
         Call->setParamAttrs(II->getParamAttrs());
@@ -172,7 +172,7 @@
 
         // Insert a branch to the normal destination right before the
         // invoke.
-        new BranchInst(II->getNormalDest(), II);
+        BranchInst::Create(II->getNormalDest(), II);
 
         // Finally, delete the invoke instruction!
         BB->getInstList().pop_back();

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/RaiseAllocations.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/RaiseAllocations.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/RaiseAllocations.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/RaiseAllocations.cpp Wed Mar 26 06:50:41 2008
@@ -175,7 +175,7 @@
           // If the old instruction was an invoke, add an unconditional branch
           // before the invoke, which will become the new terminator.
           if (InvokeInst *II = dyn_cast<InvokeInst>(I))
-            new BranchInst(II->getNormalDest(), I);
+            BranchInst::Create(II->getNormalDest(), I);
 
           // Delete the old call site
           MI->getParent()->getInstList().erase(I);
@@ -227,7 +227,7 @@
           // If the old instruction was an invoke, add an unconditional branch
           // before the invoke, which will become the new terminator.
           if (InvokeInst *II = dyn_cast<InvokeInst>(I))
-            new BranchInst(II->getNormalDest(), I);
+            BranchInst::Create(II->getNormalDest(), I);
 
           // Delete the old call site
           if (I->getType() != Type::VoidTy)

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/SimplifyLibCalls.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/SimplifyLibCalls.cpp Wed Mar 26 06:50:41 2008
@@ -430,7 +430,7 @@
           // Create a return instruction that we'll replace the call with.
           // Note that the argument of the return is the argument of the call
           // instruction.
-          new ReturnInst(ci->getOperand(1), ci);
+          ReturnInst::Create(ci->getOperand(1), ci);
 
           // Split the block at the call instruction which places it in a new
           // basic block.
@@ -496,13 +496,13 @@
 
     // We need to find the end of the destination string.  That's where the
     // memory is to be moved to. We just generate a call to strlen.
-    CallInst *DstLen = new CallInst(SLC.get_strlen(), Dst,
-                                    Dst->getName()+".len", CI);
+    CallInst *DstLen = CallInst::Create(SLC.get_strlen(), Dst,
+                                        Dst->getName()+".len", CI);
 
     // Now that we have the destination's length, we must index into the
     // destination's pointer to get the actual memcpy destination (end of
     // the string .. we're concatenating).
-    Dst = new GetElementPtrInst(Dst, DstLen, Dst->getName()+".indexed", CI);
+    Dst = GetElementPtrInst::Create(Dst, DstLen, Dst->getName()+".indexed", CI);
 
     // We have enough information to now generate the memcpy call to
     // do the concatenation for us.
@@ -511,7 +511,7 @@
       ConstantInt::get(SLC.getIntPtrType(), SrcStr.size()+1), // copy nul byte.
       ConstantInt::get(Type::Int32Ty, 1)  // alignment
     };
-    new CallInst(SLC.get_memcpy(), Vals, Vals + 4, "", CI);
+    CallInst::Create(SLC.get_memcpy(), Vals, Vals + 4, "", CI);
 
     return ReplaceCallWith(CI, Dst);
   }
@@ -551,8 +551,8 @@
         CI->getOperand(2),
         ConstantInt::get(SLC.getIntPtrType(), Str.size()+1)
       };
-      return ReplaceCallWith(CI, new CallInst(SLC.get_memchr(), Args, Args + 3,
-                                              CI->getName(), CI));
+      return ReplaceCallWith(CI, CallInst::Create(SLC.get_memchr(), Args, Args + 3,
+                                                  CI->getName(), CI));
     }
 
     // strchr can find the nul character.
@@ -575,9 +575,9 @@
     // strchr(s+n,c)  -> gep(s+n+i,c)
     //    (if c is a constant integer and s is a constant string)
     Value *Idx = ConstantInt::get(Type::Int64Ty, i);
-    Value *GEP = new GetElementPtrInst(CI->getOperand(1), Idx, 
-                                       CI->getOperand(1)->getName() +
-                                       ".strchr", CI);
+    Value *GEP = GetElementPtrInst::Create(CI->getOperand(1), Idx, 
+                                           CI->getOperand(1)->getName() +
+                                           ".strchr", CI);
     return ReplaceCallWith(CI, GEP);
   }
 } StrChrOptimizer;
@@ -754,7 +754,7 @@
       ConstantInt::get(SLC.getIntPtrType(), SrcStr.size()+1),
       ConstantInt::get(Type::Int32Ty, 1) // alignment
     };
-    new CallInst(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI);
+    CallInst::Create(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI);
 
     return ReplaceCallWith(CI, Dst);
   }
@@ -900,8 +900,8 @@
         Value *D1 = BinaryOperator::createSub(S1V1, S2V1,
                                               CI->getName()+".d1", CI);
         Constant *One = ConstantInt::get(Type::Int32Ty, 1);
-        Value *G1 = new GetElementPtrInst(Op1Cast, One, "next1v", CI);
-        Value *G2 = new GetElementPtrInst(Op2Cast, One, "next2v", CI);
+        Value *G1 = GetElementPtrInst::Create(Op1Cast, One, "next1v", CI);
+        Value *G2 = GetElementPtrInst::Create(Op2Cast, One, "next2v", CI);
         Value *S1V2 = new LoadInst(G1, LHS->getName()+".val2", CI);
         Value *S2V2 = new LoadInst(G2, RHS->getName()+".val2", CI);
         Value *D2 = BinaryOperator::createSub(S1V2, S2V2,
@@ -946,7 +946,7 @@
       CI->getOperand(1), CI->getOperand(2), CI->getOperand(3),
       ConstantInt::get(Type::Int32Ty, 1)   // align = 1 always.
     };
-    new CallInst(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI);
+    CallInst::Create(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI);
     // memcpy always returns the destination
     return ReplaceCallWith(CI, CI->getOperand(1));
   }
@@ -1162,8 +1162,8 @@
             Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0)));
       } else if (Op2->isExactlyValue(0.5)) {
         // pow(x,0.5) -> sqrt(x)
-        CallInst* sqrt_inst = new CallInst(SLC.get_sqrt(), base,
-            ci->getName()+".pow",ci);
+        CallInst* sqrt_inst = CallInst::Create(SLC.get_sqrt(), base,
+                                               ci->getName()+".pow",ci);
         return ReplaceCallWith(ci, sqrt_inst);
       } else if (Op2->isExactlyValue(1.0)) {
         // pow(x,1.0) -> x
@@ -1220,7 +1220,7 @@
     if (FormatStr.size() == 1) {
       // Turn this into a putchar call, even if it is a %.
       Value *V = ConstantInt::get(Type::Int32Ty, FormatStr[0]);
-      new CallInst(SLC.get_putchar(), V, "", CI);
+      CallInst::Create(SLC.get_putchar(), V, "", CI);
       if (CI->use_empty()) return ReplaceCallWith(CI, 0);
       return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
     }
@@ -1240,7 +1240,7 @@
                                      CI->getParent()->getParent()->getParent());
       // Cast GV to be a pointer to char.
       GV = ConstantExpr::getBitCast(GV, PointerType::getUnqual(Type::Int8Ty));
-      new CallInst(SLC.get_puts(), GV, "", CI);
+      CallInst::Create(SLC.get_puts(), GV, "", CI);
 
       if (CI->use_empty()) return ReplaceCallWith(CI, 0);
       // The return value from printf includes the \n we just removed, so +1.
@@ -1264,8 +1264,8 @@
         return false;
 
       // printf("%s\n",str) -> puts(str)
-      new CallInst(SLC.get_puts(), CastToCStr(CI->getOperand(2), CI),
-                   CI->getName(), CI);
+      CallInst::Create(SLC.get_puts(), CastToCStr(CI->getOperand(2), CI),
+                       CI->getName(), CI);
       return ReplaceCallWith(CI, 0);
     case 'c': {
       // printf("%c",c) -> putchar(c)
@@ -1279,7 +1279,7 @@
 
       V = CastInst::createZExtOrBitCast(V, Type::Int32Ty, CI->getName()+".int",
                                         CI);
-      new CallInst(SLC.get_putchar(), V, "", CI);
+      CallInst::Create(SLC.get_putchar(), V, "", CI);
       return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
     }
     }
@@ -1331,7 +1331,7 @@
         ConstantInt::get(SLC.getIntPtrType(), 1),
         CI->getOperand(1)
       };
-      new CallInst(SLC.get_fwrite(FILEty), FWriteArgs, FWriteArgs + 4, CI->getName(), CI);
+      CallInst::Create(SLC.get_fwrite(FILEty), FWriteArgs, FWriteArgs + 4, CI->getName(), CI);
       return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 
                                                   FormatStr.size()));
     }
@@ -1351,7 +1351,7 @@
       SmallVector<Value *, 2> Args;
       Args.push_back(C);
       Args.push_back(CI->getOperand(1));
-      new CallInst(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
+      CallInst::Create(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
       return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
     }
     case 's': {
@@ -1366,8 +1366,8 @@
       SmallVector<Value *, 2> Args;
       Args.push_back(CastToCStr(CI->getOperand(3), CI));
       Args.push_back(CI->getOperand(1));
-      new CallInst(SLC.get_fputs(FILETy), Args.begin(),
-                   Args.end(), CI->getName(), CI);
+      CallInst::Create(SLC.get_fputs(FILETy), Args.begin(),
+                       Args.end(), CI->getName(), CI);
       return ReplaceCallWith(CI, 0);
     }
     default:
@@ -1418,7 +1418,7 @@
                          FormatStr.size()+1), // Copy the nul byte.
         ConstantInt::get(Type::Int32Ty, 1)
       };
-      new CallInst(SLC.get_memcpy(), MemCpyArgs, MemCpyArgs + 4, "", CI);
+      CallInst::Create(SLC.get_memcpy(), MemCpyArgs, MemCpyArgs + 4, "", CI);
       return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 
                                                   FormatStr.size()));
     }
@@ -1434,18 +1434,18 @@
       Value *V = CastInst::createTruncOrBitCast(CI->getOperand(3),
                                                 Type::Int8Ty, "char", CI);
       new StoreInst(V, CI->getOperand(1), CI);
-      Value *Ptr = new GetElementPtrInst(CI->getOperand(1),
-                                         ConstantInt::get(Type::Int32Ty, 1),
-                                         CI->getOperand(1)->getName()+".end",
-                                         CI);
+      Value *Ptr = GetElementPtrInst::Create(CI->getOperand(1),
+                                             ConstantInt::get(Type::Int32Ty, 1),
+                                             CI->getOperand(1)->getName()+".end",
+                                             CI);
       new StoreInst(ConstantInt::get(Type::Int8Ty,0), Ptr, CI);
       return ReplaceCallWith(CI, ConstantInt::get(Type::Int32Ty, 1));
     }
     case 's': {
       // sprintf(dest,"%s",str) -> llvm.memcpy(dest, str, strlen(str)+1, 1)
-      Value *Len = new CallInst(SLC.get_strlen(),
-                                CastToCStr(CI->getOperand(3), CI),
-                                CI->getOperand(3)->getName()+".len", CI);
+      Value *Len = CallInst::Create(SLC.get_strlen(),
+                                    CastToCStr(CI->getOperand(3), CI),
+                                    CI->getOperand(3)->getName()+".len", CI);
       Value *UnincLen = Len;
       Len = BinaryOperator::createAdd(Len, ConstantInt::get(Len->getType(), 1),
                                       Len->getName()+"1", CI);
@@ -1455,7 +1455,7 @@
         Len,
         ConstantInt::get(Type::Int32Ty, 1)
       };
-      new CallInst(SLC.get_memcpy(), MemcpyArgs, MemcpyArgs + 4, "", CI);
+      CallInst::Create(SLC.get_memcpy(), MemcpyArgs, MemcpyArgs + 4, "", CI);
       
       // The strlen result is the unincremented number of bytes in the string.
       if (!CI->use_empty()) {
@@ -1507,7 +1507,7 @@
       ConstantInt::get(SLC.getIntPtrType(), 1),
       CI->getOperand(2)
     };
-    new CallInst(SLC.get_fwrite(FILETy), FWriteParms, FWriteParms + 4, "", CI);
+    CallInst::Create(SLC.get_fwrite(FILETy), FWriteParms, FWriteParms + 4, "", CI);
     return ReplaceCallWith(CI, 0);  // Known to have no uses (see above).
   }
 } FPutsOptimizer;
@@ -1555,7 +1555,7 @@
       Args.push_back(new ZExtInst(Val, Type::Int32Ty, Val->getName()+".int", CI));
       Args.push_back(CI->getOperand(4));
       const Type *FILETy = CI->getOperand(4)->getType();
-      new CallInst(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
+      CallInst::Create(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
       return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
     }
     return false;
@@ -1715,7 +1715,7 @@
                                                        ArgType, NULL);
     Value *V = CastInst::createIntegerCast(TheCall->getOperand(1), ArgType, 
                                            false/*ZExt*/, "tmp", TheCall);
-    Value *V2 = new CallInst(F, V, "tmp", TheCall);
+    Value *V2 = CallInst::Create(F, V, "tmp", TheCall);
     V2 = CastInst::createIntegerCast(V2, Type::Int32Ty, false/*ZExt*/, 
                                      "tmp", TheCall);
     V2 = BinaryOperator::createAdd(V2, ConstantInt::get(Type::Int32Ty, 1),
@@ -1723,8 +1723,8 @@
     Value *Cond = new ICmpInst(ICmpInst::ICMP_EQ, V, 
                                Constant::getNullValue(V->getType()), "tmp", 
                                TheCall);
-    V2 = new SelectInst(Cond, ConstantInt::get(Type::Int32Ty, 0), V2,
-                        TheCall->getName(), TheCall);
+    V2 = SelectInst::Create(Cond, ConstantInt::get(Type::Int32Ty, 0), V2,
+                            TheCall->getName(), TheCall);
     return ReplaceCallWith(TheCall, V2);
   }
 } FFSOptimizer;
@@ -1773,8 +1773,8 @@
                                            Constant *(SimplifyLibCalls::*FP)()){
     if (FPExtInst *Cast = dyn_cast<FPExtInst>(CI->getOperand(1)))
       if (Cast->getOperand(0)->getType() == Type::FloatTy) {
-        Value *New = new CallInst((SLC.*FP)(), Cast->getOperand(0),
-                                  CI->getName(), CI);
+        Value *New = CallInst::Create((SLC.*FP)(), Cast->getOperand(0),
+                                      CI->getName(), CI);
         New = new FPExtInst(New, Type::DoubleTy, CI->getName(), CI);
         CI->replaceAllUsesWith(New);
         CI->eraseFromParent();

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/StructRetPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/StructRetPromotion.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/StructRetPromotion.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/StructRetPromotion.cpp Wed Mar 26 06:50:41 2008
@@ -116,14 +116,14 @@
           SmallVector<Value*, 2> GEPIdx;
           GEPIdx.push_back(ConstantInt::get(Type::Int32Ty, 0));
           GEPIdx.push_back(ConstantInt::get(Type::Int32Ty, idx));
-          Value *NGEPI = new GetElementPtrInst(TheAlloca, GEPIdx.begin(),
-                                               GEPIdx.end(),
-                                               "mrv.gep", I);
+          Value *NGEPI = GetElementPtrInst::Create(TheAlloca, GEPIdx.begin(),
+                                                   GEPIdx.end(),
+                                                   "mrv.gep", I);
           Value *NV = new LoadInst(NGEPI, "mrv.ld", I);
           RetVals.push_back(NV);
         }
     
-        ReturnInst *NR = new ReturnInst(&RetVals[0], RetVals.size(), I);
+        ReturnInst *NR = ReturnInst::Create(&RetVals[0], RetVals.size(), I);
         I->replaceAllUsesWith(NR);
         I->eraseFromParent();
       }
@@ -222,7 +222,7 @@
   }
 
   FunctionType *NFTy = FunctionType::get(STy, Params, FTy->isVarArg());
-  Function *NF = new Function(NFTy, F->getLinkage(), F->getName());
+  Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName());
   NF->setCallingConv(F->getCallingConv());
   NF->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(), ParamAttrsVec.end()));
   F->getParent()->getFunctionList().insert(F, NF);
@@ -283,12 +283,12 @@
     // Build new call instruction.
     Instruction *New;
     if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
-      New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
-                           Args.begin(), Args.end(), "", Call);
+      New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
+                               Args.begin(), Args.end(), "", Call);
       cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
       cast<InvokeInst>(New)->setParamAttrs(NewPAL);
     } else {
-      New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
+      New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
       cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
       cast<CallInst>(New)->setParamAttrs(NewPAL);
       if (cast<CallInst>(Call)->isTailCall())

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/ProfilingUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/ProfilingUtils.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/ProfilingUtils.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/ProfilingUtils.cpp Wed Mar 26 06:50:41 2008
@@ -55,8 +55,8 @@
   }
   Args[3] = ConstantInt::get(Type::Int32Ty, NumElements);
 
-  Instruction *InitCall = new CallInst(InitFn, Args.begin(), Args.end(),
-                                       "newargc", InsertPos);
+  Instruction *InitCall = CallInst::Create(InitFn, Args.begin(), Args.end(),
+                                           "newargc", InsertPos);
 
   // If argc or argv are not available in main, just pass null values in.
   Function::arg_iterator AI;

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/RSProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/RSProfiling.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/RSProfiling.cpp Wed Mar 26 06:50:41 2008
@@ -216,9 +216,9 @@
   
   //reset counter
   BasicBlock* oldnext = t->getSuccessor(0);
-  BasicBlock* resetblock = new BasicBlock("reset", oldnext->getParent(), 
-                                          oldnext);
-  TerminatorInst* t2 = new BranchInst(oldnext, resetblock);
+  BasicBlock* resetblock = BasicBlock::Create("reset", oldnext->getParent(), 
+                                              oldnext);
+  TerminatorInst* t2 = BranchInst::Create(oldnext, resetblock);
   t->setSuccessor(0, resetblock);
   new StoreInst(ResetValue, Counter, t2);
   ReplacePhiPred(oldnext, bb, resetblock);
@@ -291,9 +291,9 @@
   
   //reset counter
   BasicBlock* oldnext = t->getSuccessor(0);
-  BasicBlock* resetblock = new BasicBlock("reset", oldnext->getParent(), 
-                                          oldnext);
-  TerminatorInst* t2 = new BranchInst(oldnext, resetblock);
+  BasicBlock* resetblock = BasicBlock::Create("reset", oldnext->getParent(), 
+                                              oldnext);
+  TerminatorInst* t2 = BranchInst::Create(oldnext, resetblock);
   t->setSuccessor(0, resetblock);
   new StoreInst(ResetValue, AI, t2);
   ReplacePhiPred(oldnext, bb, resetblock);
@@ -311,7 +311,7 @@
 void CycleCounter::ProcessChoicePoint(BasicBlock* bb) {
   BranchInst* t = cast<BranchInst>(bb->getTerminator());
   
-  CallInst* c = new CallInst(F, "rdcc", t);
+  CallInst* c = CallInst::Create(F, "rdcc", t);
   BinaryOperator* b = 
     BinaryOperator::createAnd(c, ConstantInt::get(Type::Int64Ty, rm),
                               "mrdcc", t);
@@ -375,8 +375,8 @@
     if (bb == &bb->getParent()->getEntryBlock())
       TransCache[bb] = bb; //don't translate entry block
     else
-      TransCache[bb] = new BasicBlock("dup_" + bb->getName(), bb->getParent(), 
-                                      NULL);
+      TransCache[bb] = BasicBlock::Create("dup_" + bb->getName(), bb->getParent(), 
+                                          NULL);
     return TransCache[bb];
   } else if (Instruction* i = dyn_cast<Instruction>(v)) {
     //we have already translated this
@@ -464,16 +464,16 @@
   
   //a:
   Function::iterator BBN = src; ++BBN;
-  BasicBlock* bbC = new BasicBlock("choice", &F, BBN);
+  BasicBlock* bbC = BasicBlock::Create("choice", &F, BBN);
   //ChoicePoints.insert(bbC);
   BBN = cast<BasicBlock>(Translate(src));
-  BasicBlock* bbCp = new BasicBlock("choice", &F, ++BBN);
+  BasicBlock* bbCp = BasicBlock::Create("choice", &F, ++BBN);
   ChoicePoints.insert(bbCp);
   
   //b:
-  new BranchInst(cast<BasicBlock>(Translate(dst)), bbC);
-  new BranchInst(dst, cast<BasicBlock>(Translate(dst)), 
-                 ConstantInt::get(Type::Int1Ty, true), bbCp);
+  BranchInst::Create(cast<BasicBlock>(Translate(dst)), bbC);
+  BranchInst::Create(dst, cast<BasicBlock>(Translate(dst)), 
+                     ConstantInt::get(Type::Int1Ty, true), bbCp);
   //c:
   {
     TerminatorInst* iB = src->getTerminator();
@@ -527,10 +527,11 @@
     //oh, and add the edge from the reg2mem created entry node to the 
     //duplicated second node
     TerminatorInst* T = F.getEntryBlock().getTerminator();
-    ReplaceInstWithInst(T, new BranchInst(T->getSuccessor(0),
-                                          cast<BasicBlock>(
-                                            Translate(T->getSuccessor(0))),
-                                          ConstantInt::get(Type::Int1Ty, true)));
+    ReplaceInstWithInst(T, BranchInst::Create(T->getSuccessor(0),
+                                              cast<BasicBlock>(
+                                                Translate(T->getSuccessor(0))),
+                                              ConstantInt::get(Type::Int1Ty,
+                                                               true)));
     
     //do whatever is needed now that the function is duplicated
     c->PrepFunction(&F);

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/ADCE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/ADCE.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/ADCE.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/ADCE.cpp Wed Mar 26 06:50:41 2008
@@ -163,7 +163,7 @@
 /// successors it goes to.  This eliminate a use of the condition as well.
 ///
 TerminatorInst *ADCE::convertToUnconditionalBranch(TerminatorInst *TI) {
-  BranchInst *NB = new BranchInst(TI->getSuccessor(0), TI);
+  BranchInst *NB = BranchInst::Create(TI->getSuccessor(0), TI);
   BasicBlock *BB = TI->getParent();
 
   // Remove entries from PHI nodes to avoid confusing ourself later...
@@ -325,8 +325,8 @@
   // node as a special case.
   //
   if (!AliveBlocks.count(&Func->front())) {
-    BasicBlock *NewEntry = new BasicBlock();
-    new BranchInst(&Func->front(), NewEntry);
+    BasicBlock *NewEntry = BasicBlock::Create();
+    BranchInst::Create(&Func->front(), NewEntry);
     Func->getBasicBlockList().push_front(NewEntry);
     AliveBlocks.insert(NewEntry);    // This block is always alive!
     LiveSet.insert(NewEntry->getTerminator());  // The branch is live

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GCSE.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GCSE.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GCSE.cpp Wed Mar 26 06:50:41 2008
@@ -192,7 +192,7 @@
   if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
     // Removing an invoke instruction requires adding a branch to the normal
     // destination and removing PHI node entries in the exception destination.
-    new BranchInst(II->getNormalDest(), II);
+    BranchInst::Create(II->getNormalDest(), II);
     II->getUnwindDest()->removePredecessor(II->getParent());
   }
 

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GVN.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GVN.cpp Wed Mar 26 06:50:41 2008
@@ -851,8 +851,8 @@
   }
   // Otherwise, the idom is the loop, so we need to insert a PHI node.  Do so
   // now, then get values to fill in the incoming values for the PHI.
-  PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle",
-                            BB->begin());
+  PHINode *PN = PHINode::Create(orig->getType(), orig->getName()+".rle",
+                                BB->begin());
   PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));
   
   if (Phis.count(BB) == 0)
@@ -1238,7 +1238,7 @@
   args.push_back(M->getLength());
   args.push_back(M->getAlignment());
   
-  CallInst* C = new CallInst(MemCpyFun, args.begin(), args.end(), "", M);
+  CallInst* C = CallInst::Create(MemCpyFun, args.begin(), args.end(), "", M);
   
   MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>();
   if (MD.getDependency(C) == MDep) {

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GVNPRE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GVNPRE.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GVNPRE.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/GVNPRE.cpp Wed Mar 26 06:50:41 2008
@@ -904,10 +904,10 @@
         newVal = new ShuffleVectorInst(newOp1, newOp2, newOp3,
                                        S->getName()+".expr");
       else if (InsertElementInst* I = dyn_cast<InsertElementInst>(U))
-        newVal = new InsertElementInst(newOp1, newOp2, newOp3,
-                                       I->getName()+".expr");
+        newVal = InsertElementInst::Create(newOp1, newOp2, newOp3,
+                                           I->getName()+".expr");
       else if (SelectInst* I = dyn_cast<SelectInst>(U))
-        newVal = new SelectInst(newOp1, newOp2, newOp3, I->getName()+".expr");
+        newVal = SelectInst::Create(newOp1, newOp2, newOp3, I->getName()+".expr");
       
       uint32_t v = VN.lookup_or_add(newVal);
       
@@ -947,9 +947,10 @@
       }
     
     if (newOp1 != U->getPointerOperand() || changed_idx) {
-      Instruction* newVal = new GetElementPtrInst(newOp1,
-                                       newIdx.begin(), newIdx.end(),
-                                       U->getName()+".expr");
+      Instruction* newVal =
+          GetElementPtrInst::Create(newOp1,
+                                    newIdx.begin(), newIdx.end(),
+                                    U->getName()+".expr");
       
       uint32_t v = VN.lookup_or_add(newVal);
       
@@ -1667,24 +1668,23 @@
         newVal = new ShuffleVectorInst(s1, s2, s3, S->getName()+".gvnpre",
                                        (*PI)->getTerminator());
       else if (InsertElementInst* S = dyn_cast<InsertElementInst>(U))
-        newVal = new InsertElementInst(s1, s2, s3, S->getName()+".gvnpre",
-                                       (*PI)->getTerminator());
+        newVal = InsertElementInst::Create(s1, s2, s3, S->getName()+".gvnpre",
+                                           (*PI)->getTerminator());
       else if (ExtractElementInst* S = dyn_cast<ExtractElementInst>(U))
         newVal = new ExtractElementInst(s1, s2, S->getName()+".gvnpre",
                                         (*PI)->getTerminator());
       else if (SelectInst* S = dyn_cast<SelectInst>(U))
-        newVal = new SelectInst(s1, s2, s3, S->getName()+".gvnpre",
-                                (*PI)->getTerminator());
+        newVal = SelectInst::Create(s1, s2, s3, S->getName()+".gvnpre",
+                                    (*PI)->getTerminator());
       else if (CastInst* C = dyn_cast<CastInst>(U))
         newVal = CastInst::create(C->getOpcode(), s1, C->getType(),
                                   C->getName()+".gvnpre", 
                                   (*PI)->getTerminator());
       else if (GetElementPtrInst* G = dyn_cast<GetElementPtrInst>(U))
-        newVal = new GetElementPtrInst(s1, sVarargs.begin(), sVarargs.end(), 
-                                       G->getName()+".gvnpre", 
-                                       (*PI)->getTerminator());
-                                
-                  
+        newVal = GetElementPtrInst::Create(s1, sVarargs.begin(), sVarargs.end(),
+                                           G->getName()+".gvnpre", 
+                                           (*PI)->getTerminator());
+
       VN.add(newVal, VN.lookup(U));
                   
       ValueNumberedSet& predAvail = availableOut[*PI];
@@ -1705,7 +1705,7 @@
               
   for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) {
     if (p == 0)
-      p = new PHINode(avail[*PI]->getType(), "gvnpre-join", BB->begin());
+      p = PHINode::Create(avail[*PI]->getType(), "gvnpre-join", BB->begin());
     
     p->addIncoming(avail[*PI], *PI);
   }

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/IndVarSimplify.cpp Wed Mar 26 06:50:41 2008
@@ -145,8 +145,8 @@
       Value *AddedVal = GEPI->getOperand(1);
 
       // Insert a new integer PHI node into the top of the block.
-      PHINode *NewPhi = new PHINode(AddedVal->getType(),
-                                    PN->getName()+".rec", PN);
+      PHINode *NewPhi = PHINode::Create(AddedVal->getType(),
+                                        PN->getName()+".rec", PN);
       NewPhi->addIncoming(Constant::getNullValue(NewPhi->getType()), Preheader);
 
       // Create the new add instruction.
@@ -181,7 +181,7 @@
               Value *Idx[2];
               Idx[0] = Constant::getNullValue(Type::Int32Ty);
               Idx[1] = NewAdd;
-              GetElementPtrInst *NGEPI = new GetElementPtrInst(
+              GetElementPtrInst *NGEPI = GetElementPtrInst::Create(
                   NCE, Idx, Idx + 2, 
                   GEPI->getName(), GEPI);
               SE->deleteValueFromRecords(GEPI);
@@ -200,8 +200,8 @@
         BasicBlock::iterator InsertPos = PN; ++InsertPos;
         while (isa<PHINode>(InsertPos)) ++InsertPos;
         Value *PreInc =
-          new GetElementPtrInst(PN->getIncomingValue(PreheaderIdx),
-                                NewPhi, "", InsertPos);
+          GetElementPtrInst::Create(PN->getIncomingValue(PreheaderIdx),
+                                    NewPhi, "", InsertPos);
         PreInc->takeName(PN);
         PN->replaceAllUsesWith(PreInc);
       }

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/InstructionCombining.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/InstructionCombining.cpp Wed Mar 26 06:50:41 2008
@@ -1764,8 +1764,8 @@
           }
           
           Instruction *New =
-            new InsertElementInst(UndefValue::get(II->getType()), TmpV, 0U,
-                                  II->getName());
+            InsertElementInst::Create(UndefValue::get(II->getType()), TmpV, 0U,
+                                      II->getName());
           InsertNewInstBefore(New, *II);
           AddSoonDeadInstToWorklist(*II, 0);
           return New;
@@ -1960,8 +1960,8 @@
     Value *SelectTrueVal = FoldOperationIntoSelectOperand(Op, TV, IC);
     Value *SelectFalseVal = FoldOperationIntoSelectOperand(Op, FV, IC);
 
-    return new SelectInst(SI->getCondition(), SelectTrueVal,
-                          SelectFalseVal);
+    return SelectInst::Create(SI->getCondition(), SelectTrueVal,
+                              SelectFalseVal);
   }
   return 0;
 }
@@ -2001,7 +2001,7 @@
   }
 
   // Okay, we can do the transformation: create the new PHI node.
-  PHINode *NewPN = new PHINode(I.getType(), "");
+  PHINode *NewPN = PHINode::Create(I.getType(), "");
   NewPN->reserveOperandSpace(PN->getNumOperands()/2);
   InsertNewInstBefore(NewPN, *PN);
   NewPN->takeName(PN);
@@ -2319,7 +2319,7 @@
         cast<PointerType>(CI->getOperand(0)->getType())->getAddressSpace();
       Value *I2 = InsertBitCastBefore(CI->getOperand(0),
                                       PointerType::get(Type::Int8Ty, AS), I);
-      I2 = InsertNewInstBefore(new GetElementPtrInst(I2, Other, "ctg2"), I);
+      I2 = InsertNewInstBefore(GetElementPtrInst::Create(I2, Other, "ctg2"), I);
       return new PtrToIntInst(I2, CI->getType());
     }
   }
@@ -2341,10 +2341,10 @@
       // We check both true and false select arguments for a matching subtract.
       if (match(FV, m_Zero()) && match(TV, m_Sub(m_Value(N), m_Value(A))) &&
           A == Other)  // Fold the add into the true select value.
-        return new SelectInst(SI->getCondition(), N, A);
+        return SelectInst::Create(SI->getCondition(), N, A);
       if (match(TV, m_Zero()) && match(FV, m_Sub(m_Value(N), m_Value(A))) && 
           A == Other)  // Fold the add into the false select value.
-        return new SelectInst(SI->getCondition(), A, N);
+        return SelectInst::Create(SI->getCondition(), A, N);
     }
   }
   
@@ -2828,7 +2828,7 @@
           FSI = InsertNewInstBefore(FSI, I);
 
           // construct the select instruction and return it.
-          return new SelectInst(SI->getOperand(0), TSI, FSI, SI->getName());
+          return SelectInst::Create(SI->getOperand(0), TSI, FSI, SI->getName());
         }
       }
   return 0;
@@ -3002,7 +3002,7 @@
             BinaryOperator::createAnd(Op0, SubOne(STO), SI->getName()+".t"), I);
           Value *FalseAnd = InsertNewInstBefore(
             BinaryOperator::createAnd(Op0, SubOne(SFO), SI->getName()+".f"), I);
-          return new SelectInst(SI->getOperand(0), TrueAnd, FalseAnd);
+          return SelectInst::Create(SI->getOperand(0), TrueAnd, FalseAnd);
         }
       }
   }
@@ -3974,7 +3974,7 @@
   const Type *Tys[] = { ITy };
   Module *M = I.getParent()->getParent()->getParent();
   Function *F = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1);
-  return new CallInst(F, V);
+  return CallInst::Create(F, V);
 }
 
 
@@ -4901,7 +4901,7 @@
         }
 
         if (Op1)
-          return new SelectInst(LHSI->getOperand(0), Op1, Op2);
+          return SelectInst::Create(LHSI->getOperand(0), Op1, Op2);
         break;
       }
   }
@@ -5201,7 +5201,7 @@
         }
 
         if (Op1)
-          return new SelectInst(LHSI->getOperand(0), Op1, Op2);
+          return SelectInst::Create(LHSI->getOperand(0), Op1, Op2);
         break;
       }
       case Instruction::Malloc:
@@ -6888,9 +6888,9 @@
             // If we were able to index down into an element, create the GEP
             // and bitcast the result.  This eliminates one bitcast, potentially
             // two.
-            Instruction *NGEP = new GetElementPtrInst(OrigBase, 
-                                                      NewIndices.begin(),
-                                                      NewIndices.end(), "");
+            Instruction *NGEP = GetElementPtrInst::Create(OrigBase, 
+                                                          NewIndices.begin(),
+                                                          NewIndices.end(), "");
             InsertNewInstBefore(NGEP, CI);
             NGEP->takeName(GEP);
             
@@ -7425,7 +7425,7 @@
       // If Offset is evenly divisible by Size, we can do this xform.
       if (Size && !APIntOps::srem(Offset, APInt(Offset.getBitWidth(), Size))){
         Offset = APIntOps::sdiv(Offset, APInt(Offset.getBitWidth(), Size));
-        return new GetElementPtrInst(X, ConstantInt::get(Offset));
+        return GetElementPtrInst::Create(X, ConstantInt::get(Offset));
       }
     }
     // TODO: Could handle other cases, e.g. where add is indexing into field of
@@ -7448,7 +7448,7 @@
       
       Instruction *P = InsertNewInstBefore(new IntToPtrInst(X, CI.getType(),
                                                             "tmp"), CI);
-      return new GetElementPtrInst(P, ConstantInt::get(Offset), "tmp");
+      return GetElementPtrInst::Create(P, ConstantInt::get(Offset), "tmp");
     }
   }
   return 0;
@@ -7504,8 +7504,8 @@
     // If we found a path from the src to dest, create the getelementptr now.
     if (SrcElTy == DstElTy) {
       SmallVector<Value*, 8> Idxs(NumZeros+1, ZeroUInt);
-      return new GetElementPtrInst(Src, Idxs.begin(), Idxs.end(), "", 
-                                   ((Instruction*) NULL));
+      return GetElementPtrInst::Create(Src, Idxs.begin(), Idxs.end(), "", 
+                                       ((Instruction*) NULL));
     }
   }
 
@@ -7602,8 +7602,8 @@
     }
 
     // Fold this by inserting a select from the input values.
-    SelectInst *NewSI = new SelectInst(SI.getCondition(), TI->getOperand(0),
-                                       FI->getOperand(0), SI.getName()+".v");
+    SelectInst *NewSI = SelectInst::Create(SI.getCondition(), TI->getOperand(0),
+                                           FI->getOperand(0), SI.getName()+".v");
     InsertNewInstBefore(NewSI, SI);
     return CastInst::create(Instruction::CastOps(TI->getOpcode()), NewSI, 
                             TI->getType());
@@ -7643,8 +7643,8 @@
   }
 
   // If we reach here, they do have operations in common.
-  SelectInst *NewSI = new SelectInst(SI.getCondition(), OtherOpT,
-                                     OtherOpF, SI.getName()+".v");
+  SelectInst *NewSI = SelectInst::Create(SI.getCondition(), OtherOpT,
+                                         OtherOpF, SI.getName()+".v");
   InsertNewInstBefore(NewSI, SI);
 
   if (BinaryOperator *BO = dyn_cast<BinaryOperator>(TI)) {
@@ -7893,7 +7893,7 @@
             if (AddOp != TI)
               std::swap(NewTrueOp, NewFalseOp);
             Instruction *NewSel =
-              new SelectInst(CondVal, NewTrueOp,NewFalseOp,SI.getName()+".p");
+              SelectInst::Create(CondVal, NewTrueOp,NewFalseOp,SI.getName()+".p");
 
             NewSel = InsertNewInstBefore(NewSel, SI);
             return BinaryOperator::createAdd(SubOp->getOperand(0), NewSel);
@@ -7919,7 +7919,7 @@
           if (OpToFold) {
             Constant *C = GetSelectFoldableConstant(TVI);
             Instruction *NewSel =
-              new SelectInst(SI.getCondition(), TVI->getOperand(2-OpToFold), C);
+              SelectInst::Create(SI.getCondition(), TVI->getOperand(2-OpToFold), C);
             InsertNewInstBefore(NewSel, SI);
             NewSel->takeName(TVI);
             if (BinaryOperator *BO = dyn_cast<BinaryOperator>(TVI))
@@ -7944,7 +7944,7 @@
           if (OpToFold) {
             Constant *C = GetSelectFoldableConstant(FVI);
             Instruction *NewSel =
-              new SelectInst(SI.getCondition(), C, FVI->getOperand(2-OpToFold));
+              SelectInst::Create(SI.getCondition(), C, FVI->getOperand(2-OpToFold));
             InsertNewInstBefore(NewSel, SI);
             NewSel->takeName(FVI);
             if (BinaryOperator *BO = dyn_cast<BinaryOperator>(FVI))
@@ -8272,7 +8272,7 @@
             }
           
             // Insert this value into the result vector.
-            Result = new InsertElementInst(Result, ExtractedElts[Idx], i,"tmp");
+            Result = InsertElementInst::Create(Result, ExtractedElts[Idx], i, "tmp");
             InsertNewInstBefore(cast<Instruction>(Result), CI);
           }
           return CastInst::create(Instruction::BitCast, Result, CI.getType());
@@ -8369,8 +8369,8 @@
 
     if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) {
       // Don't break the CFG, insert a dummy cond branch.
-      new BranchInst(II->getNormalDest(), II->getUnwindDest(),
-                     ConstantInt::getTrue(), II);
+      BranchInst::Create(II->getNormalDest(), II->getUnwindDest(),
+                         ConstantInt::getTrue(), II);
     }
     return EraseInstFromFunction(*CS.getInstruction());
   }
@@ -8581,13 +8581,13 @@
 
   Instruction *NC;
   if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
-    NC = new InvokeInst(Callee, II->getNormalDest(), II->getUnwindDest(),
-                        Args.begin(), Args.end(), Caller->getName(), Caller);
+    NC = InvokeInst::Create(Callee, II->getNormalDest(), II->getUnwindDest(),
+                            Args.begin(), Args.end(), Caller->getName(), Caller);
     cast<InvokeInst>(NC)->setCallingConv(II->getCallingConv());
     cast<InvokeInst>(NC)->setParamAttrs(NewCallerPAL);
   } else {
-    NC = new CallInst(Callee, Args.begin(), Args.end(),
-                      Caller->getName(), Caller);
+    NC = CallInst::Create(Callee, Args.begin(), Args.end(),
+                          Caller->getName(), Caller);
     CallInst *CI = cast<CallInst>(Caller);
     if (CI->isTailCall())
       cast<CallInst>(NC)->setTailCall();
@@ -8744,15 +8744,15 @@
 
       Instruction *NewCaller;
       if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
-        NewCaller = new InvokeInst(NewCallee,
-                                   II->getNormalDest(), II->getUnwindDest(),
-                                   NewArgs.begin(), NewArgs.end(),
-                                   Caller->getName(), Caller);
+        NewCaller = InvokeInst::Create(NewCallee,
+                                       II->getNormalDest(), II->getUnwindDest(),
+                                       NewArgs.begin(), NewArgs.end(),
+                                       Caller->getName(), Caller);
         cast<InvokeInst>(NewCaller)->setCallingConv(II->getCallingConv());
         cast<InvokeInst>(NewCaller)->setParamAttrs(NewPAL);
       } else {
-        NewCaller = new CallInst(NewCallee, NewArgs.begin(), NewArgs.end(),
-                                 Caller->getName(), Caller);
+        NewCaller = CallInst::Create(NewCallee, NewArgs.begin(), NewArgs.end(),
+                                     Caller->getName(), Caller);
         if (cast<CallInst>(Caller)->isTailCall())
           cast<CallInst>(NewCaller)->setTailCall();
         cast<CallInst>(NewCaller)->
@@ -8824,7 +8824,7 @@
   Value *InRHS = FirstInst->getOperand(1);
   PHINode *NewLHS = 0, *NewRHS = 0;
   if (LHSVal == 0) {
-    NewLHS = new PHINode(LHSType, FirstInst->getOperand(0)->getName()+".pn");
+    NewLHS = PHINode::Create(LHSType, FirstInst->getOperand(0)->getName()+".pn");
     NewLHS->reserveOperandSpace(PN.getNumOperands()/2);
     NewLHS->addIncoming(InLHS, PN.getIncomingBlock(0));
     InsertNewInstBefore(NewLHS, PN);
@@ -8832,7 +8832,7 @@
   }
   
   if (RHSVal == 0) {
-    NewRHS = new PHINode(RHSType, FirstInst->getOperand(1)->getName()+".pn");
+    NewRHS = PHINode::Create(RHSType, FirstInst->getOperand(1)->getName()+".pn");
     NewRHS->reserveOperandSpace(PN.getNumOperands()/2);
     NewRHS->addIncoming(InRHS, PN.getIncomingBlock(0));
     InsertNewInstBefore(NewRHS, PN);
@@ -8858,7 +8858,7 @@
                            RHSVal);
   else {
     assert(isa<GetElementPtrInst>(FirstInst));
-    return new GetElementPtrInst(LHSVal, RHSVal);
+    return GetElementPtrInst::Create(LHSVal, RHSVal);
   }
 }
 
@@ -8960,8 +8960,8 @@
 
   // Okay, they are all the same operation.  Create a new PHI node of the
   // correct type, and PHI together all of the LHS's of the instructions.
-  PHINode *NewPN = new PHINode(FirstInst->getOperand(0)->getType(),
-                               PN.getName()+".in");
+  PHINode *NewPN = PHINode::Create(FirstInst->getOperand(0)->getType(),
+                                   PN.getName()+".in");
   NewPN->reserveOperandSpace(PN.getNumOperands()/2);
 
   Value *InVal = FirstInst->getOperand(0);
@@ -9308,8 +9308,8 @@
     }
 
     if (!Indices.empty())
-      return new GetElementPtrInst(SrcGEPOperands[0], Indices.begin(),
-                                   Indices.end(), GEP.getName());
+      return GetElementPtrInst::Create(SrcGEPOperands[0], Indices.begin(),
+                                       Indices.end(), GEP.getName());
 
   } else if (GlobalValue *GV = dyn_cast<GlobalValue>(PtrOp)) {
     // GEP of global variable.  If all of the indices for this GEP are
@@ -9364,7 +9364,7 @@
         Idx[0] = Constant::getNullValue(Type::Int32Ty);
         Idx[1] = GEP.getOperand(1);
         Value *V = InsertNewInstBefore(
-               new GetElementPtrInst(X, Idx, Idx + 2, GEP.getName()), GEP);
+               GetElementPtrInst::Create(X, Idx, Idx + 2, GEP.getName()), GEP);
         // V and GEP are both pointer types --> BitCast
         return new BitCastInst(V, GEP.getType());
       }
@@ -9422,7 +9422,7 @@
           Idx[0] = Constant::getNullValue(Type::Int32Ty);
           Idx[1] = NewIdx;
           Instruction *NewGEP =
-            new GetElementPtrInst(X, Idx, Idx + 2, GEP.getName());
+            GetElementPtrInst::Create(X, Idx, Idx + 2, GEP.getName());
           NewGEP = InsertNewInstBefore(NewGEP, GEP);
           // The NewGEP must be pointer typed, so must the old one -> BitCast
           return new BitCastInst(NewGEP, GEP.getType());
@@ -9465,8 +9465,8 @@
       Value *Idx[2];
       Idx[0] = NullIdx;
       Idx[1] = NullIdx;
-      Value *V = new GetElementPtrInst(New, Idx, Idx + 2,
-                                       New->getName()+".sub", It);
+      Value *V = GetElementPtrInst::Create(New, Idx, Idx + 2,
+                                           New->getName()+".sub", It);
 
       // Now make everything use the getelementptr instead of the original
       // allocation.
@@ -9777,7 +9777,7 @@
                                      SI->getOperand(1)->getName()+".val"), LI);
         Value *V2 = InsertNewInstBefore(new LoadInst(SI->getOperand(2),
                                      SI->getOperand(2)->getName()+".val"), LI);
-        return new SelectInst(SI->getCondition(), V1, V2);
+        return SelectInst::Create(SI->getCondition(), V1, V2);
       }
 
       // load (select (cond, null, P)) -> load P
@@ -10054,7 +10054,7 @@
   // Insert a PHI node now if we need it.
   Value *MergedVal = OtherStore->getOperand(0);
   if (MergedVal != SI.getOperand(0)) {
-    PHINode *PN = new PHINode(MergedVal->getType(), "storemerge");
+    PHINode *PN = PHINode::Create(MergedVal->getType(), "storemerge");
     PN->reserveOperandSpace(2);
     PN->addIncoming(SI.getOperand(0), SI.getParent());
     PN->addIncoming(OtherStore->getOperand(0), OtherBB);
@@ -10340,7 +10340,7 @@
         Value *Ptr = InsertBitCastBefore(I->getOperand(0),
                                          PointerType::get(EI.getType(), AS),EI);
         GetElementPtrInst *GEP = 
-          new GetElementPtrInst(Ptr, EI.getOperand(1), I->getName() + ".gep");
+          GetElementPtrInst::Create(Ptr, EI.getOperand(1), I->getName() + ".gep");
         InsertNewInstBefore(GEP, EI);
         return new LoadInst(GEP);
       }

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopIndexSplit.cpp Wed Mar 26 06:50:41 2008
@@ -774,7 +774,7 @@
                                            "lsplit.add", PHTerminator);
       Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
                               A, UB,"lsplit,c", PHTerminator);
-      NUB = new SelectInst (C, A, UB, "lsplit.nub", PHTerminator);
+      NUB = SelectInst::Create(C, A, UB, "lsplit.nub", PHTerminator);
     }
     
     // for (i = LB; i <= UB; ++i)
@@ -790,7 +790,7 @@
              || ExitCondition->getPredicate() == ICmpInst::ICMP_ULE) {
       Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
                               NV, UB, "lsplit.c", PHTerminator);
-      NUB = new SelectInst (C, NV, UB, "lsplit.nub", PHTerminator);
+      NUB = SelectInst::Create(C, NV, UB, "lsplit.nub", PHTerminator);
     }
     break;
   case ICmpInst::ICMP_ULT:
@@ -808,7 +808,7 @@
         || ExitCondition->getPredicate() == ICmpInst::ICMP_ULT) {
       Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
                               NV, UB, "lsplit.c", PHTerminator);
-      NUB = new SelectInst (C, NV, UB, "lsplit.nub", PHTerminator);
+      NUB = SelectInst::Create(C, NV, UB, "lsplit.nub", PHTerminator);
     }
 
     // for (i = LB; i <= UB; ++i)
@@ -826,7 +826,7 @@
                                            "lsplit.add", PHTerminator);
       Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
                               S, UB, "lsplit.c", PHTerminator);
-      NUB = new SelectInst (C, S, UB, "lsplit.nub", PHTerminator);
+      NUB = SelectInst::Create(C, S, UB, "lsplit.nub", PHTerminator);
     }
     break;
   case ICmpInst::ICMP_UGE:
@@ -843,7 +843,7 @@
     {
       Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
                               NV, StartValue, "lsplit.c", PHTerminator);
-      NLB = new SelectInst (C, StartValue, NV, "lsplit.nlb", PHTerminator);
+      NLB = SelectInst::Create(C, StartValue, NV, "lsplit.nlb", PHTerminator);
     }
     break;
   case ICmpInst::ICMP_UGT:
@@ -862,7 +862,7 @@
                                            "lsplit.add", PHTerminator);
       Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
                               A, StartValue, "lsplit.c", PHTerminator);
-      NLB = new SelectInst (C, StartValue, A, "lsplit.nlb", PHTerminator);
+      NLB = SelectInst::Create(C, StartValue, A, "lsplit.nlb", PHTerminator);
     }
     break;
   default:
@@ -1358,16 +1358,16 @@
                            ExitCondition->getOperand(ExitValueNum), 
                            "lsplit.ev", InsertPt);
 
-  SD.A_ExitValue = new SelectInst(C1, AEV,
-                                  ExitCondition->getOperand(ExitValueNum), 
-                                  "lsplit.ev", InsertPt);
+  SD.A_ExitValue = SelectInst::Create(C1, AEV,
+                                      ExitCondition->getOperand(ExitValueNum), 
+                                      "lsplit.ev", InsertPt);
 
   Value *C2 = new ICmpInst(Sign ?
                            ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
                            BSV, StartValue, "lsplit.sv",
                            PHTerminator);
-  SD.B_StartValue = new SelectInst(C2, StartValue, BSV,
-                                   "lsplit.sv", PHTerminator);
+  SD.B_StartValue = SelectInst::Create(C2, StartValue, BSV,
+                                       "lsplit.sv", PHTerminator);
 }
 
 /// splitLoop - Split current loop L in two loops using split information
@@ -1510,7 +1510,7 @@
       BI != BE; ++BI) {
     if (PHINode *PN = dyn_cast<PHINode>(BI)) {
       Value *V1 = PN->getIncomingValueForBlock(A_ExitBlock);
-      PHINode *newPHI = new PHINode(PN->getType(), PN->getName());
+      PHINode *newPHI = PHINode::Create(PN->getType(), PN->getName());
       newPHI->addIncoming(V1, A_ExitingBlock);
       A_ExitBlock->getInstList().push_front(newPHI);
       PN->removeIncomingValue(A_ExitBlock);
@@ -1600,7 +1600,7 @@
   CurrentBR->eraseFromParent();
 
   // Connect exiting block to original destination.
-  new BranchInst(OrigDestBB, ExitingBB);
+  BranchInst::Create(OrigDestBB, ExitingBB);
 
   // Update PHINodes
   updatePHINodes(ExitBB, ExitingBB, CondBB, IV, IVAdd, LP);

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopRotation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopRotation.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopRotation.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopRotation.cpp Wed Mar 26 06:50:41 2008
@@ -208,7 +208,7 @@
     // Create new PHI node with two incoming values for NewHeader.
     // One incoming value is from OrigLatch (through OrigHeader) and 
     // second incoming value is from original pre-header.
-    PHINode *NH = new PHINode(In->getType(), In->getName());
+    PHINode *NH = PHINode::Create(In->getType(), In->getName());
     NH->addIncoming(PN->getIncomingValueForBlock(OrigLatch), OrigHeader);
     NH->addIncoming(NPV, OrigPreHeader);
     NewHeader->getInstList().push_front(NH);
@@ -249,7 +249,7 @@
     // create new PHINode for this instruction.
     Instruction *NewHeaderReplacement = NULL;
     if (usedOutsideOriginalHeader(In)) {
-      PHINode *PN = new PHINode(In->getType(), In->getName());
+      PHINode *PN = PHINode::Create(In->getType(), In->getName());
       PN->addIncoming(In, OrigHeader);
       PN->addIncoming(C, OrigPreHeader);
       NewHeader->getInstList().push_front(PN);
@@ -336,7 +336,7 @@
       } else {
         // Used outside Exit block. Create a new PHI node from exit block
         // to receive value from ne new header ane pre header.
-        PHINode *PN = new PHINode(U->getType(), U->getName());
+        PHINode *PN = PHINode::Create(U->getType(), U->getName());
         PN->addIncoming(ILoopHeaderInfo.PreHeader, OrigPreHeader);
         PN->addIncoming(OldPhi, OrigHeader);
         Exit->getInstList().push_front(PN);
@@ -447,12 +447,12 @@
   // Right now original pre-header has two successors, new header and
   // exit block. Insert new block between original pre-header and
   // new header such that loop's new pre-header has only one successor.
-  BasicBlock *NewPreHeader = new BasicBlock("bb.nph", OrigHeader->getParent(), 
-                                NewHeader);
+  BasicBlock *NewPreHeader = BasicBlock::Create("bb.nph", OrigHeader->getParent(), 
+                                                NewHeader);
   LoopInfo &LI = LPM.getAnalysis<LoopInfo>();
   if (Loop *PL = LI.getLoopFor(OrigPreHeader))
     PL->addBasicBlockToLoop(NewPreHeader, LI.getBase());
-  new BranchInst(NewHeader, NewPreHeader);
+  BranchInst::Create(NewHeader, NewPreHeader);
   
   BranchInst *OrigPH_BI = cast<BranchInst>(OrigPreHeader->getTerminator());
   if (OrigPH_BI->getSuccessor(0) == NewHeader)
@@ -560,7 +560,7 @@
   BasicBlock::iterator I = Exit->begin(), E = Exit->end();
   PHINode *PN = NULL;
   for (; (PN = dyn_cast<PHINode>(I)); ++I) {
-    PHINode *NewPN = new PHINode(PN->getType(), PN->getName());
+    PHINode *NewPN = PHINode::Create(PN->getType(), PN->getName());
     unsigned N = PN->getNumIncomingValues();
     for (unsigned index = 0; index < N; ++index)
       if (PN->getIncomingBlock(index) == NExit) {

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopStrengthReduce.cpp Wed Mar 26 06:50:41 2008
@@ -1271,7 +1271,7 @@
 
   if (RewriteFactor == 0) {
     // Create a new Phi for this base, and stick it in the loop header.
-    NewPHI = new PHINode(ReplacedTy, "iv.", PhiInsertBefore);
+    NewPHI = PHINode::Create(ReplacedTy, "iv.", PhiInsertBefore);
     ++NumInserted;
   
     // Add common base to the new Phi node.

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/LoopUnswitch.cpp Wed Mar 26 06:50:41 2008
@@ -568,7 +568,7 @@
     std::swap(TrueDest, FalseDest);
 
   // Insert the new branch.
-  new BranchInst(TrueDest, FalseDest, BranchVal, InsertPt);
+  BranchInst::Create(TrueDest, FalseDest, BranchVal, InsertPt);
 
 }
 
@@ -673,9 +673,9 @@
       for (BasicBlock::iterator I = EndBlock->begin();
            (OldLCSSA = dyn_cast<PHINode>(I)); ++I) {
         Value* OldValue = OldLCSSA->getIncomingValueForBlock(MiddleBlock);
-        PHINode* NewLCSSA = new PHINode(OldLCSSA->getType(),
-                                        OldLCSSA->getName() + ".us-lcssa",
-                                        MiddleBlock->getTerminator());
+        PHINode* NewLCSSA = PHINode::Create(OldLCSSA->getType(),
+                                            OldLCSSA->getName() + ".us-lcssa",
+                                            MiddleBlock->getTerminator());
         NewLCSSA->addIncoming(OldValue, StartBlock);
         OldLCSSA->setIncomingValue(OldLCSSA->getBasicBlockIndex(MiddleBlock),
                                    NewLCSSA);
@@ -687,9 +687,9 @@
       for (BasicBlock::iterator I = MiddleBlock->begin();
          (OldLCSSA = dyn_cast<PHINode>(I)) && InsertedPHIs.count(OldLCSSA) == 0;
          ++I) {
-        PHINode *NewLCSSA = new PHINode(OldLCSSA->getType(),
-                                        OldLCSSA->getName() + ".us-lcssa",
-                                        InsertPt);
+        PHINode *NewLCSSA = PHINode::Create(OldLCSSA->getType(),
+                                            OldLCSSA->getName() + ".us-lcssa",
+                                            InsertPt);
         OldLCSSA->replaceAllUsesWith(NewLCSSA);
         NewLCSSA->addIncoming(OldLCSSA, MiddleBlock);
       }
@@ -1155,8 +1155,8 @@
               BasicBlock* Split = SplitBlock(Old, SI, this);
               
               Instruction* OldTerm = Old->getTerminator();
-              new BranchInst(Split, SI->getSuccessor(i),
-                             ConstantInt::getTrue(), OldTerm);
+              BranchInst::Create(Split, SI->getSuccessor(i),
+                                 ConstantInt::getTrue(), OldTerm);
 
               LPM->deleteSimpleAnalysisValue(Old->getTerminator(), L);                
               Old->getTerminator()->eraseFromParent();
@@ -1295,7 +1295,7 @@
         BasicBlock *DeadSucc = BI->getSuccessor(CB->getZExtValue());
         BasicBlock *LiveSucc = BI->getSuccessor(!CB->getZExtValue());
         DeadSucc->removePredecessor(BI->getParent(), true);
-        Worklist.push_back(new BranchInst(LiveSucc, BI));
+        Worklist.push_back(BranchInst::Create(LiveSucc, BI));
         LPM->deleteSimpleAnalysisValue(BI, L);
         BI->eraseFromParent();
         RemoveFromWorklist(BI, Worklist);

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/SCCP.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/SCCP.cpp Wed Mar 26 06:50:41 2008
@@ -1739,7 +1739,7 @@
           
           // Make this an uncond branch to the first successor.
           TerminatorInst *TI = I->getParent()->getTerminator();
-          new BranchInst(TI->getSuccessor(0), TI);
+          BranchInst::Create(TI->getSuccessor(0), TI);
           
           // Remove entries in successor phi nodes to remove edges.
           for (unsigned i = 1, e = TI->getNumSuccessors(); i != e; ++i)

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/ScalarReplAggregates.cpp Wed Mar 26 06:50:41 2008
@@ -323,8 +323,8 @@
       SmallVector<Value*, 8> NewArgs;
       NewArgs.push_back(Constant::getNullValue(Type::Int32Ty));
       NewArgs.append(GEPI->op_begin()+3, GEPI->op_end());
-      RepValue = new GetElementPtrInst(AllocaToUse, NewArgs.begin(),
-                                       NewArgs.end(), "", GEPI);
+      RepValue = GetElementPtrInst::Create(AllocaToUse, NewArgs.begin(),
+                                           NewArgs.end(), "", GEPI);
       RepValue->takeName(GEPI);
     }
     
@@ -634,9 +634,9 @@
         Value *Idx[2];
         Idx[0] = Zero;
         Idx[1] = ConstantInt::get(Type::Int32Ty, i);
-        OtherElt = new GetElementPtrInst(OtherPtr, Idx, Idx + 2,
-                                         OtherPtr->getNameStr()+"."+utostr(i),
-                                         MI);
+        OtherElt = GetElementPtrInst::Create(OtherPtr, Idx, Idx + 2,
+                                             OtherPtr->getNameStr()+"."+utostr(i),
+                                             MI);
       }
 
       Value *EltPtr = NewElts[i];
@@ -716,7 +716,7 @@
           ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size
           Zero  // Align
         };
-        new CallInst(TheFn, Ops, Ops + 4, "", MI);
+        CallInst::Create(TheFn, Ops, Ops + 4, "", MI);
       } else {
         assert(isa<MemSetInst>(MI));
         Value *Ops[] = {
@@ -724,7 +724,7 @@
           ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size
           Zero  // Align
         };
-        new CallInst(TheFn, Ops, Ops + 4, "", MI);
+        CallInst::Create(TheFn, Ops, Ops + 4, "", MI);
       }
     }
 
@@ -838,22 +838,22 @@
           // Insert the new GEP instructions, which are properly indexed.
           SmallVector<Value*, 8> Indices(GEPI->op_begin()+1, GEPI->op_end());
           Indices[1] = Constant::getNullValue(Type::Int32Ty);
-          Value *ZeroIdx = new GetElementPtrInst(GEPI->getOperand(0),
-                                                 Indices.begin(),
-                                                 Indices.end(),
-                                                 GEPI->getName()+".0", GEPI);
+          Value *ZeroIdx = GetElementPtrInst::Create(GEPI->getOperand(0),
+                                                     Indices.begin(),
+                                                     Indices.end(),
+                                                     GEPI->getName()+".0", GEPI);
           Indices[1] = ConstantInt::get(Type::Int32Ty, 1);
-          Value *OneIdx = new GetElementPtrInst(GEPI->getOperand(0),
-                                                Indices.begin(),
-                                                Indices.end(),
-                                                GEPI->getName()+".1", GEPI);
+          Value *OneIdx = GetElementPtrInst::Create(GEPI->getOperand(0),
+                                                    Indices.begin(),
+                                                    Indices.end(),
+                                                    GEPI->getName()+".1", GEPI);
           // Replace all loads of the variable index GEP with loads from both
           // indexes and a select.
           while (!GEPI->use_empty()) {
             LoadInst *LI = cast<LoadInst>(GEPI->use_back());
             Value *Zero = new LoadInst(ZeroIdx, LI->getName()+".0", LI);
             Value *One  = new LoadInst(OneIdx , LI->getName()+".1", LI);
-            Value *R = new SelectInst(IsOne, One, Zero, LI->getName(), LI);
+            Value *R = SelectInst::Create(IsOne, One, Zero, LI->getName(), LI);
             LI->replaceAllUsesWith(R);
             LI->eraseFromParent();
           }
@@ -1261,9 +1261,9 @@
       // Must be an element insertion.
       const TargetData &TD = getAnalysis<TargetData>();
       unsigned Elt = Offset/TD.getABITypeSizeInBits(PTy->getElementType());
-      SV = new InsertElementInst(Old, SV,
-                                 ConstantInt::get(Type::Int32Ty, Elt),
-                                 "tmp", SI);
+      SV = InsertElementInst::Create(Old, SV,
+                                     ConstantInt::get(Type::Int32Ty, Elt),
+                                     "tmp", SI);
     }
   } else if (isa<PointerType>(AllocaType)) {
     // If the alloca type is a pointer, then all the elements must be

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/SimplifyCFG.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/SimplifyCFG.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/SimplifyCFG.cpp Wed Mar 26 06:50:41 2008
@@ -78,15 +78,15 @@
 static void ChangeToCall(InvokeInst *II) {
   BasicBlock *BB = II->getParent();
   SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
-  CallInst *NewCall = new CallInst(II->getCalledValue(), Args.begin(),
-                                   Args.end(), "", II);
+  CallInst *NewCall = CallInst::Create(II->getCalledValue(), Args.begin(),
+                                       Args.end(), "", II);
   NewCall->takeName(II);
   NewCall->setCallingConv(II->getCallingConv());
   NewCall->setParamAttrs(II->getParamAttrs());
   II->replaceAllUsesWith(NewCall);
 
   // Follow the call by a branch to the normal destination.
-  new BranchInst(II->getNormalDest(), II);
+  BranchInst::Create(II->getNormalDest(), II);
 
   // Update PHI nodes in the unwind destination
   II->getUnwindDest()->removePredecessor(BB);

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/TailRecursionElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/TailRecursionElimination.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Scalar/TailRecursionElimination.cpp Wed Mar 26 06:50:41 2008
@@ -377,10 +377,10 @@
   // create the new entry block, allowing us to branch back to the old entry.
   if (OldEntry == 0) {
     OldEntry = &F->getEntryBlock();
-    BasicBlock *NewEntry = new BasicBlock("", F, OldEntry);
+    BasicBlock *NewEntry = BasicBlock::Create("", F, OldEntry);
     NewEntry->takeName(OldEntry);
     OldEntry->setName("tailrecurse");
-    new BranchInst(OldEntry, NewEntry);
+    BranchInst::Create(OldEntry, NewEntry);
 
     // If this tail call is marked 'tail' and if there are any allocas in the
     // entry block, move them up to the new entry block.
@@ -400,7 +400,7 @@
     Instruction *InsertPos = OldEntry->begin();
     for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end();
          I != E; ++I) {
-      PHINode *PN = new PHINode(I->getType(), I->getName()+".tr", InsertPos);
+      PHINode *PN = PHINode::Create(I->getType(), I->getName()+".tr", InsertPos);
       I->replaceAllUsesWith(PN); // Everyone use the PHI node now!
       PN->addIncoming(I, NewEntry);
       ArgumentPHIs.push_back(PN);
@@ -430,8 +430,8 @@
   if (AccumulatorRecursionEliminationInitVal) {
     Instruction *AccRecInstr = AccumulatorRecursionInstr;
     // Start by inserting a new PHI node for the accumulator.
-    PHINode *AccPN = new PHINode(AccRecInstr->getType(), "accumulator.tr",
-                                 OldEntry->begin());
+    PHINode *AccPN = PHINode::Create(AccRecInstr->getType(), "accumulator.tr",
+                                     OldEntry->begin());
 
     // Loop over all of the predecessors of the tail recursion block.  For the
     // real entry into the function we seed the PHI with the initial value,
@@ -467,7 +467,7 @@
 
   // Now that all of the PHI nodes are in place, remove the call and
   // ret instructions, replacing them with an unconditional branch.
-  new BranchInst(OldEntry, Ret);
+  BranchInst::Create(OldEntry, Ret);
   BB->getInstList().erase(Ret);  // Remove return.
   BB->getInstList().erase(CI);   // Remove call.
   ++NumEliminated;

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/BasicBlockUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/BasicBlockUtils.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/BasicBlockUtils.cpp Wed Mar 26 06:50:41 2008
@@ -98,7 +98,7 @@
         RetVal = Constant::getNullValue(BB->getParent()->getReturnType());
 
       // Create the return...
-      NewTI = new ReturnInst(RetVal);
+      NewTI = ReturnInst::Create(RetVal);
     }
     break;
 

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/BreakCriticalEdges.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/BreakCriticalEdges.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/BreakCriticalEdges.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/BreakCriticalEdges.cpp Wed Mar 26 06:50:41 2008
@@ -122,10 +122,10 @@
   BasicBlock *DestBB = TI->getSuccessor(SuccNum);
 
   // Create a new basic block, linking it into the CFG.
-  BasicBlock *NewBB = new BasicBlock(TIBB->getName() + "." +
-                                     DestBB->getName() + "_crit_edge");
+  BasicBlock *NewBB = BasicBlock::Create(TIBB->getName() + "." +
+                                         DestBB->getName() + "_crit_edge");
   // Create our unconditional branch...
-  new BranchInst(DestBB, NewBB);
+  BranchInst::Create(DestBB, NewBB);
 
   // Branch to the new block, breaking the edge.
   TI->setSuccessor(SuccNum, NewBB);

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneFunction.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneFunction.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneFunction.cpp Wed Mar 26 06:50:41 2008
@@ -31,7 +31,7 @@
                                   DenseMap<const Value*, Value*> &ValueMap,
                                   const char *NameSuffix, Function *F,
                                   ClonedCodeInfo *CodeInfo) {
-  BasicBlock *NewBB = new BasicBlock("", F);
+  BasicBlock *NewBB = BasicBlock::Create("", F);
   if (BB->hasName()) NewBB->setName(BB->getName()+NameSuffix);
   NewBB->setUnwindDest(const_cast<BasicBlock*>(BB->getUnwindDest()));
 
@@ -141,7 +141,7 @@
                                     ArgTypes, F->getFunctionType()->isVarArg());
 
   // Create the new function...
-  Function *NewF = new Function(FTy, F->getLinkage(), F->getName());
+  Function *NewF = Function::Create(FTy, F->getLinkage(), F->getName());
 
   // Loop over the arguments, copying the names of the mapped arguments over...
   Function::arg_iterator DestI = NewF->arg_begin();
@@ -205,7 +205,7 @@
   
   // Nope, clone it now.
   BasicBlock *NewBB;
-  BBEntry = NewBB = new BasicBlock();
+  BBEntry = NewBB = BasicBlock::Create();
   if (BB->hasName()) NewBB->setName(BB->getName()+NameSuffix);
 
   bool hasCalls = false, hasDynamicAllocas = false, hasStaticAllocas = false;
@@ -250,7 +250,7 @@
       // Constant fold to uncond branch!
       if (Cond) {
         BasicBlock *Dest = BI->getSuccessor(!Cond->getZExtValue());
-        ValueMap[OldTI] = new BranchInst(Dest, NewBB);
+        ValueMap[OldTI] = BranchInst::Create(Dest, NewBB);
         ToClone.push_back(Dest);
         TerminatorDone = true;
       }
@@ -262,7 +262,7 @@
       Cond = dyn_cast_or_null<ConstantInt>(ValueMap[SI->getCondition()]);
     if (Cond) {     // Constant fold to uncond branch!
       BasicBlock *Dest = SI->getSuccessor(SI->findCaseValue(Cond));
-      ValueMap[OldTI] = new BranchInst(Dest, NewBB);
+      ValueMap[OldTI] = BranchInst::Create(Dest, NewBB);
       ToClone.push_back(Dest);
       TerminatorDone = true;
     }

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneModule.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneModule.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneModule.cpp Wed Mar 26 06:50:41 2008
@@ -63,8 +63,8 @@
   // Loop over the functions in the module, making external functions as before
   for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) {
     Function *NF =
-      new Function(cast<FunctionType>(I->getType()->getElementType()),
-                   GlobalValue::ExternalLinkage, I->getName(), New);
+      Function::Create(cast<FunctionType>(I->getType()->getElementType()),
+                       GlobalValue::ExternalLinkage, I->getName(), New);
     NF->setCallingConv(I->getCallingConv());
     NF->setParamAttrs(I->getParamAttrs());
     if (I->hasCollector())

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CodeExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CodeExtractor.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CodeExtractor.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CodeExtractor.cpp Wed Mar 26 06:50:41 2008
@@ -161,8 +161,8 @@
       PHINode *PN = cast<PHINode>(AfterPHIs);
       // Create a new PHI node in the new region, which has an incoming value
       // from OldPred of PN.
-      PHINode *NewPN = new PHINode(PN->getType(), PN->getName()+".ce",
-                                   NewBB->begin());
+      PHINode *NewPN = PHINode::Create(PN->getType(), PN->getName()+".ce",
+                                       NewBB->begin());
       NewPN->addIncoming(PN, OldPred);
 
       // Loop over all of the incoming value in PN, moving them to NewPN if they
@@ -280,10 +280,10 @@
   const FunctionType *funcType = FunctionType::get(RetTy, paramTy, false);
 
   // Create the new function
-  Function *newFunction = new Function(funcType,
-                                       GlobalValue::InternalLinkage,
-                                       oldFunction->getName() + "_" +
-                                       header->getName(), M);
+  Function *newFunction = Function::Create(funcType,
+                                           GlobalValue::InternalLinkage,
+                                           oldFunction->getName() + "_" +
+                                           header->getName(), M);
   newFunction->getBasicBlockList().push_back(newRootNode);
 
   // Create an iterator to name all of the arguments we inserted.
@@ -299,8 +299,8 @@
       Idx[1] = ConstantInt::get(Type::Int32Ty, i);
       std::string GEPname = "gep_" + inputs[i]->getName();
       TerminatorInst *TI = newFunction->begin()->getTerminator();
-      GetElementPtrInst *GEP = new GetElementPtrInst(AI, Idx, Idx+2, 
-                                                     GEPname, TI);
+      GetElementPtrInst *GEP = GetElementPtrInst::Create(AI, Idx, Idx+2, 
+                                                         GEPname, TI);
       RewriteVal = new LoadInst(GEP, "load" + GEPname, TI);
     } else
       RewriteVal = AI++;
@@ -386,8 +386,8 @@
       Idx[0] = Constant::getNullValue(Type::Int32Ty);
       Idx[1] = ConstantInt::get(Type::Int32Ty, i);
       GetElementPtrInst *GEP =
-        new GetElementPtrInst(Struct, Idx, Idx + 2,
-                              "gep_" + StructValues[i]->getName());
+        GetElementPtrInst::Create(Struct, Idx, Idx + 2,
+                                  "gep_" + StructValues[i]->getName());
       codeReplacer->getInstList().push_back(GEP);
       StoreInst *SI = new StoreInst(StructValues[i], GEP);
       codeReplacer->getInstList().push_back(SI);
@@ -395,8 +395,8 @@
   }
 
   // Emit the call to the function
-  CallInst *call = new CallInst(newFunction, params.begin(), params.end(),
-                                NumExitBlocks > 1 ? "targetBlock" : "");
+  CallInst *call = CallInst::Create(newFunction, params.begin(), params.end(),
+                                    NumExitBlocks > 1 ? "targetBlock" : "");
   codeReplacer->getInstList().push_back(call);
 
   Function::arg_iterator OutputArgBegin = newFunction->arg_begin();
@@ -412,8 +412,8 @@
       Idx[0] = Constant::getNullValue(Type::Int32Ty);
       Idx[1] = ConstantInt::get(Type::Int32Ty, FirstOut + i);
       GetElementPtrInst *GEP
-        = new GetElementPtrInst(Struct, Idx, Idx + 2,
-                                "gep_reload_" + outputs[i]->getName());
+        = GetElementPtrInst::Create(Struct, Idx, Idx + 2,
+                                    "gep_reload_" + outputs[i]->getName());
       codeReplacer->getInstList().push_back(GEP);
       Output = GEP;
     } else {
@@ -431,8 +431,8 @@
 
   // Now we can emit a switch statement using the call as a value.
   SwitchInst *TheSwitch =
-    new SwitchInst(ConstantInt::getNullValue(Type::Int16Ty),
-                   codeReplacer, 0, codeReplacer);
+      SwitchInst::Create(ConstantInt::getNullValue(Type::Int16Ty),
+                         codeReplacer, 0, codeReplacer);
 
   // Since there may be multiple exits from the original region, make the new
   // function return an unsigned, switch on that number.  This loop iterates
@@ -453,8 +453,8 @@
         if (!NewTarget) {
           // If we don't already have an exit stub for this non-extracted
           // destination, create one now!
-          NewTarget = new BasicBlock(OldTarget->getName() + ".exitStub",
-                                     newFunction);
+          NewTarget = BasicBlock::Create(OldTarget->getName() + ".exitStub",
+                                         newFunction);
           unsigned SuccNum = switchVal++;
 
           Value *brVal = 0;
@@ -469,7 +469,7 @@
             break;
           }
 
-          ReturnInst *NTRet = new ReturnInst(brVal, NewTarget);
+          ReturnInst *NTRet = ReturnInst::Create(brVal, NewTarget);
 
           // Update the switch instruction.
           TheSwitch->addCase(ConstantInt::get(Type::Int16Ty, SuccNum),
@@ -513,9 +513,9 @@
                 Idx[0] = Constant::getNullValue(Type::Int32Ty);
                 Idx[1] = ConstantInt::get(Type::Int32Ty,FirstOut+out);
                 GetElementPtrInst *GEP =
-                  new GetElementPtrInst(OAI, Idx, Idx + 2,
-                                        "gep_" + outputs[out]->getName(),
-                                        NTRet);
+                  GetElementPtrInst::Create(OAI, Idx, Idx + 2,
+                                            "gep_" + outputs[out]->getName(),
+                                            NTRet);
                 new StoreInst(outputs[out], GEP, NTRet);
               } else {
                 new StoreInst(outputs[out], OAI, NTRet);
@@ -541,14 +541,14 @@
 
     // Check if the function should return a value
     if (OldFnRetTy == Type::VoidTy) {
-      new ReturnInst(0, TheSwitch);  // Return void
+      ReturnInst::Create(0, TheSwitch);  // Return void
     } else if (OldFnRetTy == TheSwitch->getCondition()->getType()) {
       // return what we have
-      new ReturnInst(TheSwitch->getCondition(), TheSwitch);
+      ReturnInst::Create(TheSwitch->getCondition(), TheSwitch);
     } else {
       // Otherwise we must have code extracted an unwind or something, just
       // return whatever we want.
-      new ReturnInst(Constant::getNullValue(OldFnRetTy), TheSwitch);
+      ReturnInst::Create(Constant::getNullValue(OldFnRetTy), TheSwitch);
     }
 
     TheSwitch->getParent()->getInstList().erase(TheSwitch);
@@ -556,12 +556,12 @@
   case 1:
     // Only a single destination, change the switch into an unconditional
     // branch.
-    new BranchInst(TheSwitch->getSuccessor(1), TheSwitch);
+    BranchInst::Create(TheSwitch->getSuccessor(1), TheSwitch);
     TheSwitch->getParent()->getInstList().erase(TheSwitch);
     break;
   case 2:
-    new BranchInst(TheSwitch->getSuccessor(1), TheSwitch->getSuccessor(2),
-                   call, TheSwitch);
+    BranchInst::Create(TheSwitch->getSuccessor(1), TheSwitch->getSuccessor(2),
+                       call, TheSwitch);
     TheSwitch->getParent()->getInstList().erase(TheSwitch);
     break;
   default:
@@ -641,12 +641,12 @@
   Function *oldFunction = header->getParent();
 
   // This takes place of the original loop
-  BasicBlock *codeReplacer = new BasicBlock("codeRepl", oldFunction, header);
+  BasicBlock *codeReplacer = BasicBlock::Create("codeRepl", oldFunction, header);
 
   // The new function needs a root node because other nodes can branch to the
   // head of the region, but the entry node of a function cannot have preds.
-  BasicBlock *newFuncRoot = new BasicBlock("newFuncRoot");
-  newFuncRoot->getInstList().push_back(new BranchInst(header));
+  BasicBlock *newFuncRoot = BasicBlock::Create("newFuncRoot");
+  newFuncRoot->getInstList().push_back(BranchInst::Create(header));
 
   // Find inputs to, outputs from the code region.
   findInputsOutputs(inputs, outputs);

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/InlineFunction.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/InlineFunction.cpp Wed Mar 26 06:50:41 2008
@@ -84,9 +84,9 @@
           // of the old basic block.
           SmallVector<Value*, 8> InvokeArgs(CI->op_begin()+1, CI->op_end());
           InvokeInst *II =
-            new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
-                           InvokeArgs.begin(), InvokeArgs.end(),
-                           CI->getName(), BB->getTerminator());
+            InvokeInst::Create(CI->getCalledValue(), Split, InvokeDest,
+                               InvokeArgs.begin(), InvokeArgs.end(),
+                               CI->getName(), BB->getTerminator());
           II->setCallingConv(CI->getCallingConv());
           II->setParamAttrs(CI->getParamAttrs());
           
@@ -116,7 +116,7 @@
         // invoke site.  Once this happens, we know that the unwind would cause
         // a control transfer to the invoke exception destination, so we can
         // transform it into a direct branch to the exception destination.
-        new BranchInst(InvokeDest, UI);
+        BranchInst::Create(InvokeDest, UI);
         
         // Delete the unwind instruction!
         UI->getParent()->getInstList().pop_back();
@@ -275,7 +275,7 @@
           DestCast, SrcCast, Size, ConstantInt::get(Type::Int32Ty, 1)
         };
         CallInst *TheMemCpy =
-          new CallInst(MemCpyFn, CallArgs, CallArgs+4, "", TheCall);
+          CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall);
         
         // If we have a call graph, update it.
         if (CG) {
@@ -366,14 +366,14 @@
     }
       
     // Insert the llvm.stacksave.
-    CallInst *SavedPtr = new CallInst(StackSave, "savedstack", 
-                                      FirstNewBlock->begin());
+    CallInst *SavedPtr = CallInst::Create(StackSave, "savedstack", 
+                                          FirstNewBlock->begin());
     if (CG) CallerNode->addCalledFunction(SavedPtr, StackSaveCGN);
       
     // Insert a call to llvm.stackrestore before any return instructions in the
     // inlined function.
     for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
-      CallInst *CI = new CallInst(StackRestore, SavedPtr, "", Returns[i]);
+      CallInst *CI = CallInst::Create(StackRestore, SavedPtr, "", Returns[i]);
       if (CG) CallerNode->addCalledFunction(CI, StackRestoreCGN);
     }
 
@@ -386,7 +386,7 @@
       for (Function::iterator BB = FirstNewBlock, E = Caller->end();
            BB != E; ++BB)
         if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->getTerminator())) {
-          new CallInst(StackRestore, SavedPtr, "", UI);
+          CallInst::Create(StackRestore, SavedPtr, "", UI);
           ++NumStackRestores;
         }
     }
@@ -428,7 +428,7 @@
          BB != E; ++BB) {
       TerminatorInst *Term = BB->getTerminator();
       if (isa<UnwindInst>(Term)) {
-        new BranchInst(UnwindBB, Term);
+        BranchInst::Create(UnwindBB, Term);
         BB->getInstList().erase(Term);
       }
     }
@@ -452,7 +452,7 @@
     // If the call site was an invoke instruction, add a branch to the normal
     // destination.
     if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall))
-      new BranchInst(II->getNormalDest(), TheCall);
+      BranchInst::Create(II->getNormalDest(), TheCall);
 
     // If the return instruction returned a value, replace uses of the call with
     // uses of the returned value.
@@ -489,7 +489,7 @@
   if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
 
     // Add an unconditional branch to make this look like the CallInst case...
-    BranchInst *NewBr = new BranchInst(II->getNormalDest(), TheCall);
+    BranchInst *NewBr = BranchInst::Create(II->getNormalDest(), TheCall);
 
     // Split the basic block.  This guarantees that no PHI nodes will have to be
     // updated due to new incoming edges, and make the invoke case more
@@ -535,9 +535,9 @@
         // match corresponding return value operand number.
         Instruction *InsertPt = AfterCallBB->begin();
         for (unsigned i = 0; i < NumRetVals; ++i) {
-          PHINode *PHI = new PHINode(STy->getElementType(i),
-                                     TheCall->getName() + "." + utostr(i), 
-                                     InsertPt);
+            PHINode *PHI = PHINode::Create(STy->getElementType(i),
+                                           TheCall->getName() + "." + utostr(i), 
+                                           InsertPt);
           PHIs.push_back(PHI);
         }
         // TheCall results are used by GetResult instructions. 
@@ -547,7 +547,7 @@
           GR->eraseFromParent();
         }
       } else {
-        PHINode *PHI = new PHINode(RTy, TheCall->getName(), AfterCallBB->begin());
+        PHINode *PHI = PHINode::Create(RTy, TheCall->getName(), AfterCallBB->begin());
         PHIs.push_back(PHI);
         // Anything that used the result of the function call should now use the
         // PHI node as their operand.
@@ -578,7 +578,7 @@
     // Add a branch to the merge points and remove retrun instructions.
     for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
       ReturnInst *RI = Returns[i];
-      new BranchInst(AfterCallBB, RI);
+      BranchInst::Create(AfterCallBB, RI);
       RI->eraseFromParent();
     }
   } else if (!Returns.empty()) {

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LCSSA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LCSSA.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LCSSA.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LCSSA.cpp Wed Mar 26 06:50:41 2008
@@ -155,8 +155,8 @@
     DomTreeNode *ExitBBNode = DT->getNode(BB);
     Value *&Phi = Phis[ExitBBNode];
     if (!Phi && DT->dominates(InstrNode, ExitBBNode)) {
-      PHINode *PN = new PHINode(Instr->getType(), Instr->getName()+".lcssa",
-                                BB->begin());
+      PHINode *PN = PHINode::Create(Instr->getType(), Instr->getName()+".lcssa",
+                                    BB->begin());
       PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));
 
       // Remember that this phi makes the value alive in this block.
@@ -259,8 +259,8 @@
   
   // Otherwise, the idom is the loop, so we need to insert a PHI node.  Do so
   // now, then get values to fill in the incoming values for the PHI.
-  PHINode *PN = new PHINode(OrigInst->getType(), OrigInst->getName()+".lcssa",
-                            BBN->begin());
+  PHINode *PN = PHINode::Create(OrigInst->getType(), OrigInst->getName()+".lcssa",
+                                BBN->begin());
   PN->reserveOperandSpace(std::distance(pred_begin(BBN), pred_end(BBN)));
   V = PN;
                                  

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/Local.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/Local.cpp Wed Mar 26 06:50:41 2008
@@ -134,7 +134,7 @@
     // now.
     if (TheOnlyDest) {
       // Insert the new branch..
-      new BranchInst(TheOnlyDest, SI);
+      BranchInst::Create(TheOnlyDest, SI);
       BasicBlock *BB = SI->getParent();
 
       // Remove entries from PHI nodes which we no longer branch to...
@@ -156,7 +156,7 @@
       Value *Cond = new ICmpInst(ICmpInst::ICMP_EQ, SI->getCondition(),
                                  SI->getSuccessorValue(1), "cond", SI);
       // Insert the new branch...
-      new BranchInst(SI->getSuccessor(1), SI->getSuccessor(0), Cond, SI);
+      BranchInst::Create(SI->getSuccessor(1), SI->getSuccessor(0), Cond, SI);
 
       // Delete the old switch...
       SI->getParent()->getInstList().erase(SI);

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LoopSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LoopSimplify.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LoopSimplify.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LoopSimplify.cpp Wed Mar 26 06:50:41 2008
@@ -270,10 +270,10 @@
                                        const std::vector<BasicBlock*> &Preds) {
 
   // Create new basic block, insert right before the original block...
-  BasicBlock *NewBB = new BasicBlock(BB->getName()+Suffix, BB->getParent(), BB);
+  BasicBlock *NewBB = BasicBlock::Create(BB->getName()+Suffix, BB->getParent(), BB);
 
   // The preheader first gets an unconditional branch to the loop header...
-  BranchInst *BI = new BranchInst(BB, NewBB);
+  BranchInst *BI = BranchInst::Create(BB, NewBB);
 
   // For every PHI node in the block, insert a PHI node into NewBB where the
   // incoming values from the out of loop edges are moved to NewBB.  We have two
@@ -300,7 +300,7 @@
       // If the values coming into the block are not the same, we need a PHI.
       if (InVal == 0) {
         // Create the new PHI node, insert it into NewBB at the end of the block
-        PHINode *NewPHI = new PHINode(PN->getType(), PN->getName()+".ph", BI);
+        PHINode *NewPHI = PHINode::Create(PN->getType(), PN->getName()+".ph", BI);
         if (AA) AA->copyValue(PN, NewPHI);
 
         // Move all of the edges from blocks outside the loop to the new PHI
@@ -623,8 +623,8 @@
     if (*I != Preheader) BackedgeBlocks.push_back(*I);
 
   // Create and insert the new backedge block...
-  BasicBlock *BEBlock = new BasicBlock(Header->getName()+".backedge", F);
-  BranchInst *BETerminator = new BranchInst(Header, BEBlock);
+  BasicBlock *BEBlock = BasicBlock::Create(Header->getName()+".backedge", F);
+  BranchInst *BETerminator = BranchInst::Create(Header, BEBlock);
 
   // Move the new backedge block to right after the last backedge block.
   Function::iterator InsertPos = BackedgeBlocks.back(); ++InsertPos;
@@ -634,8 +634,8 @@
   // the backedge block which correspond to any PHI nodes in the header block.
   for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
     PHINode *PN = cast<PHINode>(I);
-    PHINode *NewPN = new PHINode(PN->getType(), PN->getName()+".be",
-                                 BETerminator);
+    PHINode *NewPN = PHINode::Create(PN->getType(), PN->getName()+".be",
+                                     BETerminator);
     NewPN->reserveOperandSpace(BackedgeBlocks.size());
     if (AA) AA->copyValue(PN, NewPN);
 

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerAllocations.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerAllocations.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerAllocations.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerAllocations.cpp Wed Mar 26 06:50:41 2008
@@ -141,7 +141,7 @@
       }
 
       // Create the call to Malloc.
-      CallInst *MCall = new CallInst(MallocFunc, MallocArg, "", I);
+      CallInst *MCall = CallInst::Create(MallocFunc, MallocArg, "", I);
       MCall->setTailCall();
 
       // Create a cast instruction to convert to the right type...
@@ -162,7 +162,7 @@
                         PointerType::getUnqual(Type::Int8Ty), "", I);
 
       // Insert a call to the free function...
-      (new CallInst(FreeFunc, PtrCast, "", I))->setTailCall();
+      CallInst::Create(FreeFunc, PtrCast, "", I)->setTailCall();
 
       // Delete the old free instruction
       I = --BBIL.erase(I);

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerInvoke.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerInvoke.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerInvoke.cpp Wed Mar 26 06:50:41 2008
@@ -211,15 +211,15 @@
     if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator())) {
       std::vector<Value*> CallArgs(II->op_begin()+3, II->op_end());
       // Insert a normal call instruction...
-      CallInst *NewCall = new CallInst(II->getCalledValue(),
-                                       CallArgs.begin(), CallArgs.end(), "",II);
+      CallInst *NewCall = CallInst::Create(II->getCalledValue(),
+                                           CallArgs.begin(), CallArgs.end(), "",II);
       NewCall->takeName(II);
       NewCall->setCallingConv(II->getCallingConv());
       NewCall->setParamAttrs(II->getParamAttrs());
       II->replaceAllUsesWith(NewCall);
 
       // Insert an unconditional branch to the normal destination.
-      new BranchInst(II->getNormalDest(), II);
+      BranchInst::Create(II->getNormalDest(), II);
 
       // Remove any PHI node entries from the exception destination.
       II->getUnwindDest()->removePredecessor(BB);
@@ -233,12 +233,12 @@
       writeAbortMessage(UI);
 
       // Insert a call to abort()
-      (new CallInst(AbortFn, "", UI))->setTailCall();
+      CallInst::Create(AbortFn, "", UI)->setTailCall();
 
       // Insert a return instruction.  This really should be a "barrier", as it
       // is unreachable.
-      new ReturnInst(F.getReturnType() == Type::VoidTy ? 0 :
-                            Constant::getNullValue(F.getReturnType()), UI);
+      ReturnInst::Create(F.getReturnType() == Type::VoidTy ? 0 :
+                         Constant::getNullValue(F.getReturnType()), UI);
 
       // Remove the unwind instruction now.
       BB->getInstList().erase(UI);
@@ -280,16 +280,16 @@
   
   // Insert a normal call instruction.
   std::vector<Value*> CallArgs(II->op_begin()+3, II->op_end());
-  CallInst *NewCall = new CallInst(II->getCalledValue(),
-                                   CallArgs.begin(), CallArgs.end(), "",
-                                   II);
+  CallInst *NewCall = CallInst::Create(II->getCalledValue(),
+                                       CallArgs.begin(), CallArgs.end(), "",
+                                       II);
   NewCall->takeName(II);
   NewCall->setCallingConv(II->getCallingConv());
   NewCall->setParamAttrs(II->getParamAttrs());
   II->replaceAllUsesWith(NewCall);
   
   // Replace the invoke with an uncond branch.
-  new BranchInst(II->getNormalDest(), NewCall->getParent());
+  BranchInst::Create(II->getNormalDest(), NewCall->getParent());
   II->eraseFromParent();
 }
 
@@ -463,8 +463,8 @@
     std::vector<Value*> Idx;
     Idx.push_back(Constant::getNullValue(Type::Int32Ty));
     Idx.push_back(ConstantInt::get(Type::Int32Ty, 1));
-    OldJmpBufPtr = new GetElementPtrInst(JmpBuf, Idx.begin(), Idx.end(),
-                                         "OldBuf", EntryBB->getTerminator());
+    OldJmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(),
+                                             "OldBuf", EntryBB->getTerminator());
 
     // Copy the JBListHead to the alloca.
     Value *OldBuf = new LoadInst(JBListHead, "oldjmpbufptr", true,
@@ -476,7 +476,7 @@
 
     // Create the catch block.  The catch block is basically a big switch
     // statement that goes to all of the invoke catch blocks.
-    BasicBlock *CatchBB = new BasicBlock("setjmp.catch", &F);
+    BasicBlock *CatchBB = BasicBlock::Create("setjmp.catch", &F);
     
     // Create an alloca which keeps track of which invoke is currently
     // executing.  For normal calls it contains zero.
@@ -488,12 +488,12 @@
     // Insert a load in the Catch block, and a switch on its value.  By default,
     // we go to a block that just does an unwind (which is the correct action
     // for a standard call).
-    BasicBlock *UnwindBB = new BasicBlock("unwindbb", &F);
+    BasicBlock *UnwindBB = BasicBlock::Create("unwindbb", &F);
     Unwinds.push_back(new UnwindInst(UnwindBB));
     
     Value *CatchLoad = new LoadInst(InvokeNum, "invoke.num", true, CatchBB);
-    SwitchInst *CatchSwitch = 
-      new SwitchInst(CatchLoad, UnwindBB, Invokes.size(), CatchBB);
+    SwitchInst *CatchSwitch =
+      SwitchInst::Create(CatchLoad, UnwindBB, Invokes.size(), CatchBB);
 
     // Now that things are set up, insert the setjmp call itself.
     
@@ -502,11 +502,11 @@
                                                      "setjmp.cont");
 
     Idx[1] = ConstantInt::get(Type::Int32Ty, 0);
-    Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, Idx.begin(), Idx.end(),
-                                             "TheJmpBuf",
-                                             EntryBB->getTerminator());
-    Value *SJRet = new CallInst(SetJmpFn, JmpBufPtr, "sjret",
-                                EntryBB->getTerminator());
+    Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(),
+                                                 "TheJmpBuf",
+                                                 EntryBB->getTerminator());
+    Value *SJRet = CallInst::Create(SetJmpFn, JmpBufPtr, "sjret",
+                                    EntryBB->getTerminator());
     
     // Compare the return value to zero.
     Value *IsNormal = new ICmpInst(ICmpInst::ICMP_EQ, SJRet, 
@@ -516,7 +516,7 @@
     EntryBB->getTerminator()->eraseFromParent();
     
     // Put in a new condbranch in its place.
-    new BranchInst(ContBlock, CatchBB, IsNormal, EntryBB);
+    BranchInst::Create(ContBlock, CatchBB, IsNormal, EntryBB);
 
     // At this point, we are all set up, rewrite each invoke instruction.
     for (unsigned i = 0, e = Invokes.size(); i != e; ++i)
@@ -528,9 +528,9 @@
   // Create three new blocks, the block to load the jmpbuf ptr and compare
   // against null, the block to do the longjmp, and the error block for if it
   // is null.  Add them at the end of the function because they are not hot.
-  BasicBlock *UnwindHandler = new BasicBlock("dounwind", &F);
-  BasicBlock *UnwindBlock = new BasicBlock("unwind", &F);
-  BasicBlock *TermBlock = new BasicBlock("unwinderror", &F);
+  BasicBlock *UnwindHandler = BasicBlock::Create("dounwind", &F);
+  BasicBlock *UnwindBlock = BasicBlock::Create("unwind", &F);
+  BasicBlock *TermBlock = BasicBlock::Create("unwinderror", &F);
 
   // If this function contains an invoke, restore the old jumpbuf ptr.
   Value *BufPtr;
@@ -546,17 +546,17 @@
   Value *NotNull = new ICmpInst(ICmpInst::ICMP_NE, BufPtr, 
                                 Constant::getNullValue(BufPtr->getType()),
     "notnull", UnwindHandler);
-  new BranchInst(UnwindBlock, TermBlock, NotNull, UnwindHandler);
+  BranchInst::Create(UnwindBlock, TermBlock, NotNull, UnwindHandler);
   
   // Create the block to do the longjmp.
   // Get a pointer to the jmpbuf and longjmp.
   std::vector<Value*> Idx;
   Idx.push_back(Constant::getNullValue(Type::Int32Ty));
   Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
-  Idx[0] = new GetElementPtrInst(BufPtr, Idx.begin(), Idx.end(), "JmpBuf",
-                                 UnwindBlock);
+  Idx[0] = GetElementPtrInst::Create(BufPtr, Idx.begin(), Idx.end(), "JmpBuf",
+                                     UnwindBlock);
   Idx[1] = ConstantInt::get(Type::Int32Ty, 1);
-  new CallInst(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock);
+  CallInst::Create(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock);
   new UnreachableInst(UnwindBlock);
   
   // Set up the term block ("throw without a catch").
@@ -566,13 +566,13 @@
   writeAbortMessage(TermBlock->getTerminator());
   
   // Insert a call to abort()
-  (new CallInst(AbortFn, "",
-                TermBlock->getTerminator()))->setTailCall();
+  CallInst::Create(AbortFn, "",
+                   TermBlock->getTerminator())->setTailCall();
     
   
   // Replace all unwinds with a branch to the unwind handler.
   for (unsigned i = 0, e = Unwinds.size(); i != e; ++i) {
-    new BranchInst(UnwindHandler, Unwinds[i]);
+    BranchInst::Create(UnwindHandler, Unwinds[i]);
     Unwinds[i]->eraseFromParent();    
   } 
   

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerSwitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerSwitch.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerSwitch.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerSwitch.cpp Wed Mar 26 06:50:41 2008
@@ -158,13 +158,13 @@
   // Create a new node that checks if the value is < pivot. Go to the
   // left branch if it is and right branch if not.
   Function* F = OrigBlock->getParent();
-  BasicBlock* NewNode = new BasicBlock("NodeBlock");
+  BasicBlock* NewNode = BasicBlock::Create("NodeBlock");
   Function::iterator FI = OrigBlock;
   F->getBasicBlockList().insert(++FI, NewNode);
 
   ICmpInst* Comp = new ICmpInst(ICmpInst::ICMP_SLT, Val, Pivot.Low, "Pivot");
   NewNode->getInstList().push_back(Comp);
-  new BranchInst(LBranch, RBranch, Comp, NewNode);
+  BranchInst::Create(LBranch, RBranch, Comp, NewNode);
   return NewNode;
 }
 
@@ -179,7 +179,7 @@
                                       BasicBlock* Default)
 {
   Function* F = OrigBlock->getParent();
-  BasicBlock* NewLeaf = new BasicBlock("LeafBlock");
+  BasicBlock* NewLeaf = BasicBlock::Create("LeafBlock");
   Function::iterator FI = OrigBlock;
   F->getBasicBlockList().insert(++FI, NewLeaf);
 
@@ -213,7 +213,7 @@
 
   // Make the conditional branch...
   BasicBlock* Succ = Leaf.BB;
-  new BranchInst(Succ, Default, Comp, NewLeaf);
+  BranchInst::Create(Succ, Default, Comp, NewLeaf);
 
   // If there were any PHI nodes in this successor, rewrite one entry
   // from OrigBlock to come from NewLeaf.
@@ -284,17 +284,17 @@
 
   // If there is only the default destination, don't bother with the code below.
   if (SI->getNumOperands() == 2) {
-    new BranchInst(SI->getDefaultDest(), CurBlock);
+    BranchInst::Create(SI->getDefaultDest(), CurBlock);
     CurBlock->getInstList().erase(SI);
     return;
   }
 
   // Create a new, empty default block so that the new hierarchy of
   // if-then statements go to this and the PHI nodes are happy.
-  BasicBlock* NewDefault = new BasicBlock("NewDefault");
+  BasicBlock* NewDefault = BasicBlock::Create("NewDefault");
   F->getBasicBlockList().insert(Default, NewDefault);
 
-  new BranchInst(Default, NewDefault);
+  BranchInst::Create(Default, NewDefault);
 
   // If there is an entry in any PHI nodes for the default edge, make sure
   // to update them as well.
@@ -317,7 +317,7 @@
                                           OrigBlock, NewDefault);
 
   // Branch to our shiny new if-then stuff...
-  new BranchInst(SwitchBlock, OrigBlock);
+  BranchInst::Create(SwitchBlock, OrigBlock);
 
   // We are now done with the switch instruction, delete it.
   CurBlock->getInstList().erase(SI);

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Wed Mar 26 06:50:41 2008
@@ -834,9 +834,9 @@
 
   // Create a PhiNode using the dereferenced type... and add the phi-node to the
   // BasicBlock.
-  PN = new PHINode(Allocas[AllocaNo]->getAllocatedType(),
-                   Allocas[AllocaNo]->getName() + "." +
-                   utostr(Version++), BB->begin());
+  PN = PHINode::Create(Allocas[AllocaNo]->getAllocatedType(),
+                       Allocas[AllocaNo]->getName() + "." +
+                       utostr(Version++), BB->begin());
   ++NumPHIInsert;
   PhiToAllocaMap[PN] = AllocaNo;
   PN->reserveOperandSpace(getNumPreds(BB));

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/SimplifyCFG.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/SimplifyCFG.cpp Wed Mar 26 06:50:41 2008
@@ -619,7 +619,7 @@
         assert(ThisCases.size() == 1 && "Branch can only have one case!");
         Value *Cond = BTI->getCondition();
         // Insert the new branch.
-        Instruction *NI = new BranchInst(ThisDef, TI);
+        Instruction *NI = BranchInst::Create(ThisDef, TI);
 
         // Remove PHI node entries for the dead edge.
         ThisCases[0].second->removePredecessor(TI->getParent());
@@ -689,7 +689,7 @@
         CheckEdge = 0;
 
     // Insert the new branch.
-    Instruction *NI = new BranchInst(TheRealDest, TI);
+    Instruction *NI = BranchInst::Create(TheRealDest, TI);
 
     DOUT << "Threading pred instr: " << *Pred->getTerminator()
          << "Through successor TI: " << *TI << "Leaving: " << *NI << "\n";
@@ -802,7 +802,7 @@
         AddPredecessorToBlock(NewSuccessors[i], Pred, BB);
 
       // Now that the successors are updated, create the new Switch instruction.
-      SwitchInst *NewSI = new SwitchInst(CV, PredDefault, PredCases.size(),PTI);
+      SwitchInst *NewSI = SwitchInst::Create(CV, PredDefault, PredCases.size(), PTI);
       for (unsigned i = 0, e = PredCases.size(); i != e; ++i)
         NewSI->addCase(PredCases[i].first, PredCases[i].second);
 
@@ -824,8 +824,8 @@
           if (InfLoopBlock == 0) {
             // Insert it at the end of the loop, because it's either code,
             // or it won't matter if it's hot. :)
-            InfLoopBlock = new BasicBlock("infloop", BB->getParent());
-            new BranchInst(InfLoopBlock, InfLoopBlock);
+            InfLoopBlock = BasicBlock::Create("infloop", BB->getParent());
+            BranchInst::Create(InfLoopBlock, InfLoopBlock);
           }
           NewSI->setSuccessor(i, InfLoopBlock);
         }
@@ -902,8 +902,8 @@
         // that determines the right value.
         SelectInst *&SI = InsertedSelects[std::make_pair(BB1V, BB2V)];
         if (SI == 0)
-          SI = new SelectInst(BI->getCondition(), BB1V, BB2V,
-                              BB1V->getName()+"."+BB2V->getName(), NT);
+          SI = SelectInst::Create(BI->getCondition(), BB1V, BB2V,
+                                  BB1V->getName()+"."+BB2V->getName(), NT);
         // Make the PHI node use the select for all incoming values for BB1/BB2
         for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
           if (PN->getIncomingBlock(i) == BB1 || PN->getIncomingBlock(i) == BB2)
@@ -987,9 +987,9 @@
       // difficult cases.  Instead of being smart about this, just insert a new
       // block that jumps to the destination block, effectively splitting
       // the edge we are about to create.
-      BasicBlock *EdgeBB = new BasicBlock(RealDest->getName()+".critedge",
-                                          RealDest->getParent(), RealDest);
-      new BranchInst(RealDest, EdgeBB);
+      BasicBlock *EdgeBB = BasicBlock::Create(RealDest->getName()+".critedge",
+                                              RealDest->getParent(), RealDest);
+      BranchInst::Create(RealDest, EdgeBB);
       PHINode *PN;
       for (BasicBlock::iterator BBI = RealDest->begin();
            (PN = dyn_cast<PHINode>(BBI)); ++BBI) {
@@ -1156,7 +1156,7 @@
     Value *FalseVal =
       PN->getIncomingValue(PN->getIncomingBlock(0) == IfTrue);
     
-    Value *NV = new SelectInst(IfCond, TrueVal, FalseVal, "", AfterPHIIt);
+    Value *NV = SelectInst::Create(IfCond, TrueVal, FalseVal, "", AfterPHIIt);
     PN->replaceAllUsesWith(NV);
     NV->takeName(PN);
     
@@ -1307,7 +1307,7 @@
             if (RI->getNumOperands() == 0) {
               TrueSucc->removePredecessor(BI->getParent());
               FalseSucc->removePredecessor(BI->getParent());
-              new ReturnInst(0, BI);
+              ReturnInst::Create(0, BI);
               BI->getParent()->getInstList().erase(BI);
               return true;
             }
@@ -1341,8 +1341,8 @@
               Value *NewRetVal;
               Value *BrCond = BI->getCondition();
               if (TrueValue != FalseValue)
-                NewRetVal = new SelectInst(BrCond, TrueValue,
-                                           FalseValue, "retval", BI);
+                NewRetVal = SelectInst::Create(BrCond, TrueValue,
+                                               FalseValue, "retval", BI);
               else
                 NewRetVal = TrueValue;
               
@@ -1350,7 +1350,7 @@
                    << "\n  " << *BI << "Select = " << *NewRetVal
                    << "TRUEBLOCK: " << *TrueSucc << "FALSEBLOCK: "<< *FalseSucc;
 
-              new ReturnInst(NewRetVal, BI);
+              ReturnInst::Create(NewRetVal, BI);
               BI->eraseFromParent();
               if (Instruction *BrCondI = dyn_cast<Instruction>(BrCond))
                 if (isInstructionTriviallyDead(BrCondI))
@@ -1386,13 +1386,13 @@
         if (II->getUnwindDest() == BB) {
           // Insert a new branch instruction before the invoke, because this
           // is now a fall through...
-          BranchInst *BI = new BranchInst(II->getNormalDest(), II);
+          BranchInst *BI = BranchInst::Create(II->getNormalDest(), II);
           Pred->getInstList().remove(II);   // Take out of symbol table
 
           // Insert the call now...
           SmallVector<Value*,8> Args(II->op_begin()+3, II->op_end());
-          CallInst *CI = new CallInst(II->getCalledValue(),
-                                      Args.begin(), Args.end(), II->getName(), BI);
+          CallInst *CI = CallInst::Create(II->getCalledValue(),
+                                          Args.begin(), Args.end(), II->getName(), BI);
           CI->setCallingConv(II->getCallingConv());
           CI->setParamAttrs(II->getParamAttrs());
           // If the invoke produced a value, the Call now does instead
@@ -1540,9 +1540,9 @@
               // Otherwise, if there are multiple predecessors, insert a PHI 
               // that merges in the constant and simplify the block result.
               if (BlockIsSimpleEnoughToThreadThrough(BB)) {
-                PHINode *NewPN = new PHINode(Type::Int1Ty,
-                                            BI->getCondition()->getName()+".pr",
-                                            BB->begin());
+                PHINode *NewPN = PHINode::Create(Type::Int1Ty,
+                                                 BI->getCondition()->getName()+".pr",
+                                                 BB->begin());
                 for (PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI)
                   if ((PBI = dyn_cast<BranchInst>((*PI)->getTerminator())) &&
                       PBI != BI && PBI->isConditional() &&
@@ -1661,8 +1661,8 @@
                   Value *PBIV = PN->getIncomingValue(PBBIdx);
                   if (BIV != PBIV) {
                     // Insert a select in PBI to pick the right value.
-                    Value *NV = new SelectInst(PBICond, PBIV, BIV,
-                                               PBIV->getName()+".mux", PBI);
+                    Value *NV = SelectInst::Create(PBICond, PBIV, BIV,
+                                                   PBIV->getName()+".mux", PBI);
                     PN->setIncomingValue(PBBIdx, NV);
                   }
                 }
@@ -1705,10 +1705,10 @@
             }
           } else {
             if (BI->getSuccessor(0) == BB) {
-              new BranchInst(BI->getSuccessor(1), BI);
+              BranchInst::Create(BI->getSuccessor(1), BI);
               BI->eraseFromParent();
             } else if (BI->getSuccessor(1) == BB) {
-              new BranchInst(BI->getSuccessor(0), BI);
+              BranchInst::Create(BI->getSuccessor(0), BI);
               BI->eraseFromParent();
               Changed = true;
             }
@@ -1761,14 +1761,14 @@
           if (II->getUnwindDest() == BB) {
             // Convert the invoke to a call instruction.  This would be a good
             // place to note that the call does not throw though.
-            BranchInst *BI = new BranchInst(II->getNormalDest(), II);
+            BranchInst *BI = BranchInst::Create(II->getNormalDest(), II);
             II->removeFromParent();   // Take out of symbol table
 
             // Insert the call now...
             SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
-            CallInst *CI = new CallInst(II->getCalledValue(),
-                                        Args.begin(), Args.end(),
-                                        II->getName(), BI);
+            CallInst *CI = CallInst::Create(II->getCalledValue(),
+                                            Args.begin(), Args.end(),
+                                            II->getName(), BI);
             CI->setCallingConv(II->getCallingConv());
             CI->setParamAttrs(II->getParamAttrs());
             // If the invoke produced a value, the Call does now instead.
@@ -1894,7 +1894,7 @@
           if (!TrueWhenEqual) std::swap(DefaultBB, EdgeBB);
 
           // Create the new switch instruction now.
-          SwitchInst *New = new SwitchInst(CompVal, DefaultBB,Values.size(),BI);
+          SwitchInst *New = SwitchInst::Create(CompVal, DefaultBB,Values.size(),BI);
 
           // Add all of the 'cases' to the switch instruction.
           for (unsigned i = 0, e = Values.size(); i != e; ++i)

Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp?rev=48820&r1=48819&r2=48820&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Wed Mar 26 06:50:41 2008
@@ -69,14 +69,14 @@
   } else if (UnwindingBlocks.size() == 1) {
     UnwindBlock = UnwindingBlocks.front();
   } else {
-    UnwindBlock = new BasicBlock("UnifiedUnwindBlock", &F);
+    UnwindBlock = BasicBlock::Create("UnifiedUnwindBlock", &F);
     new UnwindInst(UnwindBlock);
 
     for (std::vector<BasicBlock*>::iterator I = UnwindingBlocks.begin(),
            E = UnwindingBlocks.end(); I != E; ++I) {
       BasicBlock *BB = *I;
       BB->getInstList().pop_back();  // Remove the unwind insn
-      new BranchInst(UnwindBlock, BB);
+      BranchInst::Create(UnwindBlock, BB);
     }
   }
 
@@ -86,14 +86,14 @@
   } else if (UnreachableBlocks.size() == 1) {
     UnreachableBlock = UnreachableBlocks.front();
   } else {
-    UnreachableBlock = new BasicBlock("UnifiedUnreachableBlock", &F);
+    UnreachableBlock = BasicBlock::Create("UnifiedUnreachableBlock", &F);
     new UnreachableInst(UnreachableBlock);
 
     for (std::vector<BasicBlock*>::iterator I = UnreachableBlocks.begin(),
            E = UnreachableBlocks.end(); I != E; ++I) {
       BasicBlock *BB = *I;
       BB->getInstList().pop_back();  // Remove the unreachable inst.
-      new BranchInst(UnreachableBlock, BB);
+      BranchInst::Create(UnreachableBlock, BB);
     }
   }
 
@@ -110,27 +110,27 @@
   // nodes (if the function returns values), and convert all of the return
   // instructions into unconditional branches.
   //
-  BasicBlock *NewRetBlock = new BasicBlock("UnifiedReturnBlock", &F);
+  BasicBlock *NewRetBlock = BasicBlock::Create("UnifiedReturnBlock", &F);
 
   SmallVector<Value *, 4> Phis;
   unsigned NumRetVals = ReturningBlocks[0]->getTerminator()->getNumOperands();
   if (NumRetVals == 0)
-    new ReturnInst(NULL, NewRetBlock);
+    ReturnInst::Create(NULL, NewRetBlock);
   else if (const StructType *STy = dyn_cast<StructType>(F.getReturnType())) {
     Instruction *InsertPt = NewRetBlock->getFirstNonPHI();
     for (unsigned i = 0; i < NumRetVals; ++i) {
-      PHINode *PN = new PHINode(STy->getElementType(i), "UnifiedRetVal." 
-                                + utostr(i), InsertPt);
+      PHINode *PN = PHINode::Create(STy->getElementType(i), "UnifiedRetVal." 
+                                    + utostr(i), InsertPt);
       Phis.push_back(PN);
     }
-    new ReturnInst(&Phis[0], NumRetVals);
+    ReturnInst::Create(&Phis[0], NumRetVals);
   }
   else {
     // If the function doesn't return void... add a PHI node to the block...
-    PHINode *PN = new PHINode(F.getReturnType(), "UnifiedRetVal");
+    PHINode *PN = PHINode::Create(F.getReturnType(), "UnifiedRetVal");
     NewRetBlock->getInstList().push_back(PN);
     Phis.push_back(PN);
-    new ReturnInst(PN, NewRetBlock);
+    ReturnInst::Create(PN, NewRetBlock);
   }
 
   // Loop over all of the blocks, replacing the return instruction with an
@@ -149,7 +149,7 @@
     }
 
     BB->getInstList().pop_back();  // Remove the return insn
-    new BranchInst(NewRetBlock, BB);
+    BranchInst::Create(NewRetBlock, BB);
   }
   ReturnBlock = NewRetBlock;
   return true;





More information about the llvm-commits mailing list