[llvm-commits] [llvm] r49277 - in /llvm/trunk: examples/BrainF/ examples/Fibonacci/ examples/HowToUseJIT/ examples/ModuleMaker/ examples/ParallelJIT/ include/llvm/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/ExecutionEngine/JIT/ lib/Linker/ lib/Target/X86/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/

Gabor Greif ggreif at gmail.com
Sun Apr 6 13:25:18 PDT 2008


Author: ggreif
Date: Sun Apr  6 15:25:17 2008
New Revision: 49277

URL: http://llvm.org/viewvc/llvm-project?rev=49277&view=rev
Log:
API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.

Modified:
    llvm/trunk/examples/BrainF/BrainF.cpp
    llvm/trunk/examples/BrainF/BrainFDriver.cpp
    llvm/trunk/examples/Fibonacci/fibonacci.cpp
    llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp
    llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp
    llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp
    llvm/trunk/include/llvm/BasicBlock.h
    llvm/trunk/include/llvm/Constants.h
    llvm/trunk/include/llvm/Function.h
    llvm/trunk/include/llvm/GlobalAlias.h
    llvm/trunk/include/llvm/GlobalVariable.h
    llvm/trunk/include/llvm/InstrTypes.h
    llvm/trunk/include/llvm/Instructions.h
    llvm/trunk/include/llvm/Support/LLVMBuilder.h
    llvm/trunk/include/llvm/User.h
    llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
    llvm/trunk/lib/AsmParser/llvmAsmParser.y
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp
    llvm/trunk/lib/CodeGen/ShadowStackCollector.cpp
    llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
    llvm/trunk/lib/Linker/LinkModules.cpp
    llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
    llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
    llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
    llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp
    llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp
    llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
    llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp
    llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp
    llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
    llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp
    llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp
    llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
    llvm/trunk/lib/Transforms/Scalar/GCSE.cpp
    llvm/trunk/lib/Transforms/Scalar/GVN.cpp
    llvm/trunk/lib/Transforms/Scalar/GVNPRE.cpp
    llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
    llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
    llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
    llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
    llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
    llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
    llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp
    llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
    llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
    llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp
    llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
    llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
    llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
    llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
    llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
    llvm/trunk/lib/Transforms/Utils/Local.cpp
    llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
    llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp
    llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
    llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp
    llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
    llvm/trunk/lib/VMCore/AutoUpgrade.cpp
    llvm/trunk/lib/VMCore/BasicBlock.cpp
    llvm/trunk/lib/VMCore/Constants.cpp
    llvm/trunk/lib/VMCore/Core.cpp
    llvm/trunk/lib/VMCore/Function.cpp
    llvm/trunk/lib/VMCore/Instructions.cpp
    llvm/trunk/lib/VMCore/Module.cpp
    llvm/trunk/tools/bugpoint/CrashDebugger.cpp
    llvm/trunk/tools/bugpoint/Miscompilation.cpp

Modified: llvm/trunk/examples/BrainF/BrainF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/examples/BrainF/BrainF.cpp (original)
+++ llvm/trunk/examples/BrainF/BrainF.cpp Sun Apr  6 15:25:17 2008
@@ -74,7 +74,7 @@
   brainf_func = cast<Function>(module->
     getOrInsertFunction("brainf", Type::VoidTy, NULL));
 
-  builder = new LLVMBuilder(new BasicBlock(label, brainf_func));
+  builder = new LLVMBuilder(BasicBlock::Create(label, brainf_func));
 
   //%arr = malloc i8, i32 %d
   ConstantInt *val_mem = ConstantInt::get(APInt(32, memtotal));
@@ -110,13 +110,13 @@
   //Function footer
 
   //brainf.end:
-  endbb = new BasicBlock(label, brainf_func);
+  endbb = BasicBlock::Create(label, brainf_func);
 
   //free i8 *%arr
   new FreeInst(ptr_arr, endbb);
 
   //ret void
-  new ReturnInst(endbb);
+  ReturnInst::Create(endbb);
 
 
 
@@ -141,7 +141,7 @@
                           PointerType::getUnqual(IntegerType::Int8Ty), NULL));
 
     //brainf.aberror:
-    aberrorbb = new BasicBlock(label, brainf_func);
+    aberrorbb = BasicBlock::Create(label, brainf_func);
 
     //call i32 @puts(i8 *getelementptr([%d x i8] *@aberrormsg, i32 0, i32 0))
     {
@@ -161,14 +161,14 @@
       };
 
       CallInst *puts_call =
-        new CallInst(puts_func,
-                     puts_params, array_endof(puts_params),
-                     "", aberrorbb);
+        CallInst::Create(puts_func,
+                         puts_params, array_endof(puts_params),
+                         "", aberrorbb);
       puts_call->setTailCall(false);
     }
 
     //br label %brainf.end
-    new BranchInst(endbb, aberrorbb);
+    BranchInst::Create(endbb, aberrorbb);
   }
 }
 
@@ -247,7 +247,7 @@
               CreateOr(test_0, test_1, testreg);
 
             //br i1 %test.%d, label %main.%d, label %main.%d
-            BasicBlock *nextbb = new BasicBlock(label, brainf_func);
+            BasicBlock *nextbb = BasicBlock::Create(label, brainf_func);
             builder->CreateCondBr(test_2, aberrorbb, nextbb);
 
             //main.%d:
@@ -273,16 +273,16 @@
       case SYM_LOOP:
         {
           //br label %main.%d
-          BasicBlock *testbb = new BasicBlock(label, brainf_func);
+          BasicBlock *testbb = BasicBlock::Create(label, brainf_func);
           builder->CreateBr(testbb);
 
           //main.%d:
           BasicBlock *bb_0 = builder->GetInsertBlock();
-          BasicBlock *bb_1 = new BasicBlock(label, brainf_func);
+          BasicBlock *bb_1 = BasicBlock::Create(label, brainf_func);
           builder->SetInsertPoint(bb_1);
 
           //Make part of PHI instruction now, wait until end of loop to finish
-          PHINode *phi_0 = new PHINode(PointerType::getUnqual(IntegerType::Int8Ty),
+          PHINode *phi_0 = PHINode::Create(PointerType::getUnqual(IntegerType::Int8Ty),
                                        headreg, testbb);
           phi_0->reserveOperandSpace(2);
           phi_0->addIncoming(curhead, bb_0);
@@ -431,8 +431,8 @@
                                       testbb);
 
       //br i1 %test.%d, label %main.%d, label %main.%d
-      BasicBlock *bb_0 = new BasicBlock(label, brainf_func);
-      new BranchInst(bb_0, oldbb, test_0, testbb);
+      BasicBlock *bb_0 = BasicBlock::Create(label, brainf_func);
+      BranchInst::Create(bb_0, oldbb, test_0, testbb);
 
       //main.%d:
       builder->SetInsertPoint(bb_0);

Modified: llvm/trunk/examples/BrainF/BrainFDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainFDriver.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/examples/BrainF/BrainFDriver.cpp (original)
+++ llvm/trunk/examples/BrainF/BrainFDriver.cpp Sun Apr  6 15:25:17 2008
@@ -70,17 +70,17 @@
   }
 
   //main.0:
-  BasicBlock *bb = new BasicBlock("main.0", main_func);
+  BasicBlock *bb = BasicBlock::Create("main.0", main_func);
 
   //call void @brainf()
   {
-    CallInst *brainf_call = new CallInst(mod->getFunction("brainf"),
-                                         "", bb);
+    CallInst *brainf_call = CallInst::Create(mod->getFunction("brainf"),
+                                             "", bb);
     brainf_call->setTailCall(false);
   }
 
   //ret i32 0
-  new ReturnInst(ConstantInt::get(APInt(32, 0)), bb);
+  ReturnInst::Create(ConstantInt::get(APInt(32, 0)), bb);
 }
 
 int main(int argc, char **argv) {

Modified: llvm/trunk/examples/Fibonacci/fibonacci.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Fibonacci/fibonacci.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/examples/Fibonacci/fibonacci.cpp (original)
+++ llvm/trunk/examples/Fibonacci/fibonacci.cpp Sun Apr  6 15:25:17 2008
@@ -43,7 +43,7 @@
                                           (Type *)0));
 
   // Add a basic block to the function.
-  BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
+  BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF);
 
   // Get pointers to the constants.
   Value *One = ConstantInt::get(Type::Int32Ty, 1);
@@ -54,25 +54,25 @@
   ArgX->setName("AnArg");            // Give it a nice symbolic name for fun.
 
   // Create the true_block.
-  BasicBlock *RetBB = new BasicBlock("return", FibF);
+  BasicBlock *RetBB = BasicBlock::Create("return", FibF);
   // Create an exit block.
-  BasicBlock* RecurseBB = new BasicBlock("recurse", FibF);
+  BasicBlock* RecurseBB = BasicBlock::Create("recurse", FibF);
 
   // Create the "if (arg <= 2) goto exitbb"
   Value *CondInst = new ICmpInst(ICmpInst::ICMP_SLE, ArgX, Two, "cond", BB);
-  new BranchInst(RetBB, RecurseBB, CondInst, BB);
+  BranchInst::Create(RetBB, RecurseBB, CondInst, BB);
 
   // Create: ret int 1
-  new ReturnInst(One, RetBB);
+  ReturnInst::Create(One, RetBB);
 
   // create fib(x-1)
   Value *Sub = BinaryOperator::createSub(ArgX, One, "arg", RecurseBB);
-  CallInst *CallFibX1 = new CallInst(FibF, Sub, "fibx1", RecurseBB);
+  CallInst *CallFibX1 = CallInst::Create(FibF, Sub, "fibx1", RecurseBB);
   CallFibX1->setTailCall();
 
   // create fib(x-2)
   Sub = BinaryOperator::createSub(ArgX, Two, "arg", RecurseBB);
-  CallInst *CallFibX2 = new CallInst(FibF, Sub, "fibx2", RecurseBB);
+  CallInst *CallFibX2 = CallInst::Create(FibF, Sub, "fibx2", RecurseBB);
   CallFibX2->setTailCall();
 
 
@@ -81,7 +81,7 @@
                                          "addresult", RecurseBB);
 
   // Create the return instruction and add it to the basic block
-  new ReturnInst(Sum, RecurseBB);
+  ReturnInst::Create(Sum, RecurseBB);
 
   return FibF;
 }

Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp (original)
+++ llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp Sun Apr  6 15:25:17 2008
@@ -58,7 +58,7 @@
 
   // Add a basic block to the function. As before, it automatically inserts
   // because of the last argument.
-  BasicBlock *BB = new BasicBlock("EntryBlock", Add1F);
+  BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F);
 
   // Get pointers to the constant `1'.
   Value *One = ConstantInt::get(Type::Int32Ty, 1);
@@ -72,7 +72,7 @@
   Instruction *Add = BinaryOperator::createAdd(One, ArgX, "addresult", BB);
 
   // Create the return instruction and add it to the basic block
-  new ReturnInst(Add, BB);
+  ReturnInst::Create(Add, BB);
 
   // Now, function add1 is ready.
 
@@ -83,17 +83,17 @@
     cast<Function>(M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0));
 
   // Add a basic block to the FooF function.
-  BB = new BasicBlock("EntryBlock", FooF);
+  BB = BasicBlock::Create("EntryBlock", FooF);
 
   // Get pointers to the constant `10'.
   Value *Ten = ConstantInt::get(Type::Int32Ty, 10);
 
   // Pass Ten to the call call:
-  CallInst *Add1CallRes = new CallInst(Add1F, Ten, "add1", BB);
+  CallInst *Add1CallRes = CallInst::Create(Add1F, Ten, "add1", BB);
   Add1CallRes->setTailCall(true);
 
   // Create the return instruction and add it to the basic block.
-  new ReturnInst(Add1CallRes, BB);
+  ReturnInst::Create(Add1CallRes, BB);
 
   // Now we create the JIT.
   ExistingModuleProvider* MP = new ExistingModuleProvider(M);

Modified: llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp (original)
+++ llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp Sun Apr  6 15:25:17 2008
@@ -32,11 +32,11 @@
 
   // By passing a module as the last parameter to the Function constructor,
   // it automatically gets appended to the Module.
-  Function *F = new Function(FT, Function::ExternalLinkage, "main", M);
+  Function *F = Function::Create(FT, Function::ExternalLinkage, "main", M);
 
   // Add a basic block to the function... again, it automatically inserts
   // because of the last argument.
-  BasicBlock *BB = new BasicBlock("EntryBlock", F);
+  BasicBlock *BB = BasicBlock::Create("EntryBlock", F);
 
   // Get pointers to the constant integers...
   Value *Two = ConstantInt::get(Type::Int32Ty, 2);
@@ -50,7 +50,7 @@
   BB->getInstList().push_back(Add);
 
   // Create the return instruction and add it to the basic block
-  BB->getInstList().push_back(new ReturnInst(Add));
+  BB->getInstList().push_back(ReturnInst::Create(Add));
 
   // Output the bitcode file to stdout
   WriteBitcodeToFile(M, std::cout);

Modified: llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp (original)
+++ llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp Sun Apr  6 15:25:17 2008
@@ -39,7 +39,7 @@
 
   // Add a basic block to the function. As before, it automatically inserts
   // because of the last argument.
-  BasicBlock *BB = new BasicBlock("EntryBlock", Add1F);
+  BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F);
 
   // Get pointers to the constant `1'.
   Value *One = ConstantInt::get(Type::Int32Ty, 1);
@@ -53,7 +53,7 @@
   Instruction *Add = BinaryOperator::createAdd(One, ArgX, "addresult", BB);
 
   // Create the return instruction and add it to the basic block
-  new ReturnInst(Add, BB);
+  ReturnInst::Create(Add, BB);
 
   // Now, function add1 is ready.
   return Add1F;
@@ -67,7 +67,7 @@
                                           (Type *)0));
 
   // Add a basic block to the function.
-  BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
+  BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF);
 
   // Get pointers to the constants.
   Value *One = ConstantInt::get(Type::Int32Ty, 1);
@@ -78,31 +78,31 @@
   ArgX->setName("AnArg");            // Give it a nice symbolic name for fun.
 
   // Create the true_block.
-  BasicBlock *RetBB = new BasicBlock("return", FibF);
+  BasicBlock *RetBB = BasicBlock::Create("return", FibF);
   // Create an exit block.
-  BasicBlock* RecurseBB = new BasicBlock("recurse", FibF);
+  BasicBlock* RecurseBB = BasicBlock::Create("recurse", FibF);
 
   // Create the "if (arg < 2) goto exitbb"
   Value *CondInst = new ICmpInst(ICmpInst::ICMP_SLE, ArgX, Two, "cond", BB);
-  new BranchInst(RetBB, RecurseBB, CondInst, BB);
+  BranchInst::Create(RetBB, RecurseBB, CondInst, BB);
 
   // Create: ret int 1
-  new ReturnInst(One, RetBB);
+  ReturnInst::Create(One, RetBB);
 
   // create fib(x-1)
   Value *Sub = BinaryOperator::createSub(ArgX, One, "arg", RecurseBB);
-  Value *CallFibX1 = new CallInst(FibF, Sub, "fibx1", RecurseBB);
+  Value *CallFibX1 = CallInst::Create(FibF, Sub, "fibx1", RecurseBB);
 
   // create fib(x-2)
   Sub = BinaryOperator::createSub(ArgX, Two, "arg", RecurseBB);
-  Value *CallFibX2 = new CallInst(FibF, Sub, "fibx2", RecurseBB);
+  Value *CallFibX2 = CallInst::Create(FibF, Sub, "fibx2", RecurseBB);
 
   // fib(x-1)+fib(x-2)
   Value *Sum =
     BinaryOperator::createAdd(CallFibX1, CallFibX2, "addresult", RecurseBB);
 
   // Create the return instruction and add it to the basic block
-  new ReturnInst(Sum, RecurseBB);
+  ReturnInst::Create(Sum, RecurseBB);
 
   return FibF;
 }

Modified: llvm/trunk/include/llvm/BasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BasicBlock.h?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/include/llvm/BasicBlock.h (original)
+++ llvm/trunk/include/llvm/BasicBlock.h Sun Apr  6 15:25:17 2008
@@ -66,17 +66,22 @@
   BasicBlock(const BasicBlock &);     // Do not implement
   void operator=(const BasicBlock &); // Do not implement
 
-public:
-  /// Instruction iterators...
-  typedef InstListType::iterator                              iterator;
-  typedef InstListType::const_iterator                  const_iterator;
-
   /// BasicBlock ctor - If the function parameter is specified, the basic block
   /// is automatically inserted at either the end of the function (if
   /// InsertBefore is null), or before the specified basic block.
   ///
   explicit BasicBlock(const std::string &Name = "", Function *Parent = 0,
-                      BasicBlock *InsertBefore = 0, BasicBlock *unwindDest = 0);
+                      BasicBlock *InsertBefore = 0, BasicBlock *UnwindDest = 0);
+public:
+  /// Instruction iterators...
+  typedef InstListType::iterator                              iterator;
+  typedef InstListType::const_iterator                  const_iterator;
+
+  // allocate space for exactly zero operands
+  static BasicBlock *Create(const std::string &Name = "", Function *Parent = 0,
+                            BasicBlock *InsertBefore = 0, BasicBlock *UnwindDest = 0) {
+    return new(!!UnwindDest) BasicBlock(Name, Parent, InsertBefore, UnwindDest);
+  }
   ~BasicBlock();
 
   /// getUnwindDest - Returns the BasicBlock that flow will enter if an unwind

Modified: llvm/trunk/include/llvm/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Constants.h (original)
+++ llvm/trunk/include/llvm/Constants.h Sun Apr  6 15:25:17 2008
@@ -43,9 +43,15 @@
 /// @brief Class for constant integers.
 class ConstantInt : public Constant {
   static ConstantInt *TheTrueVal, *TheFalseVal;
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   ConstantInt(const ConstantInt &);      // DO NOT IMPLEMENT
   ConstantInt(const IntegerType *Ty, const APInt& V);
   APInt Val;
+protected:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
 public:
   /// Return the constant as an APInt value reference. This allows clients to
   /// obtain a copy of the value, with all its precision in tact.
@@ -215,9 +221,15 @@
 ///
 class ConstantFP : public Constant {
   APFloat Val;
+  void *operator new(size_t, unsigned);// DO NOT IMPLEMENT
   ConstantFP(const ConstantFP &);      // DO NOT IMPLEMENT
 protected:
   ConstantFP(const Type *Ty, const APFloat& V);
+protected:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
 public:
   /// get() - Static factory methods - Return objects of the specified value
   static ConstantFP *get(const Type *Ty, const APFloat& V);
@@ -262,10 +274,16 @@
 ///
 class ConstantAggregateZero : public Constant {
   friend struct ConstantCreator<ConstantAggregateZero, Type, char>;
+  void *operator new(size_t, unsigned);                      // DO NOT IMPLEMENT
   ConstantAggregateZero(const ConstantAggregateZero &);      // DO NOT IMPLEMENT
 protected:
   explicit ConstantAggregateZero(const Type *Ty)
     : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {}
+protected:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
 public:
   /// get() - static factory method for creating a null aggregate.  It is
   /// illegal to call this method with a non-aggregate type.
@@ -457,14 +475,19 @@
 ///
 class ConstantPointerNull : public Constant {
   friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
+  void *operator new(size_t, unsigned);                  // DO NOT IMPLEMENT
   ConstantPointerNull(const ConstantPointerNull &);      // DO NOT IMPLEMENT
 protected:
   explicit ConstantPointerNull(const PointerType *T)
     : Constant(reinterpret_cast<const Type*>(T),
                Value::ConstantPointerNullVal, 0, 0) {}
 
+protected:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
 public:
-
   /// get() - Static factory methods - Return objects of the specified value
   static ConstantPointerNull *get(const PointerType *T);
 
@@ -706,9 +729,15 @@
 ///
 class UndefValue : public Constant {
   friend struct ConstantCreator<UndefValue, Type, char>;
+  void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
   UndefValue(const UndefValue &);      // DO NOT IMPLEMENT
 protected:
   explicit UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
+protected:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
 public:
   /// get() - Static factory methods - Return an 'undef' object of the specified
   /// type.

Modified: llvm/trunk/include/llvm/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Function.h (original)
+++ llvm/trunk/include/llvm/Function.h Sun Apr  6 15:25:17 2008
@@ -104,13 +104,20 @@
   
   Function(const Function&); // DO NOT IMPLEMENT
   void operator=(const Function&); // DO NOT IMPLEMENT
-public:
+
   /// Function ctor - If the (optional) Module argument is specified, the
   /// function is automatically inserted into the end of the function list for
   /// the module.
   ///
   Function(const FunctionType *Ty, LinkageTypes Linkage,
            const std::string &N = "", Module *M = 0);
+
+public:
+  static Function *Create(const FunctionType *Ty, LinkageTypes Linkage,
+                          const std::string &N = "", Module *M = 0) {
+    return new(0) Function(Ty, Linkage, N, M);
+  }
+
   ~Function();
 
   const Type *getReturnType() const;           // Return the type of the ret val

Modified: llvm/trunk/include/llvm/GlobalAlias.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalAlias.h?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/include/llvm/GlobalAlias.h (original)
+++ llvm/trunk/include/llvm/GlobalAlias.h Sun Apr  6 15:25:17 2008
@@ -44,6 +44,10 @@
 
   Use Aliasee;
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
   /// GlobalAlias ctor - If a parent module is specified, the alias is
   /// automatically inserted into the end of the specified module's alias list.
   GlobalAlias(const Type *Ty, LinkageTypes Linkage, const std::string &Name = "",

Modified: llvm/trunk/include/llvm/GlobalVariable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalVariable.h?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/include/llvm/GlobalVariable.h (original)
+++ llvm/trunk/include/llvm/GlobalVariable.h Sun Apr  6 15:25:17 2008
@@ -32,6 +32,7 @@
 
 class GlobalVariable : public GlobalValue {
   friend class SymbolTableListTraits<GlobalVariable, Module>;
+  void *operator new(size_t, unsigned);       // Do not implement
   void operator=(const GlobalVariable &);     // Do not implement
   GlobalVariable(const GlobalVariable &);     // Do not implement
 
@@ -46,6 +47,10 @@
   Use Initializer;
 
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
   /// GlobalVariable ctor - If a parent module is specified, the global is
   /// automatically inserted into the end of the specified modules global list.
   GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage,

Modified: llvm/trunk/include/llvm/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/include/llvm/InstrTypes.h (original)
+++ llvm/trunk/include/llvm/InstrTypes.h Sun Apr  6 15:25:17 2008
@@ -83,6 +83,7 @@
 //===----------------------------------------------------------------------===//
 
 class UnaryInstruction : public Instruction {
+  void *operator new(size_t, unsigned); // Do not implement
   Use Op;
   
   // avoiding warning: 'this' : used in base member initializer list
@@ -95,6 +96,11 @@
     : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this_()) {
   }
 public:
+  // allocate space for exactly one operand
+  void *operator new(size_t s) {
+    return User::operator new(s, 1);
+  }
+
   // Out of line virtual method, so the vtable, etc has a home.
   ~UnaryInstruction();
 
@@ -129,6 +135,7 @@
 //===----------------------------------------------------------------------===//
 
 class BinaryOperator : public Instruction {
+  void *operator new(size_t, unsigned); // Do not implement
   Use Ops[2];
 protected:
   void init(BinaryOps iType);
@@ -137,6 +144,10 @@
   BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
                  const std::string &Name, BasicBlock *InsertAtEnd);
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
 
   /// Transparently provide more efficient getOperand methods.
   Value *getOperand(unsigned i) const {
@@ -489,6 +500,7 @@
 /// This class is the base class for the comparison instructions. 
 /// @brief Abstract base class of comparison instructions.
 class CmpInst: public Instruction {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   CmpInst(); // do not implement
 protected:
   CmpInst(Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS,
@@ -500,6 +512,10 @@
   Use Ops[2]; // CmpInst instructions always have 2 operands, optimize
 
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
   /// Construct a compare instruction, given the opcode, the predicate and 
   /// the two operands.  Optionally (if InstBefore is specified) insert the 
   /// instruction into a BasicBlock right before the specified instruction.  

Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Sun Apr  6 15:25:17 2008
@@ -45,7 +45,7 @@
   AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
                  const std::string &Name, BasicBlock *InsertAtEnd);
 public:
-  // Out of line virtual method, so the vtable, etc has a home.
+  // Out of line virtual method, so the vtable, etc. has a home.
   virtual ~AllocationInst();
 
   /// isArrayAllocation - Return true if there is an allocation size parameter
@@ -287,6 +287,7 @@
 /// StoreInst - an instruction for storing to memory
 ///
 class StoreInst : public Instruction {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[2];
   
   StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, Ops, 2) {
@@ -301,6 +302,10 @@
   }
   void AssertOK();
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
   StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
   StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
   StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
@@ -438,7 +443,6 @@
     }
   }
 
-public:
   /// Constructors - Create a getelementptr instruction with a base pointer an
   /// list of indices.  The first ctor can optionally insert before an existing
   /// instruction, the second appends the new instruction to the specified
@@ -447,7 +451,7 @@
   GetElementPtrInst(Value *Ptr, InputIterator IdxBegin, 
                     InputIterator IdxEnd,
                     const std::string &Name = "",
-                    Instruction *InsertBefore =0)
+                    Instruction *InsertBefore = 0)
       : Instruction(PointerType::get(
                       checkType(getIndexedType(Ptr->getType(),
                                                IdxBegin, IdxEnd, true)),
@@ -471,9 +475,33 @@
   /// Constructors - These two constructors are convenience methods because one
   /// and two index getelementptr instructions are so common.
   GetElementPtrInst(Value *Ptr, Value *Idx,
-                    const std::string &Name = "", Instruction *InsertBefore =0);
+                    const std::string &Name = "", Instruction *InsertBefore = 0);
   GetElementPtrInst(Value *Ptr, Value *Idx,
                     const std::string &Name, BasicBlock *InsertAtEnd);
+public:
+  template<typename InputIterator>
+  static GetElementPtrInst *Create(Value *Ptr, InputIterator IdxBegin, 
+                                   InputIterator IdxEnd,
+                                   const std::string &Name = "",
+                                   Instruction *InsertBefore = 0) {
+    return new(0/*FIXME*/) GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Name, InsertBefore);
+  }
+  template<typename InputIterator>
+  static GetElementPtrInst *Create(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd,
+                                   const std::string &Name, BasicBlock *InsertAtEnd) {
+    return new(0/*FIXME*/) GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Name, InsertAtEnd);
+  }
+
+  /// Constructors - These two constructors are convenience methods because one
+  /// and two index getelementptr instructions are so common.
+  static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
+                                   const std::string &Name = "", Instruction *InsertBefore = 0) {
+    return new(2/*FIXME*/) GetElementPtrInst(Ptr, Idx, Name, InsertBefore);
+  }
+  static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
+                                   const std::string &Name, BasicBlock *InsertAtEnd) {
+    return new(2/*FIXME*/) GetElementPtrInst(Ptr, Idx, Name, InsertAtEnd);
+  }
   ~GetElementPtrInst();
 
   virtual GetElementPtrInst *clone() const;
@@ -866,7 +894,6 @@
     setName(Name);
   }
 
-public:
   /// Construct a CallInst given a range of arguments.  InputIterator
   /// must be a random-access iterator pointing to contiguous storage
   /// (e.g. a std::vector<>::iterator).  Checks are made for
@@ -906,6 +933,33 @@
   explicit CallInst(Value *F, const std::string &Name = "",
                     Instruction *InsertBefore = 0);
   CallInst(Value *F, const std::string &Name, BasicBlock *InsertAtEnd);
+public:
+  template<typename InputIterator>
+  static CallInst *Create(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
+                          const std::string &Name = "", Instruction *InsertBefore = 0) {
+    return new(ArgEnd - ArgBegin + 1) CallInst(Func, ArgBegin, ArgEnd, Name, InsertBefore);
+  }
+  template<typename InputIterator>
+  static CallInst *Create(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
+                          const std::string &Name, BasicBlock *InsertAtEnd) {
+    return new(ArgEnd - ArgBegin + 1) CallInst(Func, ArgBegin, ArgEnd, Name, InsertAtEnd);
+  }
+  static CallInst *Create(Value *F, Value *Actual, const std::string& Name = "",
+                          Instruction *InsertBefore = 0) {
+    return new(2) CallInst(F, Actual, Name, InsertBefore);
+  }
+  static CallInst *Create(Value *F, Value *Actual, const std::string& Name,
+                          BasicBlock *InsertAtEnd) {
+    return new(2) CallInst(F, Actual, Name, InsertAtEnd);
+  }
+  static CallInst *Create(Value *F, const std::string &Name = "",
+                          Instruction *InsertBefore = 0) {
+    return new(1) CallInst(F, Name, InsertBefore);
+  }
+  static CallInst *Create(Value *F, const std::string &Name, BasicBlock *InsertAtEnd) {
+    return new(1) CallInst(F, Name, InsertAtEnd);
+  }
+
   ~CallInst();
 
   virtual CallInst *clone() const;
@@ -1011,7 +1065,6 @@
     : Instruction(SI.getType(), SI.getOpcode(), Ops, 3) {
     init(SI.Ops[0], SI.Ops[1], SI.Ops[2]);
   }
-public:
   SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
              Instruction *InsertBefore = 0)
     : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertBefore) {
@@ -1024,6 +1077,15 @@
     init(C, S1, S2);
     setName(Name);
   }
+public:
+  static SelectInst *Create(Value *C, Value *S1, Value *S2, const std::string &Name = "",
+             Instruction *InsertBefore = 0) {
+    return new(3) SelectInst(C, S1, S2, Name, InsertBefore);
+  }
+  static SelectInst *Create(Value *C, Value *S1, Value *S2, const std::string &Name,
+             BasicBlock *InsertAtEnd) {
+    return new(3) SelectInst(C, S1, S2, Name, InsertAtEnd);
+  }
 
   Value *getCondition() const { return Ops[0]; }
   Value *getTrueValue() const { return Ops[1]; }
@@ -1106,6 +1168,10 @@
   }
 
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2); // FIXME: unsigned Idx forms of constructor?
+  }
   ExtractElementInst(Value *Vec, Value *Idx, const std::string &Name = "",
                      Instruction *InsertBefore = 0);
   ExtractElementInst(Value *Vec, unsigned Idx, const std::string &Name = "",
@@ -1152,7 +1218,6 @@
 class InsertElementInst : public Instruction {
   Use Ops[3];
   InsertElementInst(const InsertElementInst &IE);
-public:
   InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
                     const std::string &Name = "",Instruction *InsertBefore = 0);
   InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
@@ -1161,6 +1226,26 @@
                     const std::string &Name, BasicBlock *InsertAtEnd);
   InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
                     const std::string &Name, BasicBlock *InsertAtEnd);
+public:
+  static InsertElementInst *Create(const InsertElementInst &IE) {
+    return new(IE.getNumOperands()) InsertElementInst(IE);
+  }
+  static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
+                                   const std::string &Name = "",Instruction *InsertBefore = 0) {
+    return new(3) InsertElementInst(Vec, NewElt, Idx, Name, InsertBefore);
+  }
+  static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx,
+                                   const std::string &Name = "",Instruction *InsertBefore = 0) {
+    return new(3/*FIXME*/) InsertElementInst(Vec, NewElt, Idx, Name, InsertBefore);
+  }
+  static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
+                                   const std::string &Name, BasicBlock *InsertAtEnd) {
+    return new(3) InsertElementInst(Vec, NewElt, Idx, Name, InsertAtEnd);
+  }
+  static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx,
+                                   const std::string &Name, BasicBlock *InsertAtEnd) {
+    return new(3/*FIXME*/) InsertElementInst(Vec, NewElt, Idx, Name, InsertAtEnd);
+  }
 
   /// isValidOperands - Return true if an insertelement instruction can be
   /// formed with the specified operands.
@@ -1207,6 +1292,10 @@
   Use Ops[3];
   ShuffleVectorInst(const ShuffleVectorInst &IE);
 public:
+  // allocate space for exactly three operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 3);
+  }
   ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
                     const std::string &Name = "", Instruction *InsertBefor = 0);
   ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
@@ -1265,11 +1354,15 @@
 // scientist's overactive imagination.
 //
 class PHINode : public Instruction {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   /// ReservedSpace - The number of operands actually allocated.  NumOperands is
   /// the number actually in use.
   unsigned ReservedSpace;
   PHINode(const PHINode &PN);
-public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
   explicit PHINode(const Type *Ty, const std::string &Name = "",
                    Instruction *InsertBefore = 0)
     : Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore),
@@ -1282,7 +1375,14 @@
       ReservedSpace(0) {
     setName(Name);
   }
-
+public:
+  static PHINode *Create(const Type *Ty, const std::string &Name = "",
+                         Instruction *InsertBefore = 0) {
+    return new PHINode(Ty, Name, InsertBefore);
+  }
+  static PHINode *Create(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) {
+    return new PHINode(Ty, Name, InsertAtEnd);
+  }
   ~PHINode();
 
   /// reserveOperandSpace - This method can be used to avoid repeated
@@ -1401,7 +1501,7 @@
   ReturnInst(const ReturnInst &RI);
   void init(Value * const* retVals, unsigned N);
 
-public:
+private:
   // ReturnInst constructors:
   // ReturnInst()                  - 'ret void' instruction
   // ReturnInst(    null)          - 'ret void' instruction
@@ -1422,6 +1522,25 @@
   ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore);
   ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd);
   explicit ReturnInst(BasicBlock *InsertAtEnd);
+public:
+  static ReturnInst* Create(Value *retVal = 0, Instruction *InsertBefore = 0) {
+    return new(!!retVal) ReturnInst(retVal, InsertBefore);
+  }
+  static ReturnInst* Create(Value *retVal, BasicBlock *InsertAtEnd) {
+    return new(!!retVal) ReturnInst(retVal, InsertAtEnd);
+  }
+  static ReturnInst* Create(Value * const* retVals, unsigned N) {
+    return new(N) ReturnInst(retVals, N);
+  }
+  static ReturnInst* Create(Value * const* retVals, unsigned N, Instruction *InsertBefore) {
+    return new(N) ReturnInst(retVals, N, InsertBefore);
+  }
+  static ReturnInst* Create(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd) {
+    return new(N) ReturnInst(retVals, N, InsertAtEnd);
+  }
+  static ReturnInst* Create(BasicBlock *InsertAtEnd) {
+    return new(0) ReturnInst(InsertAtEnd);
+  }
   virtual ~ReturnInst();
 
   virtual ReturnInst *clone() const;
@@ -1467,7 +1586,6 @@
   Use Ops[3];
   BranchInst(const BranchInst &BI);
   void AssertOK();
-public:
   // BranchInst constructors (where {B, T, F} are blocks, and C is a condition):
   // BranchInst(BB *B)                           - 'br B'
   // BranchInst(BB* T, BB *F, Value *C)          - 'br C, T, F'
@@ -1481,6 +1599,21 @@
   BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd);
   BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
              BasicBlock *InsertAtEnd);
+public:
+  static BranchInst *Create(BasicBlock *IfTrue, Instruction *InsertBefore = 0) {
+    return new(1) BranchInst(IfTrue, InsertBefore);
+  }
+  static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
+                            Instruction *InsertBefore = 0) {
+    return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertBefore);
+  }
+  static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) {
+    return new(1) BranchInst(IfTrue, InsertAtEnd);
+  }
+  static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
+                            BasicBlock *InsertAtEnd) {
+    return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertAtEnd);
+  }
 
   /// Transparently provide more efficient getOperand methods.
   Value *getOperand(unsigned i) const {
@@ -1561,7 +1694,6 @@
   SwitchInst(const SwitchInst &RI);
   void init(Value *Value, BasicBlock *Default, unsigned NumCases);
   void resizeOperands(unsigned No);
-public:
   /// SwitchInst ctor - Create a new switch instruction, specifying a value to
   /// switch on and a default destination.  The number of additional cases can
   /// be specified here to make memory allocation more efficient.  This
@@ -1575,9 +1707,17 @@
   /// constructor also autoinserts at the end of the specified BasicBlock.
   SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
              BasicBlock *InsertAtEnd);
+public:
+  static SwitchInst *Create(Value *Value, BasicBlock *Default, unsigned NumCases,
+                            Instruction *InsertBefore = 0) {
+    return new(NumCases/*FIXME*/) SwitchInst(Value, Default, NumCases, InsertBefore);
+  }
+  static SwitchInst *Create(Value *Value, BasicBlock *Default, unsigned NumCases,
+                            BasicBlock *InsertAtEnd) {
+    return new(NumCases/*FIXME*/) SwitchInst(Value, Default, NumCases, InsertAtEnd);
+  }
   ~SwitchInst();
 
-
   // Accessor Methods for Switch stmt
   Value *getCondition() const { return getOperand(0); }
   void setCondition(Value *V) { setOperand(0, V); }
@@ -1703,7 +1843,6 @@
     setName(Name);
   }
 
-public:
   /// Construct an InvokeInst given a range of arguments.
   /// InputIterator must be a random-access iterator pointing to
   /// contiguous storage (e.g. a std::vector<>::iterator).  Checks are
@@ -1739,6 +1878,19 @@
     init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name,
          typename std::iterator_traits<InputIterator>::iterator_category());
   }
+public:
+  template<typename InputIterator>
+  static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
+                            InputIterator ArgBegin, InputIterator ArgEnd,
+                            const std::string &Name = "", Instruction *InsertBefore = 0) {
+    return new(ArgEnd - ArgBegin + 3) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, InsertBefore);
+  }
+  template<typename InputIterator>
+  static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
+                            InputIterator ArgBegin, InputIterator ArgEnd,
+                            const std::string &Name, BasicBlock *InsertAtEnd) {
+    return new(ArgEnd - ArgBegin + 3) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, InsertAtEnd);
+  }
 
   ~InvokeInst();
 
@@ -1856,7 +2008,12 @@
 /// until an invoke instruction is found.
 ///
 class UnwindInst : public TerminatorInst {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
   explicit UnwindInst(Instruction *InsertBefore = 0);
   explicit UnwindInst(BasicBlock *InsertAtEnd);
 
@@ -1888,7 +2045,12 @@
 /// end of the block cannot be reached.
 ///
 class UnreachableInst : public TerminatorInst {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
   explicit UnreachableInst(Instruction *InsertBefore = 0);
   explicit UnreachableInst(BasicBlock *InsertAtEnd);
 
@@ -2388,7 +2550,8 @@
 /// GetResultInst - This instruction extracts individual result value from
 /// aggregate value, where aggregate value is returned by CallInst.
 ///
-class GetResultInst : public Instruction {
+class GetResultInst : public /*FIXME: Unary*/Instruction {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Aggr;
   unsigned Idx;
   GetResultInst(const GetResultInst &GRI) :
@@ -2398,6 +2561,10 @@
   }
 
 public:
+  // allocate space for exactly one operand
+  void *operator new(size_t s) {
+    return User::operator new(s, 1);
+  }
   explicit GetResultInst(Value *Aggr, unsigned index,
                          const std::string &Name = "",
                          Instruction *InsertBefore = 0);

Modified: llvm/trunk/include/llvm/Support/LLVMBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LLVMBuilder.h?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/LLVMBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/LLVMBuilder.h Sun Apr  6 15:25:17 2008
@@ -87,32 +87,32 @@
 
   /// CreateRetVoid - Create a 'ret void' instruction.
   ReturnInst *CreateRetVoid() {
-    return Insert(new ReturnInst());
+    return Insert(ReturnInst::Create());
   }
 
   /// @verbatim 
   /// CreateRet - Create a 'ret <val>' instruction. 
   /// @endverbatim
   ReturnInst *CreateRet(Value *V) {
-    return Insert(new ReturnInst(V));
+    return Insert(ReturnInst::Create(V));
   }
   
   /// CreateBr - Create an unconditional 'br label X' instruction.
   BranchInst *CreateBr(BasicBlock *Dest) {
-    return Insert(new BranchInst(Dest));
+    return Insert(BranchInst::Create(Dest));
   }
 
   /// CreateCondBr - Create a conditional 'br Cond, TrueDest, FalseDest'
   /// instruction.
   BranchInst *CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False) {
-    return Insert(new BranchInst(True, False, Cond));
+    return Insert(BranchInst::Create(True, False, Cond));
   }
   
   /// CreateSwitch - Create a switch instruction with the specified value,
   /// default dest, and with a hint for the number of cases that will be added
   /// (for efficient allocation).
   SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10) {
-    return Insert(new SwitchInst(V, Dest, NumCases));
+    return Insert(SwitchInst::Create(V, Dest, NumCases));
   }
   
   /// CreateInvoke - Create an invoke instruction.
@@ -120,8 +120,8 @@
   InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, 
                            BasicBlock *UnwindDest, InputIterator ArgBegin, 
                            InputIterator ArgEnd, const char *Name = "") {
-    return(Insert(new InvokeInst(Callee, NormalDest, UnwindDest,
-                                 ArgBegin, ArgEnd, Name)));
+    return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest,
+                                     ArgBegin, ArgEnd, Name));
   }
   
   UnwindInst *CreateUnwind() {
@@ -221,10 +221,10 @@
   template<typename InputIterator>
   GetElementPtrInst *CreateGEP(Value *Ptr, InputIterator IdxBegin, 
                                InputIterator IdxEnd, const char *Name = "") {
-    return(Insert(new GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Name)));
+    return(Insert(GetElementPtrInst::Create(Ptr, IdxBegin, IdxEnd, Name)));
   }
   GetElementPtrInst *CreateGEP(Value *Ptr, Value *Idx, const char *Name = "") {
-    return Insert(new GetElementPtrInst(Ptr, Idx, Name));
+    return Insert(GetElementPtrInst::Create(Ptr, Idx, Name));
   }
   GetElementPtrInst *CreateStructGEP(Value *Ptr, unsigned Idx, 
                                      const char *Name = "") {
@@ -232,7 +232,7 @@
       ConstantInt::get(llvm::Type::Int32Ty, 0),
       ConstantInt::get(llvm::Type::Int32Ty, Idx)
     };
-    return Insert(new GetElementPtrInst(Ptr, Idxs, Idxs+2, Name));
+    return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2, Name));
   }
   
   //===--------------------------------------------------------------------===//
@@ -384,25 +384,25 @@
   //===--------------------------------------------------------------------===//
   
   PHINode *CreatePHI(const Type *Ty, const char *Name = "") {
-    return Insert(new PHINode(Ty, Name));
+    return Insert(PHINode::Create(Ty, Name));
   }
 
   CallInst *CreateCall(Value *Callee, const char *Name = "") {
-    return Insert(new CallInst(Callee, Name));
+    return Insert(CallInst::Create(Callee, Name));
   }
   CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") {
-    return Insert(new CallInst(Callee, Arg, Name));
+    return Insert(CallInst::Create(Callee, Arg, Name));
   }
 
   template<typename InputIterator>
   CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, 
                        InputIterator ArgEnd, const char *Name = "") {
-    return(Insert(new CallInst(Callee, ArgBegin, ArgEnd, Name)));
+    return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd, Name));
   }
   
   SelectInst *CreateSelect(Value *C, Value *True, Value *False,
                            const char *Name = "") {
-    return Insert(new SelectInst(C, True, False, Name));
+    return Insert(SelectInst::Create(C, True, False, Name));
   }
   
   VAArgInst *CreateVAArg(Value *List, const Type *Ty, const char *Name = "") {
@@ -416,7 +416,7 @@
   
   InsertElementInst *CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx,
                                          const char *Name = "") {
-    return Insert(new InsertElementInst(Vec, NewElt, Idx, Name));
+    return Insert(InsertElementInst::Create(Vec, NewElt, Idx, Name));
   }
   
   ShuffleVectorInst *CreateShuffleVector(Value *V1, Value *V2, Value *Mask,

Modified: llvm/trunk/include/llvm/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/User.h?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/include/llvm/User.h (original)
+++ llvm/trunk/include/llvm/User.h Sun Apr  6 15:25:17 2008
@@ -25,6 +25,7 @@
 
 class User : public Value {
   User(const User &);             // Do not implement
+  void *operator new(size_t);     // Do not implement
 protected:
   /// OperandList - This is a pointer to the array of Users for this operand.
   /// For nodes of fixed arity (e.g. a binary operator) this array will live
@@ -38,10 +39,13 @@
   ///
   unsigned NumOperands;
 
-public:
+  void *operator new(size_t s, unsigned) {
+    return ::operator new(s);
+  }
   User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
     : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {}
 
+public:
   Value *getOperand(unsigned i) const {
     assert(i < NumOperands && "getOperand() out of range!");
     return OperandList[i];

Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Sun Apr  6 15:25:17 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/trunk/lib/AsmParser/llvmAsmParser.y
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Sun Apr  6 15:25:17 2008
@@ -493,7 +493,7 @@
    }
    const Type* ElTy = PTy->getElementType();
    if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
-     V = new Function(FTy, GlobalValue::ExternalLinkage);
+     V = Function::Create(FTy, GlobalValue::ExternalLinkage);
    else
      V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
                             (Module*)0, false, PTy->getAddressSpace());
@@ -551,7 +551,7 @@
     // We haven't seen this BB before and its first mention is a definition. 
     // Just create it and return it.
     std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
-    BB = new BasicBlock(Name, CurFun.CurrentFunction);
+    BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
     if (ID.Type == ValID::LocalID) {
       assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
       InsertValue(BB);
@@ -607,7 +607,7 @@
   std::string Name;
   if (ID.Type == ValID::LocalName)
     Name = ID.getName();
-  BB = new BasicBlock(Name, CurFun.CurrentFunction);
+  BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
 
   // Insert it in the forward refs map.
   CurFun.BBForwardRefs[ID] = BB;
@@ -1779,8 +1779,8 @@
         GlobalValue *GV;
         if (const FunctionType *FTy = 
                  dyn_cast<FunctionType>(PT->getElementType())) {
-          GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
-                            CurModule.CurrentModule);
+          GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
+                                CurModule.CurrentModule);
         } else {
           GV = new GlobalVariable(PT->getElementType(), false,
                                   GlobalValue::ExternalWeakLinkage, 0,
@@ -2319,8 +2319,8 @@
         AI->setName("");
     }
   } else  {  // Not already defined?
-    Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
-                      CurModule.CurrentModule);
+    Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
+                          CurModule.CurrentModule);
     InsertValue(Fn, CurModule.Values);
   }
 
@@ -2579,18 +2579,18 @@
   RET ReturnedVal  { // Return with a result...
     ValueList &VL = *$2;
     assert(!VL.empty() && "Invalid ret operands!");
-    $$ = new ReturnInst(&VL[0], VL.size());
+    $$ = ReturnInst::Create(&VL[0], VL.size());
     delete $2;
     CHECK_FOR_ERROR
   }
   | RET VOID {                                    // Return with no result...
-    $$ = new ReturnInst();
+    $$ = ReturnInst::Create();
     CHECK_FOR_ERROR
   }
   | BR LABEL ValueRef {                           // Unconditional Branch...
     BasicBlock* tmpBB = getBBVal($3);
     CHECK_FOR_ERROR
-    $$ = new BranchInst(tmpBB);
+    $$ = BranchInst::Create(tmpBB);
   }                                               // Conditional Branch...
   | BR INTTYPE ValueRef ',' LABEL ValueRef ',' LABEL ValueRef {  
     assert(cast<IntegerType>($2)->getBitWidth() == 1 && "Not Bool?");
@@ -2600,14 +2600,14 @@
     CHECK_FOR_ERROR
     Value* tmpVal = getVal(Type::Int1Ty, $3);
     CHECK_FOR_ERROR
-    $$ = new BranchInst(tmpBBA, tmpBBB, tmpVal);
+    $$ = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
   }
   | SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' {
     Value* tmpVal = getVal($2, $3);
     CHECK_FOR_ERROR
     BasicBlock* tmpBB = getBBVal($6);
     CHECK_FOR_ERROR
-    SwitchInst *S = new SwitchInst(tmpVal, tmpBB, $8->size());
+    SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, $8->size());
     $$ = S;
 
     std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = $8->begin(),
@@ -2626,7 +2626,7 @@
     CHECK_FOR_ERROR
     BasicBlock* tmpBB = getBBVal($6);
     CHECK_FOR_ERROR
-    SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
+    SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
     $$ = S;
     CHECK_FOR_ERROR
   }
@@ -2704,7 +2704,7 @@
       PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
 
     // Create the InvokeInst
-    InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(),Args.end());
+    InvokeInst *II = InvokeInst::Create(V, Normal, Except, Args.begin(),Args.end());
     II->setCallingConv($2);
     II->setParamAttrs(PAL);
     $$ = II;
@@ -2911,7 +2911,7 @@
       GEN_ERROR("select condition must be boolean");
     if ($4->getType() != $6->getType())
       GEN_ERROR("select value types should match");
-    $$ = new SelectInst($2, $4, $6);
+    $$ = SelectInst::Create($2, $4, $6);
     CHECK_FOR_ERROR
   }
   | VAARG ResolvedVal ',' Types {
@@ -2930,7 +2930,7 @@
   | INSERTELEMENT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
     if (!InsertElementInst::isValidOperands($2, $4, $6))
       GEN_ERROR("Invalid insertelement operands");
-    $$ = new InsertElementInst($2, $4, $6);
+    $$ = InsertElementInst::Create($2, $4, $6);
     CHECK_FOR_ERROR
   }
   | SHUFFLEVECTOR ResolvedVal ',' ResolvedVal ',' ResolvedVal {
@@ -2943,7 +2943,7 @@
     const Type *Ty = $2->front().first->getType();
     if (!Ty->isFirstClassType())
       GEN_ERROR("PHI node operands must be of first class type");
-    $$ = new PHINode(Ty);
+    $$ = PHINode::Create(Ty);
     ((PHINode*)$$)->reserveOperandSpace($2->size());
     while ($2->begin() != $2->end()) {
       if ($2->front().first->getType() != Ty) 
@@ -3031,7 +3031,7 @@
       PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
 
     // Create the call node
-    CallInst *CI = new CallInst(V, Args.begin(), Args.end());
+    CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
     CI->setTailCall($1);
     CI->setCallingConv($2);
     CI->setParamAttrs(PAL);
@@ -3144,7 +3144,7 @@
                      (*$2)->getDescription()+ "'");
     Value* tmpVal = getVal(*$2, $3);
     CHECK_FOR_ERROR
-    $$ = new GetElementPtrInst(tmpVal, $4->begin(), $4->end());
+    $$ = GetElementPtrInst::Create(tmpVal, $4->begin(), $4->end());
     delete $2; 
     delete $4;
   };

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sun Apr  6 15:25:17 2008
@@ -122,8 +122,12 @@
   class ConstantPlaceHolder : public ConstantExpr {
     ConstantPlaceHolder();                       // DO NOT IMPLEMENT
     void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT
-  public:
     Use Op;
+  public:
+    // allocate space for exactly one operand
+    void *operator new(size_t s) {
+      return User::operator new(s, 1);
+    }
     explicit ConstantPlaceHolder(const Type *Ty)
       : ConstantExpr(Ty, Instruction::UserOp1, &Op, 1),
         Op(UndefValue::get(Type::Int32Ty), this) {
@@ -1046,8 +1050,8 @@
       if (!FTy)
         return Error("Function not a pointer to function type!");
 
-      Function *Func = new Function(FTy, GlobalValue::ExternalLinkage,
-                                    "", TheModule);
+      Function *Func = Function::Create(FTy, GlobalValue::ExternalLinkage,
+                                        "", TheModule);
 
       Func->setCallingConv(Record[1]);
       bool isProto = Record[2];
@@ -1216,7 +1220,7 @@
       // Create all the basic blocks for the function.
       FunctionBBs.resize(Record[0]);
       for (unsigned i = 0, e = FunctionBBs.size(); i != e; ++i)
-        FunctionBBs[i] = new BasicBlock("", F);
+        FunctionBBs[i] = BasicBlock::Create("", F);
       CurBB = FunctionBBs[0];
       continue;
       
@@ -1270,7 +1274,7 @@
         GEPIdx.push_back(Op);
       }
 
-      I = new GetElementPtrInst(BasePtr, GEPIdx.begin(), GEPIdx.end());
+      I = GetElementPtrInst::Create(BasePtr, GEPIdx.begin(), GEPIdx.end());
       break;
     }
       
@@ -1282,7 +1286,7 @@
           getValue(Record, OpNum, Type::Int1Ty, Cond))
         return Error("Invalid SELECT record");
       
-      I = new SelectInst(Cond, TrueVal, FalseVal);
+      I = SelectInst::Create(Cond, TrueVal, FalseVal);
       break;
     }
       
@@ -1304,7 +1308,7 @@
                    cast<VectorType>(Vec->getType())->getElementType(), Elt) ||
           getValue(Record, OpNum, Type::Int32Ty, Idx))
         return Error("Invalid INSERTELT record");
-      I = new InsertElementInst(Vec, Elt, Idx);
+      I = InsertElementInst::Create(Vec, Elt, Idx);
       break;
     }
       
@@ -1354,7 +1358,7 @@
       {
         unsigned Size = Record.size();
         if (Size == 0) {
-          I = new ReturnInst();
+          I = ReturnInst::Create();
           break;
         } else {
           unsigned OpNum = 0;
@@ -1367,7 +1371,7 @@
           } while(OpNum != Record.size());
 
           // SmallVector Vs has at least one element.
-          I = new ReturnInst(&Vs[0], Vs.size());
+          I = ReturnInst::Create(&Vs[0], Vs.size());
           break;
         }
       }
@@ -1379,13 +1383,13 @@
         return Error("Invalid BR record");
 
       if (Record.size() == 1)
-        I = new BranchInst(TrueDest);
+        I = BranchInst::Create(TrueDest);
       else {
         BasicBlock *FalseDest = getBasicBlock(Record[1]);
         Value *Cond = getFnValueByID(Record[2], Type::Int1Ty);
         if (FalseDest == 0 || Cond == 0)
           return Error("Invalid BR record");
-        I = new BranchInst(TrueDest, FalseDest, Cond);
+        I = BranchInst::Create(TrueDest, FalseDest, Cond);
       }
       break;
     }
@@ -1398,7 +1402,7 @@
       if (OpTy == 0 || Cond == 0 || Default == 0)
         return Error("Invalid SWITCH record");
       unsigned NumCases = (Record.size()-3)/2;
-      SwitchInst *SI = new SwitchInst(Cond, Default, NumCases);
+      SwitchInst *SI = SwitchInst::Create(Cond, Default, NumCases);
       for (unsigned i = 0, e = NumCases; i != e; ++i) {
         ConstantInt *CaseVal = 
           dyn_cast_or_null<ConstantInt>(getFnValueByID(Record[3+i*2], OpTy));
@@ -1454,7 +1458,7 @@
         }
       }
       
-      I = new InvokeInst(Callee, NormalBB, UnwindBB, Ops.begin(), Ops.end());
+      I = InvokeInst::Create(Callee, NormalBB, UnwindBB, Ops.begin(), Ops.end());
       cast<InvokeInst>(I)->setCallingConv(CCInfo);
       cast<InvokeInst>(I)->setParamAttrs(PAL);
       break;
@@ -1471,7 +1475,7 @@
       const Type *Ty = getTypeByID(Record[0]);
       if (!Ty) return Error("Invalid PHI record");
       
-      PHINode *PN = new PHINode(Ty);
+      PHINode *PN = PHINode::Create(Ty);
       PN->reserveOperandSpace(Record.size()-1);
       
       for (unsigned i = 0, e = Record.size()-1; i != e; i += 2) {
@@ -1591,7 +1595,7 @@
         }
       }
       
-      I = new CallInst(Callee, Args.begin(), Args.end());
+      I = CallInst::Create(Callee, Args.begin(), Args.end());
       cast<CallInst>(I)->setCallingConv(CCInfo>>1);
       cast<CallInst>(I)->setTailCall(CCInfo & 1);
       cast<CallInst>(I)->setParamAttrs(PAL);

Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Sun Apr  6 15:25:17 2008
@@ -55,8 +55,8 @@
   }
 
   SmallVector<Value *, 8> Args(ArgBegin, ArgEnd);
-  CallInst *NewCI = new CallInst(FCache, Args.begin(), Args.end(),
-                                 CI->getName(), CI);
+  CallInst *NewCI = CallInst::Create(FCache, Args.begin(), Args.end(),
+                                     CI->getName(), CI);
   if (!CI->use_empty())
     CI->replaceAllUsesWith(NewCI);
   return NewCI;
@@ -339,19 +339,19 @@
     Function::arg_iterator args = F->arg_begin();
     Value* Val = args++; Val->setName("Val");
     Value* Lo = args++; Lo->setName("Lo");
-    Value* Hi  = args++; Hi->setName("High");
+    Value* Hi = args++; Hi->setName("High");
 
     // We want to select a range of bits here such that [Hi, Lo] is shifted
     // down to the low bits. However, it is quite possible that Hi is smaller
     // than Lo in which case the bits have to be reversed. 
     
     // Create the blocks we will need for the two cases (forward, reverse)
-    BasicBlock* CurBB   = new BasicBlock("entry", F);
-    BasicBlock *RevSize = new BasicBlock("revsize", CurBB->getParent());
-    BasicBlock *FwdSize = new BasicBlock("fwdsize", CurBB->getParent());
-    BasicBlock *Compute = new BasicBlock("compute", CurBB->getParent());
-    BasicBlock *Reverse = new BasicBlock("reverse", CurBB->getParent());
-    BasicBlock *RsltBlk = new BasicBlock("result",  CurBB->getParent());
+    BasicBlock* CurBB   = BasicBlock::Create("entry", F);
+    BasicBlock *RevSize = BasicBlock::Create("revsize", CurBB->getParent());
+    BasicBlock *FwdSize = BasicBlock::Create("fwdsize", CurBB->getParent());
+    BasicBlock *Compute = BasicBlock::Create("compute", CurBB->getParent());
+    BasicBlock *Reverse = BasicBlock::Create("reverse", CurBB->getParent());
+    BasicBlock *RsltBlk = BasicBlock::Create("result",  CurBB->getParent());
 
     // Cast Hi and Lo to the size of Val so the widths are all the same
     if (Hi->getType() != Val->getType())
@@ -369,17 +369,17 @@
     // Compare the Hi and Lo bit positions. This is used to determine 
     // which case we have (forward or reverse)
     ICmpInst *Cmp = new ICmpInst(ICmpInst::ICMP_ULT, Hi, Lo, "less",CurBB);
-    new BranchInst(RevSize, FwdSize, Cmp, CurBB);
+    BranchInst::Create(RevSize, FwdSize, Cmp, CurBB);
 
     // First, copmute the number of bits in the forward case.
     Instruction* FBitSize = 
       BinaryOperator::createSub(Hi, Lo,"fbits", FwdSize);
-    new BranchInst(Compute, FwdSize);
+    BranchInst::Create(Compute, FwdSize);
 
     // Second, compute the number of bits in the reverse case.
     Instruction* RBitSize = 
       BinaryOperator::createSub(Lo, Hi, "rbits", RevSize);
-    new BranchInst(Compute, RevSize);
+    BranchInst::Create(Compute, RevSize);
 
     // Now, compute the bit range. Start by getting the bitsize and the shift
     // amount (either Hi or Lo) from PHI nodes. Then we compute a mask for 
@@ -389,13 +389,13 @@
     // reversed.
 
     // Get the BitSize from one of the two subtractions
-    PHINode *BitSize = new PHINode(Val->getType(), "bits", Compute);
+    PHINode *BitSize = PHINode::Create(Val->getType(), "bits", Compute);
     BitSize->reserveOperandSpace(2);
     BitSize->addIncoming(FBitSize, FwdSize);
     BitSize->addIncoming(RBitSize, RevSize);
 
     // Get the ShiftAmount as the smaller of Hi/Lo
-    PHINode *ShiftAmt = new PHINode(Val->getType(), "shiftamt", Compute);
+    PHINode *ShiftAmt = PHINode::Create(Val->getType(), "shiftamt", Compute);
     ShiftAmt->reserveOperandSpace(2);
     ShiftAmt->addIncoming(Lo, FwdSize);
     ShiftAmt->addIncoming(Hi, RevSize);
@@ -413,24 +413,24 @@
     Instruction* FRes = 
       BinaryOperator::createLShr(Val, ShiftAmt, "fres", Compute);
     FRes = BinaryOperator::createAnd(FRes, Mask, "fres", Compute);
-    new BranchInst(Reverse, RsltBlk, Cmp, Compute);
+    BranchInst::Create(Reverse, RsltBlk, Cmp, Compute);
 
     // In the Reverse block we have the mask already in FRes but we must reverse
     // it by shifting FRes bits right and putting them in RRes by shifting them 
     // in from left.
 
     // First set up our loop counters
-    PHINode *Count = new PHINode(Val->getType(), "count", Reverse);
+    PHINode *Count = PHINode::Create(Val->getType(), "count", Reverse);
     Count->reserveOperandSpace(2);
     Count->addIncoming(BitSizePlusOne, Compute);
 
     // Next, get the value that we are shifting.
-    PHINode *BitsToShift   = new PHINode(Val->getType(), "val", Reverse);
+    PHINode *BitsToShift = PHINode::Create(Val->getType(), "val", Reverse);
     BitsToShift->reserveOperandSpace(2);
     BitsToShift->addIncoming(FRes, Compute);
 
     // Finally, get the result of the last computation
-    PHINode *RRes  = new PHINode(Val->getType(), "rres", Reverse);
+    PHINode *RRes = PHINode::Create(Val->getType(), "rres", Reverse);
     RRes->reserveOperandSpace(2);
     RRes->addIncoming(Zero, Compute);
 
@@ -456,16 +456,16 @@
     // Terminate loop if we've moved all the bits.
     ICmpInst *Cond = 
       new ICmpInst(ICmpInst::ICMP_EQ, Decr, Zero, "cond", Reverse);
-    new BranchInst(RsltBlk, Reverse, Cond, Reverse);
+    BranchInst::Create(RsltBlk, Reverse, Cond, Reverse);
 
     // Finally, in the result block, select one of the two results with a PHI
     // node and return the result;
     CurBB = RsltBlk;
-    PHINode *BitSelect = new PHINode(Val->getType(), "part_select", CurBB);
+    PHINode *BitSelect = PHINode::Create(Val->getType(), "part_select", CurBB);
     BitSelect->reserveOperandSpace(2);
     BitSelect->addIncoming(FRes, Compute);
     BitSelect->addIncoming(NewRes, Reverse);
-    new ReturnInst(BitSelect, CurBB);
+    ReturnInst::Create(BitSelect, CurBB);
   }
 
   // Return a call to the implementation function
@@ -474,7 +474,7 @@
     CI->getOperand(2),
     CI->getOperand(3)
   };
-  return new CallInst(F, Args, array_endof(Args), CI->getName(), CI);
+  return CallInst::Create(F, Args, array_endof(Args), CI->getName(), CI);
 }
 
 /// Convert the llvm.part.set.iX.iY.iZ intrinsic. This intrinsic takes 
@@ -531,18 +531,18 @@
     ConstantInt* ValZero = ConstantInt::get(ValTy, 0);
 
     // Basic blocks we fill in below.
-    BasicBlock* entry = new BasicBlock("entry", F, 0);
-    BasicBlock* large = new BasicBlock("large", F, 0);
-    BasicBlock* small = new BasicBlock("small", F, 0);
-    BasicBlock* reverse = new BasicBlock("reverse", F, 0);
-    BasicBlock* result = new BasicBlock("result", F, 0);
+    BasicBlock* entry = BasicBlock::Create("entry", F, 0);
+    BasicBlock* large = BasicBlock::Create("large", F, 0);
+    BasicBlock* small = BasicBlock::Create("small", F, 0);
+    BasicBlock* reverse = BasicBlock::Create("reverse", F, 0);
+    BasicBlock* result = BasicBlock::Create("result", F, 0);
 
     // BASIC BLOCK: entry
     // First, get the number of bits that we're placing as an i32
     ICmpInst* is_forward = 
       new ICmpInst(ICmpInst::ICMP_ULT, Lo, Hi, "", entry);
-    SelectInst* Hi_pn = new SelectInst(is_forward, Hi, Lo, "", entry);
-    SelectInst* Lo_pn = new SelectInst(is_forward, Lo, Hi, "", entry);
+    SelectInst* Hi_pn = SelectInst::Create(is_forward, Hi, Lo, "", entry);
+    SelectInst* Lo_pn = SelectInst::Create(is_forward, Lo, Hi, "", entry);
     BinaryOperator* NumBits = BinaryOperator::createSub(Hi_pn, Lo_pn, "",entry);
     NumBits = BinaryOperator::createAdd(NumBits, One, "", entry);
     // Now, convert Lo and Hi to ValTy bit width
@@ -555,7 +555,7 @@
     // are replacing and deal with it.
     ICmpInst* is_large = 
       new ICmpInst(ICmpInst::ICMP_ULT, NumBits, RepBitWidth, "", entry);
-    new BranchInst(large, small, is_large, entry);
+    BranchInst::Create(large, small, is_large, entry);
 
     // BASIC BLOCK: large
     Instruction* MaskBits = 
@@ -565,10 +565,10 @@
     BinaryOperator* Mask1 = 
       BinaryOperator::createLShr(RepMask, MaskBits, "", large);
     BinaryOperator* Rep2 = BinaryOperator::createAnd(Mask1, Rep, "", large);
-    new BranchInst(small, large);
+    BranchInst::Create(small, large);
 
     // BASIC BLOCK: small
-    PHINode* Rep3 = new PHINode(RepTy, "", small);
+    PHINode* Rep3 = PHINode::Create(RepTy, "", small);
     Rep3->reserveOperandSpace(2);
     Rep3->addIncoming(Rep2, large);
     Rep3->addIncoming(Rep, entry);
@@ -577,23 +577,23 @@
       Rep4 = new ZExtInst(Rep3, ValTy, "", small);
     else if (ValBits < RepBits)
       Rep4 = new TruncInst(Rep3, ValTy, "", small);
-    new BranchInst(result, reverse, is_forward, small);
+    BranchInst::Create(result, reverse, is_forward, small);
 
     // BASIC BLOCK: reverse (reverses the bits of the replacement)
     // Set up our loop counter as a PHI so we can decrement on each iteration.
     // We will loop for the number of bits in the replacement value.
-    PHINode *Count = new PHINode(Type::Int32Ty, "count", reverse);
+    PHINode *Count = PHINode::Create(Type::Int32Ty, "count", reverse);
     Count->reserveOperandSpace(2);
     Count->addIncoming(NumBits, small);
 
     // Get the value that we are shifting bits out of as a PHI because
     // we'll change this with each iteration.
-    PHINode *BitsToShift   = new PHINode(Val->getType(), "val", reverse);
+    PHINode *BitsToShift = PHINode::Create(Val->getType(), "val", reverse);
     BitsToShift->reserveOperandSpace(2);
     BitsToShift->addIncoming(Rep4, small);
 
     // Get the result of the last computation or zero on first iteration
-    PHINode *RRes  = new PHINode(Val->getType(), "rres", reverse);
+    PHINode *RRes = PHINode::Create(Val->getType(), "rres", reverse);
     RRes->reserveOperandSpace(2);
     RRes->addIncoming(ValZero, small);
 
@@ -615,10 +615,10 @@
     
     // Terminate loop if we've moved all the bits.
     ICmpInst *Cond = new ICmpInst(ICmpInst::ICMP_EQ, Decr, Zero, "", reverse);
-    new BranchInst(result, reverse, Cond, reverse);
+    BranchInst::Create(result, reverse, Cond, reverse);
 
     // BASIC BLOCK: result
-    PHINode *Rplcmnt  = new PHINode(Val->getType(), "", result);
+    PHINode *Rplcmnt = PHINode::Create(Val->getType(), "", result);
     Rplcmnt->reserveOperandSpace(2);
     Rplcmnt->addIncoming(NewRes, reverse);
     Rplcmnt->addIncoming(Rep4, small);
@@ -630,7 +630,7 @@
     Value* t5   = BinaryOperator::createAnd(t4, Val, "", result);
     Value* t6   = BinaryOperator::createShl(Rplcmnt, Lo, "", result);
     Value* Rslt = BinaryOperator::createOr(t5, t6, "part_set", result);
-    new ReturnInst(Rslt, result);
+    ReturnInst::Create(Rslt, result);
   }
 
   // Return a call to the implementation function
@@ -640,7 +640,7 @@
     CI->getOperand(3),
     CI->getOperand(4)
   };
-  return new CallInst(F, Args, array_endof(Args), CI->getName(), CI);
+  return CallInst::Create(F, Args, array_endof(Args), CI->getName(), CI);
 }
 
 
@@ -705,7 +705,7 @@
     // cttz(x) -> ctpop(~X & (X-1))
     Value *Src = CI->getOperand(1);
     Value *NotSrc = BinaryOperator::createNot(Src, Src->getName()+".not", CI);
-    Value *SrcM1  = ConstantInt::get(Src->getType(), 1);
+    Value *SrcM1 = ConstantInt::get(Src->getType(), 1);
     SrcM1 = BinaryOperator::createSub(Src, SrcM1, "", CI);
     Src = LowerCTPOP(BinaryOperator::createAnd(NotSrc, SrcM1, "", CI), CI);
     CI->replaceAllUsesWith(Src);

Modified: llvm/trunk/lib/CodeGen/ShadowStackCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShadowStackCollector.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/ShadowStackCollector.cpp (original)
+++ llvm/trunk/lib/CodeGen/ShadowStackCollector.cpp Sun Apr  6 15:25:17 2008
@@ -133,7 +133,7 @@
           return 0;
         
         // Create a cleanup block.
-        BasicBlock *CleanupBB = new BasicBlock(CleanupBBName, &F);
+        BasicBlock *CleanupBB = BasicBlock::Create(CleanupBBName, &F);
         UnwindInst *UI = new UnwindInst(CleanupBB);
         
         // Transform the 'call' instructions into 'invoke's branching to the
@@ -155,10 +155,10 @@
           Args.clear();
           Args.append(CI->op_begin() + 1, CI->op_end());
           
-          InvokeInst *II = new InvokeInst(CI->getOperand(0),
-                                          NewBB, CleanupBB,
-                                          Args.begin(), Args.end(),
-                                          CI->getName(), CallBB);
+          InvokeInst *II = InvokeInst::Create(CI->getOperand(0),
+                                              NewBB, CleanupBB,
+                                              Args.begin(), Args.end(),
+                                              CI->getName(), CallBB);
           II->setCallingConv(CI->getCallingConv());
           II->setParamAttrs(CI->getParamAttrs());
           CI->replaceAllUsesWith(II);

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Sun Apr  6 15:25:17 2008
@@ -220,11 +220,11 @@
 
   // First, create the function.
   FunctionType *STy=FunctionType::get(RetTy, std::vector<const Type*>(), false);
-  Function *Stub = new Function(STy, Function::InternalLinkage, "",
-                                F->getParent());
+  Function *Stub = Function::Create(STy, Function::InternalLinkage, "",
+                                    F->getParent());
 
   // Insert a basic block.
-  BasicBlock *StubBB = new BasicBlock("", Stub);
+  BasicBlock *StubBB = BasicBlock::Create("", Stub);
 
   // Convert all of the GenericValue arguments over to constants.  Note that we
   // currently don't support varargs.
@@ -257,12 +257,12 @@
     Args.push_back(C);
   }
 
-  CallInst *TheCall = new CallInst(F, Args.begin(), Args.end(), "", StubBB);
+  CallInst *TheCall = CallInst::Create(F, Args.begin(), Args.end(), "", StubBB);
   TheCall->setTailCall();
   if (TheCall->getType() != Type::VoidTy)
-    new ReturnInst(TheCall, StubBB);             // Return result of the call.
+    ReturnInst::Create(TheCall, StubBB);             // Return result of the call.
   else
-    new ReturnInst(StubBB);                      // Just return void.
+    ReturnInst::Create(StubBB);                      // Just return void.
 
   // Finally, return the value returned by our nullary stub function.
   return runFunction(Stub, std::vector<GenericValue>());

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Sun Apr  6 15:25:17 2008
@@ -822,8 +822,8 @@
         // We have a definition of the same name but different type in the
         // source module. Copy the prototype to the destination and replace
         // uses of the destination's prototype with the new prototype.
-        Function *NewDF = new Function(SF->getFunctionType(), SF->getLinkage(),
-                                       SF->getName(), Dest);
+        Function *NewDF = Function::Create(SF->getFunctionType(), SF->getLinkage(),
+                                           SF->getName(), Dest);
         CopyGVAttributes(NewDF, SF);
 
         // Any uses of DF need to change to NewDF, with cast
@@ -858,8 +858,8 @@
     } else if (!DF || SF->hasInternalLinkage() || DF->hasInternalLinkage()) {
       // Function does not already exist, simply insert an function signature
       // identical to SF into the dest module.
-      Function *NewDF = new Function(SF->getFunctionType(), SF->getLinkage(),
-                                     SF->getName(), Dest);
+      Function *NewDF = Function::Create(SF->getFunctionType(), SF->getLinkage(),
+                                         SF->getName(), Dest);
       CopyGVAttributes(NewDF, SF);
 
       // If the LLVM runtime renamed the function, but it is an externally

Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Sun Apr  6 15:25:17 2008
@@ -254,7 +254,7 @@
   Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1);
   
   Value *Op = CI->getOperand(1);
-  Op = new CallInst(Int, Op, CI->getName(), CI);
+  Op = CallInst::Create(Int, Op, CI->getName(), CI);
   
   CI->replaceAllUsesWith(Op);
   CI->eraseFromParent();

Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Sun Apr  6 15:25:17 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
@@ -518,9 +518,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));
         }        
@@ -532,8 +532,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));
@@ -553,13 +553,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()));
@@ -616,9 +616,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/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Sun Apr  6 15:25:17 2008
@@ -157,7 +157,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())
@@ -187,12 +187,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())
@@ -550,7 +550,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())
@@ -602,12 +602,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())
@@ -660,7 +660,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/trunk/lib/Transforms/IPO/ExtractGV.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Sun Apr  6 15:25:17 2008
@@ -546,8 +546,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);
@@ -789,8 +789,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;
@@ -1054,8 +1054,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;
@@ -1070,8 +1070,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.
@@ -1173,13 +1173,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.
@@ -1188,21 +1188,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();
@@ -1411,7 +1410,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/trunk/lib/Transforms/IPO/IndMemRemoval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/IPO/LowerSetJmp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp Sun Apr  6 15:25:17 2008
@@ -268,7 +268,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()];
 
@@ -276,7 +276,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);
 
@@ -311,7 +311,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;
 }
 
@@ -324,7 +324,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
@@ -340,7 +340,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
@@ -348,24 +348,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);
 }
 
@@ -386,7 +386,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
@@ -428,7 +428,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);
@@ -474,9 +474,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());
 
@@ -507,15 +507,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;
@@ -525,14 +525,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/trunk/lib/Transforms/IPO/PruneEH.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PruneEH.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PruneEH.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PruneEH.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/IPO/RaiseAllocations.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Scalar/ADCE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ADCE.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ADCE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ADCE.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Scalar/GCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GCSE.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GCSE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GCSE.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Sun Apr  6 15:25:17 2008
@@ -793,8 +793,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)
@@ -1370,7 +1370,7 @@
       ConstantInt::get(Type::Int64Ty, Range.End-Range.Start),  // size
       ConstantInt::get(Type::Int32Ty, Range.Alignment)   // align
     };
-    Value *C = new CallInst(MemSetF, Ops, Ops+4, "", InsertPt);
+    Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt);
     DEBUG(cerr << "Replace stores:\n";
           for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i)
             cerr << *Range.TheStores[i];
@@ -1568,7 +1568,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/trunk/lib/Transforms/Scalar/GVNPRE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVNPRE.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNPRE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVNPRE.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sun Apr  6 15:25:17 2008
@@ -1811,8 +1811,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;
@@ -2007,8 +2007,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;
 }
@@ -2048,7 +2048,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);
@@ -2366,7 +2366,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());
     }
   }
@@ -2388,10 +2388,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);
     }
   }
   
@@ -2875,7 +2875,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;
@@ -3049,7 +3049,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);
         }
       }
   }
@@ -4021,7 +4021,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);
 }
 
 
@@ -4957,7 +4957,7 @@
         }
 
         if (Op1)
-          return new SelectInst(LHSI->getOperand(0), Op1, Op2);
+          return SelectInst::Create(LHSI->getOperand(0), Op1, Op2);
         break;
       }
   }
@@ -5257,7 +5257,7 @@
         }
 
         if (Op1)
-          return new SelectInst(LHSI->getOperand(0), Op1, Op2);
+          return SelectInst::Create(LHSI->getOperand(0), Op1, Op2);
         break;
       }
       case Instruction::Malloc:
@@ -6953,9 +6953,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);
             
@@ -7517,7 +7517,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
@@ -7540,7 +7540,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;
@@ -7601,8 +7601,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));
     }
   }
 
@@ -7699,8 +7699,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());
@@ -7740,8 +7740,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)) {
@@ -7990,7 +7990,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);
@@ -8016,7 +8016,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))
@@ -8041,7 +8041,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))
@@ -8369,7 +8369,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());
@@ -8466,8 +8466,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());
   }
@@ -8678,13 +8678,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();
@@ -8841,15 +8841,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)->
@@ -8921,7 +8921,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);
@@ -8929,7 +8929,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);
@@ -8955,7 +8955,7 @@
                            RHSVal);
   else {
     assert(isa<GetElementPtrInst>(FirstInst));
-    return new GetElementPtrInst(LHSVal, RHSVal);
+    return GetElementPtrInst::Create(LHSVal, RHSVal);
   }
 }
 
@@ -9057,8 +9057,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);
@@ -9405,8 +9405,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
@@ -9461,7 +9461,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());
       }
@@ -9519,7 +9519,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());
@@ -9562,8 +9562,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.
@@ -9874,7 +9874,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
@@ -10151,7 +10151,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);
@@ -10437,7 +10437,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/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Sun Apr  6 15:25:17 2008
@@ -772,7 +772,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)
@@ -788,7 +788,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:
@@ -806,7 +806,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)
@@ -824,7 +824,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:
@@ -841,7 +841,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:
@@ -860,7 +860,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:
@@ -1356,16 +1356,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
@@ -1508,7 +1508,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);
@@ -1598,7 +1598,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/trunk/lib/Transforms/Scalar/LoopRotation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Sun Apr  6 15:25:17 2008
@@ -1740,7 +1740,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/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/CloneFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Sun Apr  6 15:25:17 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()));
 
@@ -144,7 +144,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();
@@ -208,7 +208,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;
@@ -253,7 +253,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;
       }
@@ -265,7 +265,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/trunk/lib/Transforms/Utils/CloneModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneModule.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneModule.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneModule.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/CodeExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/LCSSA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/LoopSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/LowerAllocations.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/LowerInvoke.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/LowerSwitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Sun Apr  6 15:25:17 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/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Sun Apr  6 15:25:17 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;

Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Sun Apr  6 15:25:17 2008
@@ -216,7 +216,7 @@
     return;
   }
 
-  switch(NewFn->getIntrinsicID()) {
+  switch (NewFn->getIntrinsicID()) {
   default:  assert(0 && "Unknown function for CallInst upgrade.");
   case Intrinsic::x86_mmx_psll_d:
   case Intrinsic::x86_mmx_psll_q:
@@ -237,8 +237,8 @@
     Operands[1] = BC;
     
     //  Construct a new CallInst
-    CallInst *NewCI = new CallInst(NewFn, Operands, Operands+2, 
-                                   "upgraded."+CI->getName(), CI);
+    CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+2, 
+                                       "upgraded."+CI->getName(), CI);
     NewCI->setTailCall(CI->isTailCall());
     NewCI->setCallingConv(CI->getCallingConv());
     
@@ -254,14 +254,14 @@
   }        
   case Intrinsic::ctlz:
   case Intrinsic::ctpop:
-  case Intrinsic::cttz:
+  case Intrinsic::cttz: {
     //  Build a small vector of the 1..(N-1) operands, which are the 
     //  parameters.
     SmallVector<Value*, 8> Operands(CI->op_begin()+1, CI->op_end());
 
     //  Construct a new CallInst
-    CallInst *NewCI = new CallInst(NewFn, Operands.begin(), Operands.end(), 
-                                   "upgraded."+CI->getName(), CI);
+    CallInst *NewCI = CallInst::Create(NewFn, Operands.begin(), Operands.end(),
+                                       "upgraded."+CI->getName(), CI);
     NewCI->setTailCall(CI->isTailCall());
     NewCI->setCallingConv(CI->getCallingConv());
 
@@ -287,7 +287,8 @@
 
     //  Clean up the old call now that it has been completely upgraded.
     CI->eraseFromParent();
-    break;
+  }
+  break;
   }
 }
 

Modified: llvm/trunk/lib/VMCore/BasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/BasicBlock.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/BasicBlock.cpp (original)
+++ llvm/trunk/lib/VMCore/BasicBlock.cpp Sun Apr  6 15:25:17 2008
@@ -35,6 +35,10 @@
   /// DummyInst - An instance of this class is used to mark the end of the
   /// instruction list.  This is not a real instruction.
   struct VISIBILITY_HIDDEN DummyInst : public Instruction {
+    // allocate space for exactly zero operands
+    void *operator new(size_t s) {
+      return User::operator new(s, 0);
+    }
     DummyInst() : Instruction(Type::VoidTy, OtherOpsEnd, 0, 0) {
       // This should not be garbage monitored.
       LeakDetector::removeGarbageObject(this);
@@ -71,7 +75,7 @@
 
 BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
                        BasicBlock *InsertBefore, BasicBlock *Dest)
-  : User(Type::LabelTy, Value::BasicBlockVal, &unwindDest, 0), Parent(0) {
+  : User(Type::LabelTy, Value::BasicBlockVal, &unwindDest, 0/*FIXME*/), Parent(0) {
 
   // Make sure that we get added to a function
   LeakDetector::addGarbageObject(this);
@@ -283,14 +287,14 @@
   assert(I != InstList.end() &&
          "Trying to get me to create degenerate basic block!");
 
-  BasicBlock *New = new BasicBlock(BBName, getParent(), getNext());
+  BasicBlock *New = new(0/*FIXME*/) BasicBlock(BBName, getParent(), getNext());
 
   // Move all of the specified instructions from the original basic block into
   // the new basic block.
   New->getInstList().splice(New->end(), this->getInstList(), I, end());
 
   // Add a branch instruction to the newly formed basic block.
-  new BranchInst(New, this);
+  BranchInst::Create(New, this);
 
   // Now we must loop through all of the successors of the New block (which
   // _were_ the successors of the 'this' block), and update any PHI nodes in

Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Sun Apr  6 15:25:17 2008
@@ -410,8 +410,13 @@
 /// UnaryConstantExpr - This class is private to Constants.cpp, and is used
 /// behind the scenes to implement unary constant exprs.
 class VISIBILITY_HIDDEN UnaryConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Op;
 public:
+  // allocate space for exactly one operand
+  void *operator new(size_t s) {
+    return User::operator new(s, 1);
+  }
   UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty)
     : ConstantExpr(Ty, Opcode, &Op, 1), Op(C, this) {}
 };
@@ -419,8 +424,13 @@
 /// BinaryConstantExpr - This class is private to Constants.cpp, and is used
 /// behind the scenes to implement binary constant exprs.
 class VISIBILITY_HIDDEN BinaryConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[2];
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
   BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2)
     : ConstantExpr(C1->getType(), Opcode, Ops, 2) {
     Ops[0].init(C1, this);
@@ -431,8 +441,13 @@
 /// SelectConstantExpr - This class is private to Constants.cpp, and is used
 /// behind the scenes to implement select constant exprs.
 class VISIBILITY_HIDDEN SelectConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[3];
 public:
+  // allocate space for exactly three operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 3);
+  }
   SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3)
     : ConstantExpr(C2->getType(), Instruction::Select, Ops, 3) {
     Ops[0].init(C1, this);
@@ -445,8 +460,13 @@
 /// Constants.cpp, and is used behind the scenes to implement
 /// extractelement constant exprs.
 class VISIBILITY_HIDDEN ExtractElementConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[2];
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
   ExtractElementConstantExpr(Constant *C1, Constant *C2)
     : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(), 
                    Instruction::ExtractElement, Ops, 2) {
@@ -459,8 +479,13 @@
 /// Constants.cpp, and is used behind the scenes to implement
 /// insertelement constant exprs.
 class VISIBILITY_HIDDEN InsertElementConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[3];
 public:
+  // allocate space for exactly three operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 3);
+  }
   InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
     : ConstantExpr(C1->getType(), Instruction::InsertElement, 
                    Ops, 3) {
@@ -474,8 +499,13 @@
 /// Constants.cpp, and is used behind the scenes to implement
 /// shufflevector constant exprs.
 class VISIBILITY_HIDDEN ShuffleVectorConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[3];
 public:
+  // allocate space for exactly three operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 3);
+  }
   ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3)
   : ConstantExpr(C1->getType(), Instruction::ShuffleVector, 
                  Ops, 3) {
@@ -487,7 +517,7 @@
 
 /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
 /// used behind the scenes to implement getelementpr constant exprs.
-struct VISIBILITY_HIDDEN GetElementPtrConstantExpr : public ConstantExpr {
+class VISIBILITY_HIDDEN GetElementPtrConstantExpr : public ConstantExpr {
   GetElementPtrConstantExpr(Constant *C, const std::vector<Constant*> &IdxList,
                             const Type *DestTy)
     : ConstantExpr(DestTy, Instruction::GetElementPtr,
@@ -496,6 +526,11 @@
     for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
       OperandList[i+1].init(IdxList[i], this);
   }
+public:
+  static GetElementPtrConstantExpr *Create(Constant *C, const std::vector<Constant*> &IdxList,
+                                    const Type *DestTy) {
+    return new(IdxList.size() + 1/*FIXME*/) GetElementPtrConstantExpr(C, IdxList, DestTy);
+  }
   ~GetElementPtrConstantExpr() {
     delete [] OperandList;
   }
@@ -505,6 +540,11 @@
 // behind the scenes to implement ICmp and FCmp constant expressions. This is
 // needed in order to store the predicate value for these instructions.
 struct VISIBILITY_HIDDEN CompareConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
   unsigned short predicate;
   Use Ops[2];
   CompareConstantExpr(Instruction::OtherOps opc, unsigned short pred, 
@@ -771,7 +811,8 @@
   template<class ConstantClass, class TypeClass, class ValType>
   struct VISIBILITY_HIDDEN ConstantCreator {
     static ConstantClass *create(const TypeClass *Ty, const ValType &V) {
-      return new ConstantClass(Ty, V);
+      unsigned FIXME; // = traits<ValType>::uses(V)
+      return new(FIXME) ConstantClass(Ty, V);
     }
   };
 
@@ -1433,7 +1474,7 @@
                                              V.operands[2]);
       if (V.opcode == Instruction::GetElementPtr) {
         std::vector<Constant*> IdxList(V.operands.begin()+1, V.operands.end());
-        return new GetElementPtrConstantExpr(V.operands[0], IdxList, Ty);
+        return GetElementPtrConstantExpr::Create(V.operands[0], IdxList, Ty);
       }
 
       // The compare instructions are weird. We have to encode the predicate

Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Sun Apr  6 15:25:17 2008
@@ -670,8 +670,8 @@
 
 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
                              LLVMTypeRef FunctionTy) {
-  return wrap(new Function(unwrap<FunctionType>(FunctionTy),
-                           GlobalValue::ExternalLinkage, Name, unwrap(M)));
+  return wrap(Function::Create(unwrap<FunctionType>(FunctionTy),
+                               GlobalValue::ExternalLinkage, Name, unwrap(M)));
 }
 
 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name) {
@@ -864,14 +864,14 @@
 }
 
 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef FnRef, const char *Name) {
-  return wrap(new BasicBlock(Name, unwrap<Function>(FnRef)));
+  return wrap(BasicBlock::Create(Name, unwrap<Function>(FnRef)));
 }
 
 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBBRef,
                                        const char *Name) {
   BasicBlock *InsertBeforeBB = unwrap(InsertBeforeBBRef);
-  return wrap(new BasicBlock(Name, InsertBeforeBB->getParent(),
-                             InsertBeforeBB));
+  return wrap(BasicBlock::Create(Name, InsertBeforeBB->getParent(),
+                                 InsertBeforeBB));
 }
 
 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BBRef) {

Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Sun Apr  6 15:25:17 2008
@@ -24,7 +24,7 @@
 using namespace llvm;
 
 BasicBlock *ilist_traits<BasicBlock>::createSentinel() {
-  BasicBlock *Ret = new BasicBlock();
+  BasicBlock *Ret = BasicBlock::Create();
   // This should not be garbage monitored.
   LeakDetector::removeGarbageObject(Ret);
   return Ret;

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Sun Apr  6 15:25:17 2008
@@ -2710,7 +2710,7 @@
 // unit that uses these classes.
 
 GetElementPtrInst *GetElementPtrInst::clone() const {
-  return new GetElementPtrInst(*this);
+  return new(getNumOperands()) GetElementPtrInst(*this);
 }
 
 BinaryOperator *BinaryOperator::clone() const {
@@ -2741,24 +2741,24 @@
 CastInst   *PtrToIntInst::clone() const { return new PtrToIntInst(*this); }
 CastInst   *IntToPtrInst::clone() const { return new IntToPtrInst(*this); }
 CastInst   *BitCastInst::clone()  const { return new BitCastInst(*this); }
-CallInst   *CallInst::clone()     const { return new CallInst(*this); }
-SelectInst *SelectInst::clone()   const { return new SelectInst(*this); }
+CallInst   *CallInst::clone()     const { return new(getNumOperands()) CallInst(*this); }
+SelectInst *SelectInst::clone()   const { return new(getNumOperands()) SelectInst(*this); }
 VAArgInst  *VAArgInst::clone()    const { return new VAArgInst(*this); }
 
 ExtractElementInst *ExtractElementInst::clone() const {
   return new ExtractElementInst(*this);
 }
 InsertElementInst *InsertElementInst::clone() const {
-  return new InsertElementInst(*this);
+  return InsertElementInst::Create(*this);
 }
 ShuffleVectorInst *ShuffleVectorInst::clone() const {
   return new ShuffleVectorInst(*this);
 }
 PHINode    *PHINode::clone()    const { return new PHINode(*this); }
-ReturnInst *ReturnInst::clone() const { return new ReturnInst(*this); }
-BranchInst *BranchInst::clone() const { return new BranchInst(*this); }
-SwitchInst *SwitchInst::clone() const { return new SwitchInst(*this); }
-InvokeInst *InvokeInst::clone() const { return new InvokeInst(*this); }
+ReturnInst *ReturnInst::clone() const { return new(getNumOperands()) ReturnInst(*this); }
+BranchInst *BranchInst::clone() const { return new(getNumOperands()) BranchInst(*this); }
+SwitchInst *SwitchInst::clone() const { return new(getNumOperands()) SwitchInst(*this); }
+InvokeInst *InvokeInst::clone() const { return new(getNumOperands()) InvokeInst(*this); }
 UnwindInst *UnwindInst::clone() const { return new UnwindInst(); }
 UnreachableInst *UnreachableInst::clone() const { return new UnreachableInst();}
 GetResultInst *GetResultInst::clone() const { return new GetResultInst(*this); }

Modified: llvm/trunk/lib/VMCore/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Module.cpp (original)
+++ llvm/trunk/lib/VMCore/Module.cpp Sun Apr  6 15:25:17 2008
@@ -32,7 +32,7 @@
 Function *ilist_traits<Function>::createSentinel() {
   FunctionType *FTy =
     FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false);
-  Function *Ret = new Function(FTy, GlobalValue::ExternalLinkage);
+  Function *Ret = Function::Create(FTy, GlobalValue::ExternalLinkage);
   // This should not be garbage monitored.
   LeakDetector::removeGarbageObject(Ret);
   return Ret;
@@ -149,7 +149,7 @@
   GlobalValue *F = dyn_cast_or_null<GlobalValue>(SymTab.lookup(Name));
   if (F == 0) {
     // Nope, add it
-    Function *New = new Function(Ty, GlobalVariable::ExternalLinkage, Name);
+    Function *New = Function::Create(Ty, GlobalVariable::ExternalLinkage, Name);
     FunctionList.push_back(New);
     return New;                    // Return the new prototype.
   }

Modified: llvm/trunk/tools/bugpoint/CrashDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/CrashDebugger.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/CrashDebugger.cpp (original)
+++ llvm/trunk/tools/bugpoint/CrashDebugger.cpp Sun Apr  6 15:25:17 2008
@@ -309,8 +309,8 @@
 
         // Add a new return instruction of the appropriate type...
         const Type *RetTy = BB->getParent()->getReturnType();
-        new ReturnInst(RetTy == Type::VoidTy ? 0 :
-                       Constant::getNullValue(RetTy), BB);
+	ReturnInst::Create(RetTy == Type::VoidTy ? 0 :
+			   Constant::getNullValue(RetTy), BB);
       }
 
   // The CFG Simplifier pass may delete one of the basic blocks we are

Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=49277&r1=49276&r2=49277&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original)
+++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Sun Apr  6 15:25:17 2008
@@ -644,14 +644,14 @@
       // Rename it
       oldMain->setName("llvm_bugpoint_old_main");
       // Create a NEW `main' function with same type in the test module.
-      Function *newMain = new Function(oldMain->getFunctionType(),
-                                       GlobalValue::ExternalLinkage,
-                                       "main", Test);
+      Function *newMain = Function::Create(oldMain->getFunctionType(),
+                                           GlobalValue::ExternalLinkage,
+                                           "main", Test);
       // Create an `oldmain' prototype in the test module, which will
       // corresponds to the real main function in the same module.
-      Function *oldMainProto = new Function(oldMain->getFunctionType(),
-                                            GlobalValue::ExternalLinkage,
-                                            oldMain->getName(), Test);
+      Function *oldMainProto = Function::Create(oldMain->getFunctionType(),
+                                                GlobalValue::ExternalLinkage,
+                                                oldMain->getName(), Test);
       // Set up and remember the argument list for the main function.
       std::vector<Value*> args;
       for (Function::arg_iterator
@@ -662,12 +662,12 @@
       }
 
       // Call the old main function and return its result
-      BasicBlock *BB = new BasicBlock("entry", newMain);
-      CallInst *call = new CallInst(oldMainProto, args.begin(), args.end(),
-                                    "", BB);
+      BasicBlock *BB = BasicBlock::Create("entry", newMain);
+      CallInst *call = CallInst::Create(oldMainProto, args.begin(), args.end(),
+                                        "", BB);
 
       // If the type of old function wasn't void, return value of call
-      new ReturnInst(call, BB);
+      ReturnInst::Create(call, BB);
     }
 
   // The second nasty issue we must deal with in the JIT is that the Safe
@@ -717,35 +717,35 @@
 
           // Construct a new stub function that will re-route calls to F
           const FunctionType *FuncTy = F->getFunctionType();
-          Function *FuncWrapper = new Function(FuncTy,
-                                               GlobalValue::InternalLinkage,
-                                               F->getName() + "_wrapper",
-                                               F->getParent());
-          BasicBlock *EntryBB  = new BasicBlock("entry", FuncWrapper);
-          BasicBlock *DoCallBB = new BasicBlock("usecache", FuncWrapper);
-          BasicBlock *LookupBB = new BasicBlock("lookupfp", FuncWrapper);
+          Function *FuncWrapper = Function::Create(FuncTy,
+                                                   GlobalValue::InternalLinkage,
+                                                   F->getName() + "_wrapper",
+                                                   F->getParent());
+          BasicBlock *EntryBB  = BasicBlock::Create("entry", FuncWrapper);
+          BasicBlock *DoCallBB = BasicBlock::Create("usecache", FuncWrapper);
+          BasicBlock *LookupBB = BasicBlock::Create("lookupfp", FuncWrapper);
 
           // Check to see if we already looked up the value.
           Value *CachedVal = new LoadInst(Cache, "fpcache", EntryBB);
           Value *IsNull = new ICmpInst(ICmpInst::ICMP_EQ, CachedVal,
                                        NullPtr, "isNull", EntryBB);
-          new BranchInst(LookupBB, DoCallBB, IsNull, EntryBB);
+          BranchInst::Create(LookupBB, DoCallBB, IsNull, EntryBB);
 
           // Resolve the call to function F via the JIT API:
           //
           // call resolver(GetElementPtr...)
-          CallInst *Resolver = new CallInst(resolverFunc, ResolverArgs.begin(),
-                                            ResolverArgs.end(),
-                                            "resolver", LookupBB);
+          CallInst *Resolver = CallInst::Create(resolverFunc, ResolverArgs.begin(),
+                                                ResolverArgs.end(),
+                                                "resolver", LookupBB);
           // cast the result from the resolver to correctly-typed function
           CastInst *CastedResolver = new BitCastInst(Resolver, 
             PointerType::getUnqual(F->getFunctionType()), "resolverCast", LookupBB);
 
           // Save the value in our cache.
           new StoreInst(CastedResolver, Cache, LookupBB);
-          new BranchInst(DoCallBB, LookupBB);
+          BranchInst::Create(DoCallBB, LookupBB);
 
-          PHINode *FuncPtr = new PHINode(NullPtr->getType(), "fp", DoCallBB);
+          PHINode *FuncPtr = PHINode::Create(NullPtr->getType(), "fp", DoCallBB);
           FuncPtr->addIncoming(CastedResolver, LookupBB);
           FuncPtr->addIncoming(CachedVal, EntryBB);
 
@@ -757,12 +757,12 @@
 
           // Pass on the arguments to the real function, return its result
           if (F->getReturnType() == Type::VoidTy) {
-            new CallInst(FuncPtr, Args.begin(), Args.end(), "", DoCallBB);
-            new ReturnInst(DoCallBB);
+            CallInst::Create(FuncPtr, Args.begin(), Args.end(), "", DoCallBB);
+            ReturnInst::Create(DoCallBB);
           } else {
-            CallInst *Call = new CallInst(FuncPtr, Args.begin(), Args.end(),
-                                          "retval", DoCallBB);
-            new ReturnInst(Call, DoCallBB);
+            CallInst *Call = CallInst::Create(FuncPtr, Args.begin(), Args.end(),
+                                              "retval", DoCallBB);
+            ReturnInst::Create(Call, DoCallBB);
           }
 
           // Use the wrapper function instead of the old function





More information about the llvm-commits mailing list