[llvm-commits] [llvm] r75703 - in /llvm/trunk: examples/BrainF/ examples/Fibonacci/ examples/HowToUseJIT/ examples/ModuleMaker/ examples/ParallelJIT/ include/llvm/ include/llvm/Support/ include/llvm/Transforms/Utils/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/ExecutionEngine/JIT/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/CBackend/ lib/Target/XCore/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoi...

Owen Anderson resistor at mac.com
Tue Jul 14 16:09:56 PDT 2009


Author: resistor
Date: Tue Jul 14 18:09:55 2009
New Revision: 75703

URL: http://llvm.org/viewvc/llvm-project?rev=75703&view=rev
Log:
Move EVER MORE stuff over to LLVMContext.

Modified:
    llvm/trunk/examples/BrainF/BrainF.cpp
    llvm/trunk/examples/BrainF/BrainF.h
    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/Constants.h
    llvm/trunk/include/llvm/Instructions.h
    llvm/trunk/include/llvm/LLVMContext.h
    llvm/trunk/include/llvm/Support/IRBuilder.h
    llvm/trunk/include/llvm/Transforms/Utils/Local.h
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp
    llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
    llvm/trunk/lib/CodeGen/ShadowStackGC.cpp
    llvm/trunk/lib/CodeGen/StackProtector.cpp
    llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
    llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp
    llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
    llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp
    llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp
    llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
    llvm/trunk/lib/Target/CBackend/CBackend.cpp
    llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp
    llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.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/RaiseAllocations.cpp
    llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
    llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
    llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
    llvm/trunk/lib/Transforms/Scalar/LICM.cpp
    llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp
    llvm/trunk/lib/Transforms/Scalar/Reg2Mem.cpp
    llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
    llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp
    llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
    llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp
    llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
    llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
    llvm/trunk/lib/VMCore/Constants.cpp
    llvm/trunk/lib/VMCore/Instructions.cpp
    llvm/trunk/lib/VMCore/LLVMContext.cpp
    llvm/trunk/tools/bugpoint/ExtractFunction.cpp
    llvm/trunk/tools/bugpoint/Miscompilation.cpp
    llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp
    llvm/trunk/unittests/Support/ValueHandleTest.cpp
    llvm/trunk/unittests/VMCore/MetadataTest.cpp

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

==============================================================================
--- llvm/trunk/examples/BrainF/BrainF.cpp (original)
+++ llvm/trunk/examples/BrainF/BrainF.cpp Tue Jul 14 18:09:55 2009
@@ -43,7 +43,7 @@
   comflag  = cf;
 
   header(Context);
-  readloop(0, 0, 0);
+  readloop(0, 0, 0, Context);
   delete builder;
   return module;
 }
@@ -77,16 +77,16 @@
   builder = new IRBuilder<>(BasicBlock::Create(label, brainf_func));
 
   //%arr = malloc i8, i32 %d
-  ConstantInt *val_mem = ConstantInt::get(APInt(32, memtotal));
+  ConstantInt *val_mem = C.getConstantInt(APInt(32, memtotal));
   ptr_arr = builder->CreateMalloc(IntegerType::Int8Ty, val_mem, "arr");
 
   //call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1)
   {
     Value *memset_params[] = {
       ptr_arr,
-      ConstantInt::get(APInt(8, 0)),
+      C.getConstantInt(APInt(8, 0)),
       val_mem,
-      ConstantInt::get(APInt(32, 1))
+      C.getConstantInt(APInt(32, 1))
     };
 
     CallInst *memset_call = builder->
@@ -97,12 +97,12 @@
   //%arrmax = getelementptr i8 *%arr, i32 %d
   if (comflag & flag_arraybounds) {
     ptr_arrmax = builder->
-      CreateGEP(ptr_arr, ConstantInt::get(APInt(32, memtotal)), "arrmax");
+      CreateGEP(ptr_arr, C.getConstantInt(APInt(32, memtotal)), "arrmax");
   }
 
   //%head.%d = getelementptr i8 *%arr, i32 %d
   curhead = builder->CreateGEP(ptr_arr,
-                               ConstantInt::get(APInt(32, memtotal/2)),
+                               C.getConstantInt(APInt(32, memtotal/2)),
                                headreg);
 
 
@@ -124,8 +124,8 @@
   if (comflag & flag_arraybounds)
   {
     //@aberrormsg = internal constant [%d x i8] c"\00"
-    Constant *msg_0 = ConstantArray::
-      get("Error: The head has left the tape.", true);
+    Constant *msg_0 =
+      C.getConstantArray("Error: The head has left the tape.", true);
 
     GlobalVariable *aberrormsg = new GlobalVariable(
       *module,
@@ -138,7 +138,7 @@
     //declare i32 @puts(i8 *)
     Function *puts_func = cast<Function>(module->
       getOrInsertFunction("puts", IntegerType::Int32Ty,
-                          PointerType::getUnqual(IntegerType::Int8Ty), NULL));
+                          C.getPointerTypeUnqual(IntegerType::Int8Ty), NULL));
 
     //brainf.aberror:
     aberrorbb = BasicBlock::Create(label, brainf_func);
@@ -172,7 +172,8 @@
   }
 }
 
-void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
+void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
+                      LLVMContext &C) {
   Symbol cursym = SYM_NONE;
   int curvalue = 0;
   Symbol nextsym = SYM_NONE;
@@ -228,7 +229,7 @@
         {
           //%head.%d = getelementptr i8 *%head.%d, i32 %d
           curhead = builder->
-            CreateGEP(curhead, ConstantInt::get(APInt(32, curvalue)),
+            CreateGEP(curhead, C.getConstantInt(APInt(32, curvalue)),
                       headreg);
 
           //Error block for array out of bounds
@@ -263,7 +264,7 @@
 
           //%tape.%d = add i8 %tape.%d, %d
           Value *tape_1 = builder->
-            CreateAdd(tape_0, ConstantInt::get(APInt(8, curvalue)), tapereg);
+            CreateAdd(tape_0, C.getConstantInt(APInt(8, curvalue)), tapereg);
 
           //store i8 %tape.%d, i8 *%head.%d\n"
           builder->CreateStore(tape_1, curhead);
@@ -283,13 +284,13 @@
 
           // Make part of PHI instruction now, wait until end of loop to finish
           PHINode *phi_0 =
-            PHINode::Create(PointerType::getUnqual(IntegerType::Int8Ty),
+            PHINode::Create(C.getPointerTypeUnqual(IntegerType::Int8Ty),
                             headreg, testbb);
           phi_0->reserveOperandSpace(2);
           phi_0->addIncoming(curhead, bb_0);
           curhead = phi_0;
 
-          readloop(phi_0, bb_1, testbb);
+          readloop(phi_0, bb_1, testbb, C);
         }
         break;
 
@@ -428,7 +429,7 @@
 
       //%test.%d = icmp eq i8 %tape.%d, 0
       ICmpInst *test_0 = new ICmpInst(*testbb, ICmpInst::ICMP_EQ, tape_0,
-                                      ConstantInt::get(APInt(8, 0)), testreg);
+                                      C.getConstantInt(APInt(8, 0)), testreg);
 
       //br i1 %test.%d, label %main.%d, label %main.%d
       BasicBlock *bb_0 = BasicBlock::Create(label, brainf_func);
@@ -439,7 +440,7 @@
 
       //%head.%d = phi i8 *[%head.%d, %main.%d]
       PHINode *phi_1 = builder->
-        CreatePHI(PointerType::getUnqual(IntegerType::Int8Ty), headreg);
+        CreatePHI(C.getPointerTypeUnqual(IntegerType::Int8Ty), headreg);
       phi_1->reserveOperandSpace(1);
       phi_1->addIncoming(head_0, testbb);
       curhead = phi_1;

Modified: llvm/trunk/examples/BrainF/BrainF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.h?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/examples/BrainF/BrainF.h (original)
+++ llvm/trunk/examples/BrainF/BrainF.h Tue Jul 14 18:09:55 2009
@@ -70,7 +70,8 @@
 
     /// The main loop for parsing.  It calls itself recursively
     /// to handle the depth of nesting of "[]".
-    void readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb);
+    void readloop(PHINode *phi, BasicBlock *oldbb,
+                  BasicBlock *testbb, LLVMContext &Context);
 
     /// Constants during parsing
     int memtotal;

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

==============================================================================
--- llvm/trunk/examples/Fibonacci/fibonacci.cpp (original)
+++ llvm/trunk/examples/Fibonacci/fibonacci.cpp Tue Jul 14 18:09:55 2009
@@ -36,7 +36,7 @@
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
-static Function *CreateFibFunction(Module *M) {
+static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
   // Create the fib function and insert it into module M.  This function is said
   // to return an int and take an int parameter.
   Function *FibF =
@@ -47,8 +47,8 @@
   BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF);
 
   // Get pointers to the constants.
-  Value *One = ConstantInt::get(Type::Int32Ty, 1);
-  Value *Two = ConstantInt::get(Type::Int32Ty, 2);
+  Value *One = Context.getConstantInt(Type::Int32Ty, 1);
+  Value *Two = Context.getConstantInt(Type::Int32Ty, 2);
 
   // Get pointer to the integer argument of the add1 function...
   Argument *ArgX = FibF->arg_begin();   // Get the arg.
@@ -97,7 +97,7 @@
   Module *M = new Module("test", Context);
 
   // We are about to create the "fib" function:
-  Function *FibF = CreateFibFunction(M);
+  Function *FibF = CreateFibFunction(M, Context);
 
   // Now we going to create JIT
   ExistingModuleProvider *MP = new ExistingModuleProvider(M);

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

==============================================================================
--- llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp (original)
+++ llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp Tue Jul 14 18:09:55 2009
@@ -69,7 +69,7 @@
   BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F);
 
   // Get pointers to the constant `1'.
-  Value *One = ConstantInt::get(Type::Int32Ty, 1);
+  Value *One = Context.getConstantInt(Type::Int32Ty, 1);
 
   // Get pointers to the integer argument of the add1 function...
   assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@@ -94,7 +94,7 @@
   BB = BasicBlock::Create("EntryBlock", FooF);
 
   // Get pointers to the constant `10'.
-  Value *Ten = ConstantInt::get(Type::Int32Ty, 10);
+  Value *Ten = Context.getConstantInt(Type::Int32Ty, 10);
 
   // Pass Ten to the call call:
   CallInst *Add1CallRes = CallInst::Create(Add1F, Ten, "add1", BB);

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

==============================================================================
--- llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp (original)
+++ llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp Tue Jul 14 18:09:55 2009
@@ -30,7 +30,8 @@
   Module *M = new Module("test", Context);
 
   // Create the main function: first create the type 'int ()'
-  FunctionType *FT = FunctionType::get(Type::Int32Ty, /*not vararg*/false);
+  FunctionType *FT =
+    Context.getFunctionType(Type::Int32Ty, /*not vararg*/false);
 
   // By passing a module as the last parameter to the Function constructor,
   // it automatically gets appended to the Module.
@@ -41,8 +42,8 @@
   BasicBlock *BB = BasicBlock::Create("EntryBlock", F);
 
   // Get pointers to the constant integers...
-  Value *Two = ConstantInt::get(Type::Int32Ty, 2);
-  Value *Three = ConstantInt::get(Type::Int32Ty, 3);
+  Value *Two = Context.getConstantInt(Type::Int32Ty, 2);
+  Value *Three = Context.getConstantInt(Type::Int32Ty, 3);
 
   // Create the add instruction... does not insert...
   Instruction *Add = BinaryOperator::Create(Instruction::Add, Two, Three,

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

==============================================================================
--- llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp (original)
+++ llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp Tue Jul 14 18:09:55 2009
@@ -44,7 +44,7 @@
   BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F);
 
   // Get pointers to the constant `1'.
-  Value *One = ConstantInt::get(Type::Int32Ty, 1);
+  Value *One = M->getContext().getConstantInt(Type::Int32Ty, 1);
 
   // Get pointers to the integer argument of the add1 function...
   assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@@ -72,8 +72,8 @@
   BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF);
 
   // Get pointers to the constants.
-  Value *One = ConstantInt::get(Type::Int32Ty, 1);
-  Value *Two = ConstantInt::get(Type::Int32Ty, 2);
+  Value *One = M->getContext().getConstantInt(Type::Int32Ty, 1);
+  Value *Two = M->getContext().getConstantInt(Type::Int32Ty, 2);
 
   // Get pointer to the integer argument of the add1 function...
   Argument *ArgX = FibF->arg_begin();   // Get the arg.

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

==============================================================================
--- llvm/trunk/include/llvm/Constants.h (original)
+++ llvm/trunk/include/llvm/Constants.h Tue Jul 14 18:09:55 2009
@@ -102,39 +102,10 @@
     return CreateTrueFalseVals(false);
   }
 
-  /// Return a ConstantInt with the specified integer value for the specified
-  /// type. If the type is wider than 64 bits, the value will be zero-extended
-  /// to fit the type, unless isSigned is true, in which case the value will
-  /// be interpreted as a 64-bit signed integer and sign-extended to fit
-  /// the type.
-  /// @brief Get a ConstantInt for a specific value.
-  static ConstantInt *get(const IntegerType *Ty,
-                          uint64_t V, bool isSigned = false);
-
-  /// If Ty is a vector type, return a Constant with a splat of the given
-  /// value. Otherwise return a ConstantInt for the given value.
-  static Constant *get(const Type *Ty, uint64_t V, bool isSigned = false);
-
-  /// Return a ConstantInt with the specified value for the specified type. The
-  /// value V will be canonicalized to a an unsigned APInt. Accessing it with
-  /// either getSExtValue() or getZExtValue() will yield a correctly sized and
-  /// signed value for the type Ty.
-  /// @brief Get a ConstantInt for a specific signed value.
-  static ConstantInt *getSigned(const IntegerType *Ty, int64_t V) {
-    return get(Ty, V, true);
-  }
-  static Constant *getSigned(const Type *Ty, int64_t V) {
-    return get(Ty, V, true);
-  }
-
   /// Return a ConstantInt with the specified value and an implied Type. The
   /// type is the integer type that corresponds to the bit width of the value.
   static ConstantInt *get(const APInt &V);
 
-  /// If Ty is a vector type, return a Constant with a splat of the given
-  /// value. Otherwise return a ConstantInt for the given value.
-  static Constant *get(const Type *Ty, const APInt &V);
-
   /// getType - Specialize the getType() method to always return an IntegerType,
   /// which reduces the amount of casting needed in parts of the compiler.
   ///
@@ -348,14 +319,6 @@
     return get(T, std::vector<Constant*>(Vals, Vals+NumVals));
   }
 
-  /// This method constructs a ConstantArray and initializes it with a text
-  /// string. The default behavior (AddNull==true) causes a null terminator to
-  /// be placed at the end of the array. This effectively increases the length
-  /// of the array by one (you've been warned).  However, in some situations 
-  /// this is not desired so if AddNull==false then the string is copied without
-  /// null termination. 
-  static Constant *get(const std::string &Initializer, bool AddNull = true);
-
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
 

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

==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Tue Jul 14 18:09:55 2009
@@ -29,6 +29,7 @@
 class ConstantInt;
 class ConstantRange;
 class APInt;
+class LLVMContext;
 
 //===----------------------------------------------------------------------===//
 //                             AllocationInst Class
@@ -39,10 +40,14 @@
 ///
 class AllocationInst : public UnaryInstruction {
 protected:
-  AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
-                 const std::string &Name = "", Instruction *InsertBefore = 0);
-  AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
-                 const std::string &Name, BasicBlock *InsertAtEnd);
+  LLVMContext &Context;
+
+  AllocationInst(LLVMContext &Context, const Type *Ty, Value *ArraySize, 
+                 unsigned iTy, unsigned Align, const std::string &Name = "", 
+                 Instruction *InsertBefore = 0);
+  AllocationInst(LLVMContext &Context, 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.
   virtual ~AllocationInst();
@@ -98,28 +103,33 @@
 class MallocInst : public AllocationInst {
   MallocInst(const MallocInst &MI);
 public:
-  explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
+  explicit MallocInst(LLVMContext &Context, 
+                      const Type *Ty, Value *ArraySize = 0,
                       const std::string &NameStr = "",
                       Instruction *InsertBefore = 0)
-    : AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertBefore) {}
-  MallocInst(const Type *Ty, Value *ArraySize, const std::string &NameStr,
-             BasicBlock *InsertAtEnd)
-    : AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {}
+    : AllocationInst(Context, Ty, ArraySize, Malloc,
+                     0, NameStr, InsertBefore) {}
+  MallocInst(LLVMContext &Context, const Type *Ty, Value *ArraySize,
+             const std::string &NameStr, BasicBlock *InsertAtEnd)
+    : AllocationInst(Context, Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {}
 
-  MallocInst(const Type *Ty, const std::string &NameStr,
+  MallocInst(LLVMContext &Context, const Type *Ty, const std::string &NameStr,
              Instruction *InsertBefore = 0)
-    : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertBefore) {}
-  MallocInst(const Type *Ty, const std::string &NameStr,
+    : AllocationInst(Context, Ty, 0, Malloc, 0, NameStr, InsertBefore) {}
+  MallocInst(LLVMContext &Context, const Type *Ty, const std::string &NameStr,
              BasicBlock *InsertAtEnd)
-    : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {}
+    : AllocationInst(Context, Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {}
 
-  MallocInst(const Type *Ty, Value *ArraySize, unsigned Align,
-             const std::string &NameStr, BasicBlock *InsertAtEnd)
-    : AllocationInst(Ty, ArraySize, Malloc, Align, NameStr, InsertAtEnd) {}
-  MallocInst(const Type *Ty, Value *ArraySize, unsigned Align,
-                      const std::string &NameStr = "",
-                      Instruction *InsertBefore = 0)
-    : AllocationInst(Ty, ArraySize, Malloc, Align, NameStr, InsertBefore) {}
+  MallocInst(LLVMContext &Context, const Type *Ty, Value *ArraySize,
+             unsigned Align, const std::string &NameStr,
+             BasicBlock *InsertAtEnd)
+    : AllocationInst(Context, Ty, ArraySize, Malloc,
+                     Align, NameStr, InsertAtEnd) {}
+  MallocInst(LLVMContext &Context, const Type *Ty, Value *ArraySize,
+             unsigned Align, const std::string &NameStr = "", 
+             Instruction *InsertBefore = 0)
+    : AllocationInst(Context, Ty, ArraySize,
+                     Malloc, Align, NameStr, InsertBefore) {}
 
   virtual MallocInst *clone(LLVMContext &Context) const;
 
@@ -143,27 +153,34 @@
 class AllocaInst : public AllocationInst {
   AllocaInst(const AllocaInst &);
 public:
-  explicit AllocaInst(const Type *Ty, Value *ArraySize = 0,
+  explicit AllocaInst(LLVMContext &Context, const Type *Ty,
+                      Value *ArraySize = 0,
                       const std::string &NameStr = "",
                       Instruction *InsertBefore = 0)
-    : AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertBefore) {}
-  AllocaInst(const Type *Ty, Value *ArraySize, const std::string &NameStr,
+    : AllocationInst(Context, Ty, ArraySize, Alloca,
+                     0, NameStr, InsertBefore) {}
+  AllocaInst(LLVMContext &Context, const Type *Ty,
+             Value *ArraySize, const std::string &NameStr,
              BasicBlock *InsertAtEnd)
-    : AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertAtEnd) {}
+    : AllocationInst(Context, Ty, ArraySize, Alloca, 0, NameStr, InsertAtEnd) {}
 
-  AllocaInst(const Type *Ty, const std::string &NameStr,
+  AllocaInst(LLVMContext &Context, const Type *Ty, const std::string &NameStr,
              Instruction *InsertBefore = 0)
-    : AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertBefore) {}
-  AllocaInst(const Type *Ty, const std::string &NameStr,
+    : AllocationInst(Context, Ty, 0, Alloca, 0, NameStr, InsertBefore) {}
+  AllocaInst(LLVMContext &Context, const Type *Ty, const std::string &NameStr,
              BasicBlock *InsertAtEnd)
-    : AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertAtEnd) {}
+    : AllocationInst(Context, Ty, 0, Alloca, 0, NameStr, InsertAtEnd) {}
 
-  AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
-             const std::string &NameStr = "", Instruction *InsertBefore = 0)
-    : AllocationInst(Ty, ArraySize, Alloca, Align, NameStr, InsertBefore) {}
-  AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
-             const std::string &NameStr, BasicBlock *InsertAtEnd)
-    : AllocationInst(Ty, ArraySize, Alloca, Align, NameStr, InsertAtEnd) {}
+  AllocaInst(LLVMContext &Context, const Type *Ty, Value *ArraySize,
+             unsigned Align, const std::string &NameStr = "",
+             Instruction *InsertBefore = 0)
+    : AllocationInst(Context, Ty, ArraySize, Alloca,
+                     Align, NameStr, InsertBefore) {}
+  AllocaInst(LLVMContext &Context, const Type *Ty, Value *ArraySize,
+             unsigned Align, const std::string &NameStr,
+             BasicBlock *InsertAtEnd)
+    : AllocationInst(Context, Ty, ArraySize, Alloca,
+                     Align, NameStr, InsertAtEnd) {}
 
   virtual AllocaInst *clone(LLVMContext &Context) const;
 
@@ -1266,12 +1283,8 @@
   }
   ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr = "",
                      Instruction *InsertBefore = 0);
-  ExtractElementInst(Value *Vec, unsigned Idx, const std::string &NameStr = "",
-                     Instruction *InsertBefore = 0);
   ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr,
                      BasicBlock *InsertAtEnd);
-  ExtractElementInst(Value *Vec, unsigned Idx, const std::string &NameStr,
-                     BasicBlock *InsertAtEnd);
 
   /// isValidOperands - Return true if an extractelement instruction can be
   /// formed with the specified operands.
@@ -1310,13 +1323,8 @@
   InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
                     const std::string &NameStr = "",
                     Instruction *InsertBefore = 0);
-  InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
-                    const std::string &NameStr = "",
-                    Instruction *InsertBefore = 0);
   InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
                     const std::string &NameStr, BasicBlock *InsertAtEnd);
-  InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
-                    const std::string &NameStr, BasicBlock *InsertAtEnd);
 public:
   static InsertElementInst *Create(const InsertElementInst &IE) {
     return new(IE.getNumOperands()) InsertElementInst(IE);
@@ -1326,21 +1334,11 @@
                                    Instruction *InsertBefore = 0) {
     return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
   }
-  static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx,
-                                   const std::string &NameStr = "",
-                                   Instruction *InsertBefore = 0) {
-    return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
-  }
   static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
                                    const std::string &NameStr,
                                    BasicBlock *InsertAtEnd) {
     return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd);
   }
-  static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx,
-                                   const std::string &NameStr,
-                                   BasicBlock *InsertAtEnd) {
-    return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd);
-  }
 
   /// isValidOperands - Return true if an insertelement instruction can be
   /// formed with the specified operands.

Modified: llvm/trunk/include/llvm/LLVMContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LLVMContext.h?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/include/llvm/LLVMContext.h (original)
+++ llvm/trunk/include/llvm/LLVMContext.h Tue Jul 14 18:09:55 2009
@@ -70,12 +70,33 @@
   // ConstantInt accessors
   ConstantInt* getConstantIntTrue();
   ConstantInt* getConstantIntFalse();
+  
+  /// If Ty is a vector type, return a Constant with a splat of the given
+  /// value. Otherwise return a ConstantInt for the given value.
   Constant* getConstantInt(const Type* Ty, uint64_t V,
                               bool isSigned = false);
+                              
+  /// Return a ConstantInt with the specified integer value for the specified
+  /// type. If the type is wider than 64 bits, the value will be zero-extended
+  /// to fit the type, unless isSigned is true, in which case the value will
+  /// be interpreted as a 64-bit signed integer and sign-extended to fit
+  /// the type.
+  /// @brief Get a ConstantInt for a specific value.
   ConstantInt* getConstantInt(const IntegerType* Ty, uint64_t V,
                               bool isSigned = false);
+
+  /// Return a ConstantInt with the specified value for the specified type. The
+  /// value V will be canonicalized to a an unsigned APInt. Accessing it with
+  /// either getSExtValue() or getZExtValue() will yield a correctly sized and
+  /// signed value for the type Ty.
+  /// @brief Get a ConstantInt for a specific signed value.
   ConstantInt* getConstantIntSigned(const IntegerType* Ty, int64_t V);
+  Constant *getConstantIntSigned(const Type *Ty, int64_t V);
+  
   ConstantInt* getConstantInt(const APInt& V);
+  
+  /// If Ty is a vector type, return a Constant with a splat of the given
+  /// value. Otherwise return a ConstantInt for the given value.
   Constant* getConstantInt(const Type* Ty, const APInt& V);
   
   // ConstantPointerNull accessors
@@ -97,6 +118,13 @@
                              const std::vector<Constant*>& V);
   Constant* getConstantArray(const ArrayType* T, Constant* const* Vals,
                              unsigned NumVals);
+                             
+  /// This method constructs a ConstantArray and initializes it with a text
+  /// string. The default behavior (AddNull==true) causes a null terminator to
+  /// be placed at the end of the array. This effectively increases the length
+  /// of the array by one (you've been warned).  However, in some situations 
+  /// this is not desired so if AddNull==false then the string is copied without
+  /// null termination.
   Constant* getConstantArray(const std::string& Initializer,
                              bool AddNull = true);
                              

Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/IRBuilder.h Tue Jul 14 18:09:55 2009
@@ -330,11 +330,11 @@
 
   MallocInst *CreateMalloc(const Type *Ty, Value *ArraySize = 0,
                            const char *Name = "") {
-    return Insert(new MallocInst(Ty, ArraySize), Name);
+    return Insert(new MallocInst(Context, Ty, ArraySize), Name);
   }
   AllocaInst *CreateAlloca(const Type *Ty, Value *ArraySize = 0,
                            const char *Name = "") {
-    return Insert(new AllocaInst(Ty, ArraySize), Name);
+    return Insert(new AllocaInst(Context, Ty, ArraySize), Name);
   }
   FreeInst *CreateFree(Value *Ptr) {
     return Insert(new FreeInst(Ptr));

Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Tue Jul 14 18:09:55 2009
@@ -27,6 +27,7 @@
 class AllocaInst;
 class ConstantExpr;
 class TargetData;
+class LLVMContext;
 struct DbgInfoIntrinsic;
 
 template<typename T> class SmallVectorImpl;
@@ -107,13 +108,15 @@
 /// invalidating the SSA information for the value.  It returns the pointer to
 /// the alloca inserted to create a stack slot for X.
 ///
-AllocaInst *DemoteRegToStack(Instruction &X, bool VolatileLoads = false,
+AllocaInst *DemoteRegToStack(LLVMContext &Context, Instruction &X,
+                             bool VolatileLoads = false,
                              Instruction *AllocaPoint = 0);
 
 /// DemotePHIToStack - This function takes a virtual register computed by a phi
 /// node and replaces it with a slot in the stack frame, allocated via alloca.
 /// The phi node is deleted and it returns the pointer to the alloca inserted. 
-AllocaInst *DemotePHIToStack(PHINode *P, Instruction *AllocaPoint = 0);
+AllocaInst *DemotePHIToStack(LLVMContext &Context, PHINode *P,
+                             Instruction *AllocaPoint = 0);
 
 /// OnlyUsedByDbgIntrinsics - Return true if the instruction I is only used
 /// by DbgIntrinsics. If DbgInUses is specified then the vector is filled 

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Jul 14 18:09:55 2009
@@ -196,7 +196,8 @@
 
 const SCEV *
 ScalarEvolution::getConstant(const Type *Ty, uint64_t V, bool isSigned) {
-  return getConstant(ConstantInt::get(cast<IntegerType>(Ty), V, isSigned));
+  return getConstant(
+    Context->getConstantInt(cast<IntegerType>(Ty), V, isSigned));
 }
 
 const Type *SCEVConstant::getType() const { return V->getType(); }
@@ -2115,7 +2116,7 @@
 /// specified signed integer value and return a SCEV for the constant.
 const SCEV *ScalarEvolution::getIntegerSCEV(int Val, const Type *Ty) {
   const IntegerType *ITy = cast<IntegerType>(getEffectiveSCEVType(Ty));
-  return getConstant(ConstantInt::get(ITy, Val));
+  return getConstant(Context->getConstantInt(ITy, Val));
 }
 
 /// getNegativeSCEV - Return a SCEV corresponding to -V = -1*V
@@ -3537,8 +3538,8 @@
 
   unsigned MaxSteps = MaxBruteForceIterations;
   for (unsigned IterationNum = 0; IterationNum != MaxSteps; ++IterationNum) {
-    ConstantInt *ItCst =
-      ConstantInt::get(cast<IntegerType>(IdxExpr->getType()), IterationNum);
+    ConstantInt *ItCst = Context->getConstantInt(
+                           cast<IntegerType>(IdxExpr->getType()), IterationNum);
     ConstantInt *Val = EvaluateConstantChrecAtConstant(IdxExpr, ItCst, *this);
 
     // Form the GEP offset.

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Jul 14 18:09:55 2009
@@ -3182,9 +3182,9 @@
     return Error(SizeLoc, "element count must be i32");
 
   if (Opc == Instruction::Malloc)
-    Inst = new MallocInst(Ty, Size, Alignment);
+    Inst = new MallocInst(Context, Ty, Size, Alignment);
   else
-    Inst = new AllocaInst(Ty, Size, Alignment);
+    Inst = new AllocaInst(Context, Ty, Size, Alignment);
   return false;
 }
 

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

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jul 14 18:09:55 2009
@@ -1817,7 +1817,8 @@
       Value *Size = getFnValueByID(Record[1], Type::Int32Ty);
       unsigned Align = Record[2];
       if (!Ty || !Size) return Error("Invalid MALLOC record");
-      I = new MallocInst(Ty->getElementType(), Size, (1 << Align) >> 1);
+      I = new MallocInst(Context, Ty->getElementType(), Size,
+                         (1 << Align) >> 1);
       break;
     }
     case bitc::FUNC_CODE_INST_FREE: { // FREE: [op, opty]
@@ -1837,7 +1838,8 @@
       Value *Size = getFnValueByID(Record[1], Type::Int32Ty);
       unsigned Align = Record[2];
       if (!Ty || !Size) return Error("Invalid ALLOCA record");
-      I = new AllocaInst(Ty->getElementType(), Size, (1 << Align) >> 1);
+      I = new AllocaInst(Context, Ty->getElementType(), Size,
+                         (1 << Align) >> 1);
       break;
     }
     case bitc::FUNC_CODE_INST_LOAD: { // LOAD: [opty, op, align, vol]

Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Tue Jul 14 18:09:55 2009
@@ -354,7 +354,8 @@
 
   // Create the temporary if we didn't already.
   if (!ExceptionValueVar) {
-    ExceptionValueVar = new AllocaInst(PointerType::getUnqual(Type::Int8Ty),
+    ExceptionValueVar = new AllocaInst(*Context, 
+                                       PointerType::getUnqual(Type::Int8Ty),
                                        "eh.value", F->begin()->begin());
     ++NumStackTempsIntroduced;
   }

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

==============================================================================
--- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Tue Jul 14 18:09:55 2009
@@ -149,7 +149,7 @@
 
 /// LowerBSWAP - Emit the code to lower bswap of V before the specified
 /// instruction IP.
-static Value *LowerBSWAP(Value *V, Instruction *IP) {
+static Value *LowerBSWAP(LLVMContext &Context, Value *V, Instruction *IP) {
   assert(V->getType()->isInteger() && "Can't bswap a non-integer type!");
 
   unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
@@ -159,25 +159,27 @@
   switch(BitSize) {
   default: llvm_unreachable("Unhandled type size of value to byteswap!");
   case 16: {
-    Value *Tmp1 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 8),
+    Value *Tmp1 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 8),
                                     "bswap.2");
-    Value *Tmp2 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 8),
+    Value *Tmp2 = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 8),
                                      "bswap.1");
     V = Builder.CreateOr(Tmp1, Tmp2, "bswap.i16");
     break;
   }
   case 32: {
-    Value *Tmp4 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 24),
+    Value *Tmp4 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 24),
                                     "bswap.4");
-    Value *Tmp3 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 8),
+    Value *Tmp3 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 8),
                                     "bswap.3");
-    Value *Tmp2 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 8),
+    Value *Tmp2 = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 8),
                                      "bswap.2");
-    Value *Tmp1 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 24),
+    Value *Tmp1 = Builder.CreateLShr(V,Context.getConstantInt(V->getType(), 24),
                                      "bswap.1");
-    Tmp3 = Builder.CreateAnd(Tmp3, ConstantInt::get(Type::Int32Ty, 0xFF0000),
+    Tmp3 = Builder.CreateAnd(Tmp3,
+                             Context.getConstantInt(Type::Int32Ty, 0xFF0000),
                              "bswap.and3");
-    Tmp2 = Builder.CreateAnd(Tmp2, ConstantInt::get(Type::Int32Ty, 0xFF00),
+    Tmp2 = Builder.CreateAnd(Tmp2,
+                             Context.getConstantInt(Type::Int32Ty, 0xFF00),
                              "bswap.and2");
     Tmp4 = Builder.CreateOr(Tmp4, Tmp3, "bswap.or1");
     Tmp2 = Builder.CreateOr(Tmp2, Tmp1, "bswap.or2");
@@ -185,41 +187,44 @@
     break;
   }
   case 64: {
-    Value *Tmp8 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 56),
+    Value *Tmp8 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 56),
                                     "bswap.8");
-    Value *Tmp7 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 40),
+    Value *Tmp7 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 40),
                                     "bswap.7");
-    Value *Tmp6 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 24),
+    Value *Tmp6 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 24),
                                     "bswap.6");
-    Value *Tmp5 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 8),
+    Value *Tmp5 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 8),
                                     "bswap.5");
-    Value* Tmp4 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 8),
+    Value* Tmp4 = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 8),
                                      "bswap.4");
-    Value* Tmp3 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 24),
+    Value* Tmp3 = Builder.CreateLShr(V, 
+                                     Context.getConstantInt(V->getType(), 24),
                                      "bswap.3");
-    Value* Tmp2 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 40),
+    Value* Tmp2 = Builder.CreateLShr(V, 
+                                     Context.getConstantInt(V->getType(), 40),
                                      "bswap.2");
-    Value* Tmp1 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 56),
+    Value* Tmp1 = Builder.CreateLShr(V, 
+                                     Context.getConstantInt(V->getType(), 56),
                                      "bswap.1");
     Tmp7 = Builder.CreateAnd(Tmp7,
-                             ConstantInt::get(Type::Int64Ty,
+                             Context.getConstantInt(Type::Int64Ty,
                                               0xFF000000000000ULL),
                              "bswap.and7");
     Tmp6 = Builder.CreateAnd(Tmp6,
-                             ConstantInt::get(Type::Int64Ty,
+                             Context.getConstantInt(Type::Int64Ty,
                                               0xFF0000000000ULL),
                              "bswap.and6");
     Tmp5 = Builder.CreateAnd(Tmp5,
-                             ConstantInt::get(Type::Int64Ty, 0xFF00000000ULL),
+                        Context.getConstantInt(Type::Int64Ty, 0xFF00000000ULL),
                              "bswap.and5");
     Tmp4 = Builder.CreateAnd(Tmp4,
-                             ConstantInt::get(Type::Int64Ty, 0xFF000000ULL),
+                        Context.getConstantInt(Type::Int64Ty, 0xFF000000ULL),
                              "bswap.and4");
     Tmp3 = Builder.CreateAnd(Tmp3,
-                             ConstantInt::get(Type::Int64Ty, 0xFF0000ULL),
+                             Context.getConstantInt(Type::Int64Ty, 0xFF0000ULL),
                              "bswap.and3");
     Tmp2 = Builder.CreateAnd(Tmp2,
-                             ConstantInt::get(Type::Int64Ty, 0xFF00ULL),
+                             Context.getConstantInt(Type::Int64Ty, 0xFF00ULL),
                              "bswap.and2");
     Tmp8 = Builder.CreateOr(Tmp8, Tmp7, "bswap.or1");
     Tmp6 = Builder.CreateOr(Tmp6, Tmp5, "bswap.or2");
@@ -236,7 +241,7 @@
 
 /// LowerCTPOP - Emit the code to lower ctpop of V before the specified
 /// instruction IP.
-static Value *LowerCTPOP(Value *V, Instruction *IP) {
+static Value *LowerCTPOP(LLVMContext &Context, Value *V, Instruction *IP) {
   assert(V->getType()->isInteger() && "Can't ctpop a non-integer type!");
 
   static const uint64_t MaskValues[6] = {
@@ -249,23 +254,23 @@
 
   unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
   unsigned WordSize = (BitSize + 63) / 64;
-  Value *Count = ConstantInt::get(V->getType(), 0);
+  Value *Count = Context.getConstantInt(V->getType(), 0);
 
   for (unsigned n = 0; n < WordSize; ++n) {
     Value *PartValue = V;
     for (unsigned i = 1, ct = 0; i < (BitSize>64 ? 64 : BitSize); 
          i <<= 1, ++ct) {
-      Value *MaskCst = ConstantInt::get(V->getType(), MaskValues[ct]);
+      Value *MaskCst = Context.getConstantInt(V->getType(), MaskValues[ct]);
       Value *LHS = Builder.CreateAnd(PartValue, MaskCst, "cppop.and1");
       Value *VShift = Builder.CreateLShr(PartValue,
-                                         ConstantInt::get(V->getType(), i),
+                                        Context.getConstantInt(V->getType(), i),
                                          "ctpop.sh");
       Value *RHS = Builder.CreateAnd(VShift, MaskCst, "cppop.and2");
       PartValue = Builder.CreateAdd(LHS, RHS, "ctpop.step");
     }
     Count = Builder.CreateAdd(PartValue, Count, "ctpop.part");
     if (BitSize > 64) {
-      V = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 64),
+      V = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 64),
                              "ctpop.part.sh");
       BitSize -= 64;
     }
@@ -276,19 +281,19 @@
 
 /// LowerCTLZ - Emit the code to lower ctlz of V before the specified
 /// instruction IP.
-static Value *LowerCTLZ(Value *V, Instruction *IP) {
+static Value *LowerCTLZ(LLVMContext &Context, Value *V, Instruction *IP) {
 
   IRBuilder<> Builder(IP->getParent(), IP);
 
   unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
   for (unsigned i = 1; i < BitSize; i <<= 1) {
-    Value *ShVal = ConstantInt::get(V->getType(), i);
+    Value *ShVal = Context.getConstantInt(V->getType(), i);
     ShVal = Builder.CreateLShr(V, ShVal, "ctlz.sh");
     V = Builder.CreateOr(V, ShVal, "ctlz.step");
   }
 
   V = Builder.CreateNot(V);
-  return LowerCTPOP(V, IP);
+  return LowerCTPOP(Context, V, IP);
 }
 
 static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname,
@@ -357,15 +362,15 @@
     break;
   }
   case Intrinsic::ctpop:
-    CI->replaceAllUsesWith(LowerCTPOP(CI->getOperand(1), CI));
+    CI->replaceAllUsesWith(LowerCTPOP(*Context, CI->getOperand(1), CI));
     break;
 
   case Intrinsic::bswap:
-    CI->replaceAllUsesWith(LowerBSWAP(CI->getOperand(1), CI));
+    CI->replaceAllUsesWith(LowerBSWAP(*Context, CI->getOperand(1), CI));
     break;
     
   case Intrinsic::ctlz:
-    CI->replaceAllUsesWith(LowerCTLZ(CI->getOperand(1), CI));
+    CI->replaceAllUsesWith(LowerCTLZ(*Context, CI->getOperand(1), CI));
     break;
 
   case Intrinsic::cttz: {
@@ -373,9 +378,9 @@
     Value *Src = CI->getOperand(1);
     Value *NotSrc = Builder.CreateNot(Src);
     NotSrc->setName(Src->getName() + ".not");
-    Value *SrcM1 = ConstantInt::get(Src->getType(), 1);
+    Value *SrcM1 = Context->getConstantInt(Src->getType(), 1);
     SrcM1 = Builder.CreateSub(Src, SrcM1);
-    Src = LowerCTPOP(Builder.CreateAnd(NotSrc, SrcM1), CI);
+    Src = LowerCTPOP(*Context, Builder.CreateAnd(NotSrc, SrcM1), CI);
     CI->replaceAllUsesWith(Src);
     break;
   }
@@ -409,7 +414,7 @@
   case Intrinsic::readcyclecounter: {
     cerr << "WARNING: this target does not support the llvm.readcyclecoun"
          << "ter intrinsic.  It is being lowered to a constant 0\n";
-    CI->replaceAllUsesWith(ConstantInt::get(Type::Int64Ty, 0));
+    CI->replaceAllUsesWith(Context->getConstantInt(Type::Int64Ty, 0));
     break;
   }
 
@@ -429,7 +434,7 @@
   case Intrinsic::eh_typeid_for_i32:
   case Intrinsic::eh_typeid_for_i64:
     // Return something different to eh_selector.
-    CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
+    CI->replaceAllUsesWith(Context->getConstantInt(CI->getType(), 1));
     break;
 
   case Intrinsic::var_annotation:
@@ -501,7 +506,7 @@
   case Intrinsic::flt_rounds:
      // Lower to "round to the nearest"
      if (CI->getType() != Type::VoidTy)
-       CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
+       CI->replaceAllUsesWith(Context->getConstantInt(CI->getType(), 1));
      break;
   }
 

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Jul 14 18:09:55 2009
@@ -30,6 +30,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Function.h"
 #include "llvm/GlobalVariable.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -2035,7 +2036,7 @@
   case MVT::i64: FF = 0x5F800000ULL; break;  // 2^64 (as a float)
   }
   if (TLI.isLittleEndian()) FF <<= 32;
-  Constant *FudgeFactor = ConstantInt::get(Type::Int64Ty, FF);
+  Constant *FudgeFactor = DAG.getContext()->getConstantInt(Type::Int64Ty, FF);
 
   SDValue CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy());
   unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment();

Modified: llvm/trunk/lib/CodeGen/ShadowStackGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShadowStackGC.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/ShadowStackGC.cpp (original)
+++ llvm/trunk/lib/CodeGen/ShadowStackGC.cpp Tue Jul 14 18:09:55 2009
@@ -62,9 +62,11 @@
     Constant *GetFrameMap(Function &F);
     const Type* GetConcreteStackEntryType(Function &F);
     void CollectRoots(Function &F);
-    static GetElementPtrInst *CreateGEP(IRBuilder<> &B, Value *BasePtr,
+    static GetElementPtrInst *CreateGEP(LLVMContext *Context, 
+                                        IRBuilder<> &B, Value *BasePtr,
                                         int Idx1, const char *Name);
-    static GetElementPtrInst *CreateGEP(IRBuilder<> &B, Value *BasePtr,
+    static GetElementPtrInst *CreateGEP(LLVMContext *Context,
+                                        IRBuilder<> &B, Value *BasePtr,
                                         int Idx1, int Idx2, const char *Name);
   };
 
@@ -186,6 +188,7 @@
 
 Constant *ShadowStackGC::GetFrameMap(Function &F) {
   // doInitialization creates the abstract type of this value.
+  LLVMContext *Context = F.getContext();
 
   Type *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
 
@@ -200,17 +203,17 @@
   }
 
   Constant *BaseElts[] = {
-    ConstantInt::get(Type::Int32Ty, Roots.size(), false),
-    ConstantInt::get(Type::Int32Ty, NumMeta, false),
+    Context->getConstantInt(Type::Int32Ty, Roots.size(), false),
+    Context->getConstantInt(Type::Int32Ty, NumMeta, false),
   };
 
   Constant *DescriptorElts[] = {
-    ConstantStruct::get(BaseElts, 2),
-    ConstantArray::get(ArrayType::get(VoidPtr, NumMeta),
+    Context->getConstantStruct(BaseElts, 2),
+    Context->getConstantArray(Context->getArrayType(VoidPtr, NumMeta),
                        Metadata.begin(), NumMeta)
   };
 
-  Constant *FrameMap = ConstantStruct::get(DescriptorElts, 2);
+  Constant *FrameMap = Context->getConstantStruct(DescriptorElts, 2);
 
   std::string TypeName("gc_map.");
   TypeName += utostr(NumMeta);
@@ -233,9 +236,9 @@
                                     GlobalVariable::InternalLinkage,
                                     FrameMap, "__gc_" + F.getName());
 
-  Constant *GEPIndices[2] = { ConstantInt::get(Type::Int32Ty, 0),
-                              ConstantInt::get(Type::Int32Ty, 0) };
-  return ConstantExpr::getGetElementPtr(GV, GEPIndices, 2);
+  Constant *GEPIndices[2] = { Context->getConstantInt(Type::Int32Ty, 0),
+                              Context->getConstantInt(Type::Int32Ty, 0) };
+  return Context->getConstantExprGetElementPtr(GV, GEPIndices, 2);
 }
 
 const Type* ShadowStackGC::GetConcreteStackEntryType(Function &F) {
@@ -337,11 +340,11 @@
 }
 
 GetElementPtrInst *
-ShadowStackGC::CreateGEP(IRBuilder<> &B, Value *BasePtr,
+ShadowStackGC::CreateGEP(LLVMContext *Context, IRBuilder<> &B, Value *BasePtr,
                          int Idx, int Idx2, const char *Name) {
-  Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0),
-                       ConstantInt::get(Type::Int32Ty, Idx),
-                       ConstantInt::get(Type::Int32Ty, Idx2) };
+  Value *Indices[] = { Context->getConstantInt(Type::Int32Ty, 0),
+                       Context->getConstantInt(Type::Int32Ty, Idx),
+                       Context->getConstantInt(Type::Int32Ty, Idx2) };
   Value* Val = B.CreateGEP(BasePtr, Indices, Indices + 3, Name);
 
   assert(isa<GetElementPtrInst>(Val) && "Unexpected folded constant");
@@ -350,10 +353,10 @@
 }
 
 GetElementPtrInst *
-ShadowStackGC::CreateGEP(IRBuilder<> &B, Value *BasePtr,
+ShadowStackGC::CreateGEP(LLVMContext *Context, IRBuilder<> &B, Value *BasePtr,
                          int Idx, const char *Name) {
-  Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0),
-                       ConstantInt::get(Type::Int32Ty, Idx) };
+  Value *Indices[] = { Context->getConstantInt(Type::Int32Ty, 0),
+                       Context->getConstantInt(Type::Int32Ty, Idx) };
   Value *Val = B.CreateGEP(BasePtr, Indices, Indices + 2, Name);
 
   assert(isa<GetElementPtrInst>(Val) && "Unexpected folded constant");
@@ -363,6 +366,8 @@
 
 /// runOnFunction - Insert code to maintain the shadow stack.
 bool ShadowStackGC::performCustomLowering(Function &F) {
+  LLVMContext *Context = F.getContext();
+  
   // Find calls to llvm.gcroot.
   CollectRoots(F);
 
@@ -387,13 +392,14 @@
 
   // Initialize the map pointer and load the current head of the shadow stack.
   Instruction *CurrentHead  = AtEntry.CreateLoad(Head, "gc_currhead");
-  Instruction *EntryMapPtr  = CreateGEP(AtEntry, StackEntry,0,1,"gc_frame.map");
+  Instruction *EntryMapPtr  = CreateGEP(Context, AtEntry, StackEntry,
+                                        0,1,"gc_frame.map");
                               AtEntry.CreateStore(FrameMap, EntryMapPtr);
 
   // After all the allocas...
   for (unsigned I = 0, E = Roots.size(); I != E; ++I) {
     // For each root, find the corresponding slot in the aggregate...
-    Value *SlotPtr = CreateGEP(AtEntry, StackEntry, 1 + I, "gc_root");
+    Value *SlotPtr = CreateGEP(Context, AtEntry, StackEntry, 1 + I, "gc_root");
 
     // And use it in lieu of the alloca.
     AllocaInst *OriginalAlloca = Roots[I].second;
@@ -409,17 +415,19 @@
   AtEntry.SetInsertPoint(IP->getParent(), IP);
 
   // Push the entry onto the shadow stack.
-  Instruction *EntryNextPtr = CreateGEP(AtEntry,StackEntry,0,0,"gc_frame.next");
-  Instruction *NewHeadVal   = CreateGEP(AtEntry,StackEntry, 0, "gc_newhead");
-                              AtEntry.CreateStore(CurrentHead, EntryNextPtr);
-                              AtEntry.CreateStore(NewHeadVal, Head);
+  Instruction *EntryNextPtr = CreateGEP(Context, AtEntry,
+                                        StackEntry,0,0,"gc_frame.next");
+  Instruction *NewHeadVal   = CreateGEP(Context, AtEntry, 
+                                        StackEntry, 0, "gc_newhead");
+  AtEntry.CreateStore(CurrentHead, EntryNextPtr);
+  AtEntry.CreateStore(NewHeadVal, Head);
 
   // For each instruction that escapes...
   EscapeEnumerator EE(F, "gc_cleanup");
   while (IRBuilder<> *AtExit = EE.Next()) {
     // Pop the entry from the shadow stack. Don't reuse CurrentHead from
     // AtEntry, since that would make the value live for the entire function.
-    Instruction *EntryNextPtr2 = CreateGEP(*AtExit, StackEntry, 0, 0,
+    Instruction *EntryNextPtr2 = CreateGEP(Context, *AtExit, StackEntry, 0, 0,
                                            "gc_frame.next");
     Value *SavedHead = AtExit->CreateLoad(EntryNextPtr2, "gc_savedhead");
                        AtExit->CreateStore(SavedHead, Head);

Modified: llvm/trunk/lib/CodeGen/StackProtector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackProtector.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/StackProtector.cpp (original)
+++ llvm/trunk/lib/CodeGen/StackProtector.cpp Tue Jul 14 18:09:55 2009
@@ -154,7 +154,7 @@
       BasicBlock &Entry = F->getEntryBlock();
       Instruction *InsPt = &Entry.front();
 
-      AI = new AllocaInst(PtrTy, "StackGuardSlot", InsPt);
+      AI = new AllocaInst(*Context, PtrTy, "StackGuardSlot", InsPt);
       LoadInst *LI = new LoadInst(StackGuardVar, "StackGuard", false, InsPt);
 
       Value *Args[] = { LI, AI };

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

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Tue Jul 14 18:09:55 2009
@@ -351,6 +351,7 @@
 GenericValue JIT::runFunction(Function *F,
                               const std::vector<GenericValue> &ArgValues) {
   assert(F && "Function *F was null at entry to run()");
+  LLVMContext *Context = F->getContext();
 
   void *FPtr = getPointerToFunction(F);
   assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
@@ -452,7 +453,7 @@
   // arguments.  Make this function and return.
 
   // First, create the function.
-  FunctionType *STy=FunctionType::get(RetTy, false);
+  FunctionType *STy=Context->getFunctionType(RetTy, false);
   Function *Stub = Function::Create(STy, Function::InternalLinkage, "",
                                     F->getParent());
 
@@ -469,26 +470,27 @@
     switch (ArgTy->getTypeID()) {
     default: llvm_unreachable("Unknown argument type for function call!");
     case Type::IntegerTyID:
-        C = ConstantInt::get(AV.IntVal);
+        C = Context->getConstantInt(AV.IntVal);
         break;
     case Type::FloatTyID:
-        C = ConstantFP::get(APFloat(AV.FloatVal));
+        C = Context->getConstantFP(APFloat(AV.FloatVal));
         break;
     case Type::DoubleTyID:
-        C = ConstantFP::get(APFloat(AV.DoubleVal));
+        C = Context->getConstantFP(APFloat(AV.DoubleVal));
         break;
     case Type::PPC_FP128TyID:
     case Type::X86_FP80TyID:
     case Type::FP128TyID:
-        C = ConstantFP::get(APFloat(AV.IntVal));
+        C = Context->getConstantFP(APFloat(AV.IntVal));
         break;
     case Type::PointerTyID:
       void *ArgPtr = GVTOP(AV);
       if (sizeof(void*) == 4)
-        C = ConstantInt::get(Type::Int32Ty, (int)(intptr_t)ArgPtr);
+        C = Context->getConstantInt(Type::Int32Ty, (int)(intptr_t)ArgPtr);
       else
-        C = ConstantInt::get(Type::Int64Ty, (intptr_t)ArgPtr);
-      C = ConstantExpr::getIntToPtr(C, ArgTy);  // Cast the integer to pointer
+        C = Context->getConstantInt(Type::Int64Ty, (intptr_t)ArgPtr);
+      // Cast the integer to pointer
+      C = Context->getConstantExprIntToPtr(C, ArgTy);
       break;
     }
     Args.push_back(C);

Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Tue Jul 14 18:09:55 2009
@@ -20,6 +20,8 @@
 #include "ARMSubtarget.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
@@ -890,7 +892,8 @@
                   unsigned PredReg) const {
   MachineFunction &MF = *MBB.getParent();
   MachineConstantPool *ConstantPool = MF.getConstantPool();
-  Constant *C = ConstantInt::get(Type::Int32Ty, Val);
+  Constant *C =
+             MF.getFunction()->getContext()->getConstantInt(Type::Int32Ty, Val);
   unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
 
   BuildMI(MBB, MBBI, dl, TII.get(ARM::LDRcp), DestReg)

Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue Jul 14 18:09:55 2009
@@ -21,6 +21,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Function.h"
 #include "llvm/Intrinsics.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -865,7 +866,8 @@
                !ARM_AM::isSOImmTwoPartVal(Val));     // two instrs.
     if (UseCP) {
       SDValue CPIdx =
-        CurDAG->getTargetConstantPool(ConstantInt::get(Type::Int32Ty, Val),
+        CurDAG->getTargetConstantPool(
+                       CurDAG->getContext()->getConstantInt(Type::Int32Ty, Val),
                                       TLI.getPointerTy());
 
       SDNode *ResNode;

Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Tue Jul 14 18:09:55 2009
@@ -20,6 +20,8 @@
 #include "Thumb1RegisterInfo.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
@@ -65,7 +67,8 @@
                                            unsigned PredReg) const {
   MachineFunction &MF = *MBB.getParent();
   MachineConstantPool *ConstantPool = MF.getConstantPool();
-  Constant *C = ConstantInt::get(Type::Int32Ty, Val);
+  Constant *C =
+             MF.getFunction()->getContext()->getConstantInt(Type::Int32Ty, Val);
   unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
 
   BuildMI(MBB, MBBI, dl, TII.get(ARM::tLDRcp), DestReg)

Modified: llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp Tue Jul 14 18:09:55 2009
@@ -20,6 +20,8 @@
 #include "Thumb2RegisterInfo.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
@@ -49,7 +51,8 @@
                                            unsigned PredReg) const {
   MachineFunction &MF = *MBB.getParent();
   MachineConstantPool *ConstantPool = MF.getConstantPool();
-  Constant *C = ConstantInt::get(Type::Int32Ty, Val);
+  Constant *C = 
+             MF.getFunction()->getContext()->getConstantInt(Type::Int32Ty, Val);
   unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
 
   BuildMI(MBB, MBBI, dl, TII.get(ARM::t2LDRpci), DestReg)

Modified: llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp Tue Jul 14 18:09:55 2009
@@ -26,6 +26,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/GlobalValue.h"
 #include "llvm/Intrinsics.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -304,7 +305,7 @@
       // val32 >= IMM_LOW  + IMM_LOW  * IMM_MULT) //always true
       break; //(zext (LDAH (LDA)))
     //Else use the constant pool
-    ConstantInt *C = ConstantInt::get(Type::Int64Ty, uval);
+    ConstantInt *C = CurDAG->getContext()->getConstantInt(Type::Int64Ty, uval);
     SDValue CPI = CurDAG->getTargetConstantPool(C, MVT::i64);
     SDNode *Tmp = CurDAG->getTargetNode(Alpha::LDAHr, dl, MVT::i64, CPI,
                                         SDValue(getGlobalBaseReg(), 0));

Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Tue Jul 14 18:09:55 2009
@@ -3503,7 +3503,7 @@
     if (!ITy->isPowerOf2ByteWidth())
       // We have a bit width that doesn't match an even power-of-2 byte
       // size. Consequently we must & the value with the type's bit mask
-      BitMask = ConstantInt::get(ITy, ITy->getBitMask());
+      BitMask = Context->getConstantInt(ITy, ITy->getBitMask());
   if (BitMask)
     Out << "((";
   writeOperand(Operand);

Modified: llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp Tue Jul 14 18:09:55 2009
@@ -19,6 +19,7 @@
 #include "llvm/Intrinsics.h"
 #include "llvm/CallingConv.h"
 #include "llvm/Constants.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -173,7 +174,8 @@
         else if (! Predicate_immU16(N)) {
           unsigned Val = cast<ConstantSDNode>(N)->getZExtValue();
           SDValue CPIdx =
-            CurDAG->getTargetConstantPool(ConstantInt::get(Type::Int32Ty, Val),
+            CurDAG->getTargetConstantPool(
+                       CurDAG->getContext()->getConstantInt(Type::Int32Ty, Val),
                                           TLI.getPointerTy());
           return CurDAG->getTargetNode(XCore::LDWCP_lru6, dl, MVT::i32, 
                                        MVT::Other, CPIdx, 

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

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Tue Jul 14 18:09:55 2009
@@ -755,7 +755,7 @@
 
       // Just add all the struct element types.
       const Type *AgTy = cast<PointerType>(I->getType())->getElementType();
-      Value *TheAlloca = new AllocaInst(AgTy, 0, "", InsertPt);
+      Value *TheAlloca = new AllocaInst(*Context, AgTy, 0, "", InsertPt);
       const StructType *STy = cast<StructType>(AgTy);
       Value *Idxs[2] = { Context->getConstantInt(Type::Int32Ty, 0), 0 };
 

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

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Jul 14 18:09:55 2009
@@ -828,7 +828,7 @@
     Type *NewTy = Context->getArrayType(MI->getAllocatedType(),
                                  NElements->getZExtValue());
     MallocInst *NewMI =
-      new MallocInst(NewTy, Context->getNullValue(Type::Int32Ty),
+      new MallocInst(*Context, NewTy, Context->getNullValue(Type::Int32Ty),
                      MI->getAlignment(), MI->getName(), MI);
     Value* Indices[2];
     Indices[0] = Indices[1] = Context->getNullValue(Type::Int32Ty);
@@ -1291,7 +1291,7 @@
                          GV->isThreadLocal());
     FieldGlobals.push_back(NGV);
     
-    MallocInst *NMI = new MallocInst(FieldTy, MI->getArraySize(),
+    MallocInst *NMI = new MallocInst(*Context, FieldTy, MI->getArraySize(),
                                      MI->getName() + ".f" + utostr(FieldNo),MI);
     FieldMallocs.push_back(NMI);
     new StoreInst(NMI, NGV, MI);
@@ -1507,7 +1507,7 @@
       // structs.  malloc [100 x struct],1 -> malloc struct, 100
       if (const ArrayType *AT = dyn_cast<ArrayType>(MI->getAllocatedType())) {
         MallocInst *NewMI = 
-          new MallocInst(AllocSTy, 
+          new MallocInst(*Context, AllocSTy, 
                   Context->getConstantInt(Type::Int32Ty, AT->getNumElements()),
                          "", MI);
         NewMI->takeName(MI);
@@ -1703,7 +1703,8 @@
       Instruction* FirstI = GS.AccessingFunction->getEntryBlock().begin();
       const Type* ElemTy = GV->getType()->getElementType();
       // FIXME: Pass Global's alignment when globals have alignment
-      AllocaInst* Alloca = new AllocaInst(ElemTy, NULL, GV->getName(), FirstI);
+      AllocaInst* Alloca = new AllocaInst(*Context, ElemTy, NULL,
+                                          GV->getName(), FirstI);
       if (!isa<UndefValue>(GV->getInitializer()))
         new StoreInst(GV->getInitializer(), Alloca, FirstI);
 

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

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp Tue Jul 14 18:09:55 2009
@@ -1,4 +1,4 @@
-//===-- IndMemRemoval.cpp - Remove indirect allocations and frees ----------===//
+//===-- IndMemRemoval.cpp - Remove indirect allocations and frees ---------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -10,8 +10,8 @@
 // This pass finds places where memory allocation functions may escape into
 // indirect land.  Some transforms are much easier (aka possible) only if free 
 // or malloc are not called indirectly.
-// Thus find places where the address of memory functions are taken and construct
-// bounce functions with direct calls of those functions.
+// Thus find places where the address of memory functions are taken and 
+// construct bounce functions with direct calls of those functions.
 //
 //===----------------------------------------------------------------------===//
 
@@ -73,7 +73,7 @@
       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);
+      Instruction* a = new MallocInst(*Context, Type::Int8Ty, c, "m", bb);
       ReturnInst::Create(a, bb);
       ++NumBounce;
       NumBounceSites += F->getNumUses();

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

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp Tue Jul 14 18:09:55 2009
@@ -311,7 +311,7 @@
 
   // Fill in the alloca and call to initialize the SJ map.
   const Type *SBPTy = Context->getPointerTypeUnqual(Type::Int8Ty);
-  AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
+  AllocaInst* Map = new AllocaInst(*Context, SBPTy, 0, "SJMap", Inst);
   CallInst::Create(InitSJMap, Map, "", Inst);
   return SJMap[Func] = Map;
 }
@@ -408,7 +408,7 @@
          UI != E; ++UI)
       if (cast<Instruction>(*UI)->getParent() != ABlock ||
           InstrsAfterCall.count(cast<Instruction>(*UI))) {
-        DemoteRegToStack(*II);
+        DemoteRegToStack(*Context, *II);
         break;
       }
   InstrsAfterCall.clear();

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

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp Tue Jul 14 18:09:55 2009
@@ -169,7 +169,8 @@
               CastInst::CreateIntegerCast(Source, Type::Int32Ty, false/*ZExt*/,
                                           "MallocAmtCast", I);
 
-          MallocInst *MI = new MallocInst(Type::Int8Ty, Source, "", I);
+          MallocInst *MI = new MallocInst(*Context, Type::Int8Ty,
+                                          Source, "", I);
           MI->takeName(I);
           I->replaceAllUsesWith(MI);
 

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

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp Tue Jul 14 18:09:55 2009
@@ -110,7 +110,7 @@
   DOUT << "SretPromotion: sret argument will be promoted\n";
   NumSRET++;
   // [1] Replace use of sret parameter 
-  AllocaInst *TheAlloca = new AllocaInst (STy, NULL, "mrv", 
+  AllocaInst *TheAlloca = new AllocaInst (*Context, STy, NULL, "mrv", 
                                           F->getEntryBlock().begin());
   Value *NFirstArg = F->arg_begin();
   NFirstArg->replaceAllUsesWith(TheAlloca);

Modified: llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Tue Jul 14 18:09:55 2009
@@ -248,7 +248,7 @@
   //make a local temporary to cache the global
   BasicBlock& bb = F->getEntryBlock();
   BasicBlock::iterator InsertPt = bb.begin();
-  AI = new AllocaInst(T, 0, "localcounter", InsertPt);
+  AI = new AllocaInst(*F->getContext(), T, 0, "localcounter", InsertPt);
   LoadInst* l = new LoadInst(Counter, "counterload", InsertPt);
   new StoreInst(l, AI, InsertPt);
   

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jul 14 18:09:55 2009
@@ -1756,8 +1756,10 @@
           Value *LHS = II->getOperand(1);
           Value *RHS = II->getOperand(2);
           // Extract the element as scalars.
-          LHS = InsertNewInstBefore(new ExtractElementInst(LHS, 0U,"tmp"), *II);
-          RHS = InsertNewInstBefore(new ExtractElementInst(RHS, 0U,"tmp"), *II);
+          LHS = InsertNewInstBefore(new ExtractElementInst(LHS, 
+            Context->getConstantInt(Type::Int32Ty, 0U, false), "tmp"), *II);
+          RHS = InsertNewInstBefore(new ExtractElementInst(RHS,
+            Context->getConstantInt(Type::Int32Ty, 0U, false), "tmp"), *II);
           
           switch (II->getIntrinsicID()) {
           default: llvm_unreachable("Case stmts out of sync!");
@@ -1775,7 +1777,8 @@
           
           Instruction *New =
             InsertElementInst::Create(
-              Context->getUndef(II->getType()), TmpV, 0U, II->getName());
+              Context->getUndef(II->getType()), TmpV,
+              Context->getConstantInt(Type::Int32Ty, 0U, false), II->getName());
           InsertNewInstBefore(New, *II);
           AddSoonDeadInstToWorklist(*II, 0);
           return New;
@@ -7888,9 +7891,9 @@
   
   AllocationInst *New;
   if (isa<MallocInst>(AI))
-    New = new MallocInst(CastElTy, Amt, AI.getAlignment());
+    New = new MallocInst(*Context, CastElTy, Amt, AI.getAlignment());
   else
-    New = new AllocaInst(CastElTy, Amt, AI.getAlignment());
+    New = new AllocaInst(*Context, CastElTy, Amt, AI.getAlignment());
   InsertNewInstBefore(New, AI);
   New->takeName(&AI);
   
@@ -9974,14 +9977,16 @@
           
           if (ExtractedElts[Idx] == 0) {
             Instruction *Elt = 
-              new ExtractElementInst(Idx < 16 ? Op0 : Op1, Idx&15, "tmp");
+              new ExtractElementInst(Idx < 16 ? Op0 : Op1, 
+                  Context->getConstantInt(Type::Int32Ty, Idx&15, false), "tmp");
             InsertNewInstBefore(Elt, CI);
             ExtractedElts[Idx] = Elt;
           }
         
           // Insert this value into the result vector.
           Result = InsertElementInst::Create(Result, ExtractedElts[Idx],
-                                             i, "tmp");
+                               Context->getConstantInt(Type::Int32Ty, i, false), 
+                               "tmp");
           InsertNewInstBefore(cast<Instruction>(Result), CI);
         }
         return CastInst::Create(Instruction::BitCast, Result, CI.getType());
@@ -11363,10 +11368,12 @@
 
       // Create and insert the replacement instruction...
       if (isa<MallocInst>(AI))
-        New = new MallocInst(NewTy, 0, AI.getAlignment(), AI.getName());
+        New = new MallocInst(*Context, NewTy, 0,
+                             AI.getAlignment(), AI.getName());
       else {
         assert(isa<AllocaInst>(AI) && "Unknown type of allocation inst!");
-        New = new AllocaInst(NewTy, 0, AI.getAlignment(), AI.getName());
+        New = new AllocaInst(*Context, NewTy, 0,
+                             AI.getAlignment(), AI.getName());
       }
 
       InsertNewInstBefore(New, AI);
@@ -12475,7 +12482,8 @@
         } else {
           return ReplaceInstUsesWith(EI, Context->getUndef(EI.getType()));
         }
-        return new ExtractElementInst(Src, SrcIdx);
+        return new ExtractElementInst(Src,
+                         Context->getConstantInt(Type::Int32Ty, SrcIdx, false));
       }
     }
   }

Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Jul 14 18:09:55 2009
@@ -912,7 +912,7 @@
     
     // We found a use of I outside of BB.  Create a new stack slot to
     // break this inter-block usage pattern.
-    DemoteRegToStack(*I);
+    DemoteRegToStack(*Context, *I);
   }
  
   // We are going to have to map operands from the original BB block to the new

Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Tue Jul 14 18:09:55 2009
@@ -508,7 +508,7 @@
     AllocaInst *AI = 0;
 
     if (I.getType() != Type::VoidTy) {
-      AI = new AllocaInst(I.getType(), 0, I.getName(),
+      AI = new AllocaInst(*Context, I.getType(), 0, I.getName(),
                           I.getParent()->getParent()->getEntryBlock().begin());
       CurAST->add(AI);
     }
@@ -853,7 +853,8 @@
       continue;
     
     const Type *Ty = cast<PointerType>(V->getType())->getElementType();
-    AllocaInst *AI = new AllocaInst(Ty, 0, V->getName()+".tmp", FnStart);
+    AllocaInst *AI = new AllocaInst(*Context, Ty, 0,
+                                    V->getName()+".tmp", FnStart);
     PromotedValues.push_back(std::make_pair(AI, V));
 
     // Update the AST and alias analysis.

Modified: llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp Tue Jul 14 18:09:55 2009
@@ -1891,7 +1891,7 @@
         assert(!Ty->isFPOrFPVector() && "Float in work queue!");
 
         Constant *Zero = Context->getNullValue(Ty);
-        Constant *One = ConstantInt::get(Ty, 1);
+        Constant *One = Context->getConstantInt(Ty, 1);
         ConstantInt *AllOnes = cast<ConstantInt>(Context->getAllOnesValue(Ty));
 
         switch (Opcode) {

Modified: llvm/trunk/lib/Transforms/Scalar/Reg2Mem.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reg2Mem.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Reg2Mem.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Reg2Mem.cpp Tue Jul 14 18:09:55 2009
@@ -89,7 +89,7 @@
         NumRegsDemoted += worklist.size();
         for (std::list<Instruction*>::iterator ilb = worklist.begin(), 
                ile = worklist.end(); ilb != ile; ++ilb)
-          DemoteRegToStack(**ilb, false, AllocaInsertionPoint);
+          DemoteRegToStack(*Context, **ilb, false, AllocaInsertionPoint);
 
         worklist.clear();
 
@@ -105,7 +105,7 @@
         NumPhisDemoted += worklist.size();
         for (std::list<Instruction*>::iterator ilb = worklist.begin(), 
                ile = worklist.end(); ilb != ile; ++ilb)
-          DemotePHIToStack(cast<PHINode>(*ilb), AllocaInsertionPoint);
+          DemotePHIToStack(*Context, cast<PHINode>(*ilb), AllocaInsertionPoint);
 
         return true;
       }

Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Tue Jul 14 18:09:55 2009
@@ -302,14 +302,16 @@
         DOUT << "CONVERT TO VECTOR: " << *AI << "  TYPE = " << *VectorTy <<"\n";
         
         // Create and insert the vector alloca.
-        NewAI = new AllocaInst(VectorTy, 0, "", AI->getParent()->begin());
+        NewAI = new AllocaInst(*Context, VectorTy, 0, "", 
+                               AI->getParent()->begin());
         ConvertUsesToScalar(AI, NewAI, 0);
       } else {
         DOUT << "CONVERT TO SCALAR INTEGER: " << *AI << "\n";
         
         // Create and insert the integer alloca.
         const Type *NewTy = Context->getIntegerType(AllocaSize*8);
-        NewAI = new AllocaInst(NewTy, 0, "", AI->getParent()->begin());
+        NewAI = new AllocaInst(*Context, NewTy, 0, "", 
+                               AI->getParent()->begin());
         ConvertUsesToScalar(AI, NewAI, 0);
       }
       NewAI->takeName(AI);
@@ -334,7 +336,8 @@
   if (const StructType *ST = dyn_cast<StructType>(AI->getAllocatedType())) {
     ElementAllocas.reserve(ST->getNumContainedTypes());
     for (unsigned i = 0, e = ST->getNumContainedTypes(); i != e; ++i) {
-      AllocaInst *NA = new AllocaInst(ST->getContainedType(i), 0, 
+      AllocaInst *NA = new AllocaInst(*Context,
+                                      ST->getContainedType(i), 0, 
                                       AI->getAlignment(),
                                       AI->getName() + "." + utostr(i), AI);
       ElementAllocas.push_back(NA);
@@ -345,7 +348,7 @@
     ElementAllocas.reserve(AT->getNumElements());
     const Type *ElTy = AT->getElementType();
     for (unsigned i = 0, e = AT->getNumElements(); i != e; ++i) {
-      AllocaInst *NA = new AllocaInst(ElTy, 0, AI->getAlignment(),
+      AllocaInst *NA = new AllocaInst(*Context, ElTy, 0, AI->getAlignment(),
                                       AI->getName() + "." + utostr(i), AI);
       ElementAllocas.push_back(NA);
       WorkList.push_back(NA);  // Add to worklist for recursive processing

Modified: llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp Tue Jul 14 18:09:55 2009
@@ -285,7 +285,7 @@
     if (I->isUsedOutsideOfBlock(DestBlock)) {
       // We found a use outside of the tail.  Create a new stack slot to
       // break this inter-block usage pattern.
-      DemoteRegToStack(*I);
+      DemoteRegToStack(*Context, *I);
     }
 
   // We are going to have to map operands from the original block B to the new

Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Tue Jul 14 18:09:55 2009
@@ -372,7 +372,8 @@
       StructValues.push_back(*i);
     } else {
       AllocaInst *alloca =
-        new AllocaInst((*i)->getType(), 0, (*i)->getName()+".loc",
+        new AllocaInst(*codeReplacer->getContext(), 
+                       (*i)->getType(), 0, (*i)->getName()+".loc",
                        codeReplacer->getParent()->begin()->begin());
       ReloadOutputs.push_back(alloca);
       params.push_back(alloca);
@@ -389,7 +390,7 @@
     // Allocate a struct at the beginning of this function
     Type *StructArgTy = Context->getStructType(ArgTypes);
     Struct =
-      new AllocaInst(StructArgTy, 0, "structArg",
+      new AllocaInst(*codeReplacer->getContext(), StructArgTy, 0, "structArg",
                      codeReplacer->getParent()->begin()->begin());
     params.push_back(Struct);
 

Modified: llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp Tue Jul 14 18:09:55 2009
@@ -29,7 +29,8 @@
 /// invalidating the SSA information for the value.  It returns the pointer to
 /// the alloca inserted to create a stack slot for I.
 ///
-AllocaInst* llvm::DemoteRegToStack(Instruction &I, bool VolatileLoads,
+AllocaInst* llvm::DemoteRegToStack(LLVMContext &Context, 
+                                   Instruction &I, bool VolatileLoads,
                                    Instruction *AllocaPoint) {
   if (I.use_empty()) {
     I.eraseFromParent();
@@ -39,10 +40,11 @@
   // Create a stack slot to hold the value.
   AllocaInst *Slot;
   if (AllocaPoint) {
-    Slot = new AllocaInst(I.getType(), 0, I.getName()+".reg2mem", AllocaPoint);
+    Slot = new AllocaInst(Context, I.getType(), 0,
+                          I.getName()+".reg2mem", AllocaPoint);
   } else {
     Function *F = I.getParent()->getParent();
-    Slot = new AllocaInst(I.getType(), 0, I.getName()+".reg2mem",
+    Slot = new AllocaInst(Context, I.getType(), 0, I.getName()+".reg2mem",
                           F->getEntryBlock().begin());
   }
   
@@ -107,7 +109,8 @@
 /// DemotePHIToStack - This function takes a virtual register computed by a phi
 /// node and replaces it with a slot in the stack frame, allocated via alloca.
 /// The phi node is deleted and it returns the pointer to the alloca inserted.
-AllocaInst* llvm::DemotePHIToStack(PHINode *P, Instruction *AllocaPoint) {
+AllocaInst* llvm::DemotePHIToStack(LLVMContext &Context, PHINode *P,
+                                   Instruction *AllocaPoint) {
   if (P->use_empty()) {
     P->eraseFromParent();    
     return 0;                
@@ -116,10 +119,11 @@
   // Create a stack slot to hold the value.
   AllocaInst *Slot;
   if (AllocaPoint) {
-    Slot = new AllocaInst(P->getType(), 0, P->getName()+".reg2mem", AllocaPoint);
+    Slot = new AllocaInst(Context, P->getType(), 0,
+                          P->getName()+".reg2mem", AllocaPoint);
   } else {
     Function *F = P->getParent()->getParent();
-    Slot = new AllocaInst(P->getType(), 0, P->getName()+".reg2mem",
+    Slot = new AllocaInst(Context, P->getType(), 0, P->getName()+".reg2mem",
                           F->getEntryBlock().begin());
   }
   

Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Tue Jul 14 18:09:55 2009
@@ -309,8 +309,9 @@
         // Create the alloca.  If we have TargetData, use nice alignment.
         unsigned Align = 1;
         if (TD) Align = TD->getPrefTypeAlignment(AggTy);
-        Value *NewAlloca = new AllocaInst(AggTy, 0, Align, I->getName(),
-                                          Caller->begin()->begin());
+        Value *NewAlloca = new AllocaInst(*Context, AggTy, 0, Align, 
+                                          I->getName(), 
+                                          &*Caller->begin()->begin());
         // Emit a memcpy.
         const Type *Tys[] = { Type::Int64Ty };
         Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(),

Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Tue Jul 14 18:09:55 2009
@@ -266,7 +266,7 @@
 void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
                                          AllocaInst *InvokeNum,
                                          SwitchInst *CatchSwitch) {
-  ConstantInt *InvokeNoC = ConstantInt::get(Type::Int32Ty, InvokeNo);
+  ConstantInt *InvokeNoC = Context->getConstantInt(Type::Int32Ty, InvokeNo);
 
   // If the unwind edge has phi nodes, split the edge.
   if (isa<PHINode>(II->getUnwindDest()->begin())) {
@@ -417,7 +417,7 @@
       // If we decided we need a spill, do it.
       if (NeedsSpill) {
         ++NumSpilled;
-        DemoteRegToStack(*Inst, true);
+        DemoteRegToStack(*Context, *Inst, true);
       }
     }
 }
@@ -470,13 +470,15 @@
     // alloca because the value needs to be live across invokes.
     unsigned Align = TLI ? TLI->getJumpBufAlignment() : 0;
     AllocaInst *JmpBuf =
-      new AllocaInst(JBLinkTy, 0, Align, "jblink", F.begin()->begin());
+      new AllocaInst(*Context, JBLinkTy, 0, Align,
+                     "jblink", F.begin()->begin());
 
     std::vector<Value*> Idx;
     Idx.push_back(Context->getNullValue(Type::Int32Ty));
-    Idx.push_back(ConstantInt::get(Type::Int32Ty, 1));
+    Idx.push_back(Context->getConstantInt(Type::Int32Ty, 1));
     OldJmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(),
-                                             "OldBuf", EntryBB->getTerminator());
+                                             "OldBuf",
+                                              EntryBB->getTerminator());
 
     // Copy the JBListHead to the alloca.
     Value *OldBuf = new LoadInst(JBListHead, "oldjmpbufptr", true,
@@ -492,9 +494,9 @@
 
     // Create an alloca which keeps track of which invoke is currently
     // executing.  For normal calls it contains zero.
-    AllocaInst *InvokeNum = new AllocaInst(Type::Int32Ty, 0, "invokenum",
-                                           EntryBB->begin());
-    new StoreInst(ConstantInt::get(Type::Int32Ty, 0), InvokeNum, true,
+    AllocaInst *InvokeNum = new AllocaInst(*Context, Type::Int32Ty, 0,
+                                           "invokenum",EntryBB->begin());
+    new StoreInst(Context->getConstantInt(Type::Int32Ty, 0), InvokeNum, true,
                   EntryBB->getTerminator());
 
     // Insert a load in the Catch block, and a switch on its value.  By default,
@@ -513,7 +515,7 @@
     BasicBlock *ContBlock = EntryBB->splitBasicBlock(EntryBB->getTerminator(),
                                                      "setjmp.cont");
 
-    Idx[1] = ConstantInt::get(Type::Int32Ty, 0);
+    Idx[1] = Context->getConstantInt(Type::Int32Ty, 0);
     Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(),
                                                  "TheJmpBuf",
                                                  EntryBB->getTerminator());
@@ -567,12 +569,12 @@
   // Get a pointer to the jmpbuf and longjmp.
   std::vector<Value*> Idx;
   Idx.push_back(Context->getNullValue(Type::Int32Ty));
-  Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
+  Idx.push_back(Context->getConstantInt(Type::Int32Ty, 0));
   Idx[0] = GetElementPtrInst::Create(BufPtr, Idx.begin(), Idx.end(), "JmpBuf",
                                      UnwindBlock);
   Idx[0] = new BitCastInst(Idx[0], PointerType::getUnqual(Type::Int8Ty),
                            "tmp", UnwindBlock);
-  Idx[1] = ConstantInt::get(Type::Int32Ty, 1);
+  Idx[1] = Context->getConstantInt(Type::Int32Ty, 1);
   CallInst::Create(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock);
   new UnreachableInst(UnwindBlock);
 

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

==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Tue Jul 14 18:09:55 2009
@@ -181,8 +181,8 @@
 
 ConstantInt *ConstantInt::CreateTrueFalseVals(bool WhichOne) {
   assert(TheTrueVal == 0 && TheFalseVal == 0);
-  TheTrueVal  = get(Type::Int1Ty, 1);
-  TheFalseVal = get(Type::Int1Ty, 0);
+  TheTrueVal  = getGlobalContext().getConstantInt(Type::Int1Ty, 1);
+  TheFalseVal = getGlobalContext().getConstantInt(Type::Int1Ty, 0);
   
   // Ensure that llvm_shutdown nulls out TheTrueVal/TheFalseVal.
   TrueFalseCleanup.Register();
@@ -223,22 +223,6 @@
                  DenseMapAPIntKeyInfo> IntMapTy;
 static ManagedStatic<IntMapTy> IntConstants;
 
-ConstantInt *ConstantInt::get(const IntegerType *Ty,
-                              uint64_t V, bool isSigned) {
-  return get(APInt(Ty->getBitWidth(), V, isSigned));
-}
-
-Constant *ConstantInt::get(const Type *Ty, uint64_t V, bool isSigned) {
-  Constant *C = get(cast<IntegerType>(Ty->getScalarType()), V, isSigned);
-
-  // For vectors, broadcast the value.
-  if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
-    return
-      ConstantVector::get(std::vector<Constant *>(VTy->getNumElements(), C));
-
-  return C;
-}
-
 // Get a ConstantInt from an APInt. Note that the value stored in the DenseMap 
 // as the key, is a DenseMapAPIntKeyInfo::KeyTy which has provided the
 // operator== and operator!= to ensure that the DenseMap doesn't attempt to
@@ -267,19 +251,6 @@
   }
 }
 
-Constant *ConstantInt::get(const Type *Ty, const APInt &V) {
-  ConstantInt *C = ConstantInt::get(V);
-  assert(C->getType() == Ty->getScalarType() &&
-         "ConstantInt type doesn't match the type implied by its value!");
-
-  // For vectors, broadcast the value.
-  if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
-    return
-      ConstantVector::get(std::vector<Constant *>(VTy->getNumElements(), C));
-
-  return C;
-}
-
 //===----------------------------------------------------------------------===//
 //                                ConstantFP
 //===----------------------------------------------------------------------===//
@@ -1307,26 +1278,6 @@
   destroyConstantImpl();
 }
 
-/// ConstantArray::get(const string&) - Return an array that is initialized to
-/// contain the specified string.  If length is zero then a null terminator is 
-/// added to the specified string so that it may be used in a natural way. 
-/// Otherwise, the length parameter specifies how much of the string to use 
-/// and it won't be null terminated.
-///
-Constant *ConstantArray::get(const std::string &Str, bool AddNull) {
-  std::vector<Constant*> ElementVals;
-  for (unsigned i = 0; i < Str.length(); ++i)
-    ElementVals.push_back(ConstantInt::get(Type::Int8Ty, Str[i]));
-
-  // Add a null terminator to the string...
-  if (AddNull) {
-    ElementVals.push_back(ConstantInt::get(Type::Int8Ty, 0));
-  }
-
-  ArrayType *ATy = ArrayType::get(Type::Int8Ty, ElementVals.size());
-  return ConstantArray::get(ATy, ElementVals);
-}
-
 /// isString - This method returns true if the array is an array of i8, and 
 /// if the elements of the array are all ConstantInt's.
 bool ConstantArray::isString() const {

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

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Tue Jul 14 18:09:55 2009
@@ -700,9 +700,9 @@
 //                        AllocationInst Implementation
 //===----------------------------------------------------------------------===//
 
-static Value *getAISize(Value *Amt) {
+static Value *getAISize(LLVMContext &Context, Value *Amt) {
   if (!Amt)
-    Amt = ConstantInt::get(Type::Int32Ty, 1);
+    Amt = Context.getConstantInt(Type::Int32Ty, 1);
   else {
     assert(!isa<BasicBlock>(Amt) &&
            "Passed basic block into allocation size parameter! Use other ctor");
@@ -712,21 +712,25 @@
   return Amt;
 }
 
-AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
+AllocationInst::AllocationInst(LLVMContext &C, 
+                               const Type *Ty, Value *ArraySize, unsigned iTy,
                                unsigned Align, const std::string &Name,
                                Instruction *InsertBefore)
-  : UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(ArraySize),
-                     InsertBefore) {
+  : UnaryInstruction(PointerType::getUnqual(Ty), iTy,
+                     getAISize(Context, ArraySize), InsertBefore),
+    Context(C) {
   setAlignment(Align);
   assert(Ty != Type::VoidTy && "Cannot allocate void!");
   setName(Name);
 }
 
-AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
+AllocationInst::AllocationInst(LLVMContext &C,
+                               const Type *Ty, Value *ArraySize, unsigned iTy,
                                unsigned Align, const std::string &Name,
                                BasicBlock *InsertAtEnd)
-  : UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(ArraySize),
-                     InsertAtEnd) {
+  : UnaryInstruction(PointerType::getUnqual(Ty), iTy,
+                     getAISize(Context, ArraySize), InsertAtEnd),
+    Context(C) {
   setAlignment(Align);
   assert(Ty != Type::VoidTy && "Cannot allocate void!");
   setName(Name);
@@ -753,8 +757,9 @@
 }
 
 AllocaInst::AllocaInst(const AllocaInst &AI)
-  : AllocationInst(AI.getType()->getElementType(), (Value*)AI.getOperand(0),
-                   Instruction::Alloca, AI.getAlignment()) {
+  : AllocationInst(AI.Context, AI.getType()->getElementType(),    
+                   (Value*)AI.getOperand(0), Instruction::Alloca,
+                   AI.getAlignment()) {
 }
 
 /// isStaticAlloca - Return true if this alloca is in the entry block of the
@@ -770,8 +775,9 @@
 }
 
 MallocInst::MallocInst(const MallocInst &MI)
-  : AllocationInst(MI.getType()->getElementType(), (Value*)MI.getOperand(0),
-                   Instruction::Malloc, MI.getAlignment()) {
+  : AllocationInst(MI.Context, MI.getType()->getElementType(), 
+                   (Value*)MI.getOperand(0), Instruction::Malloc,
+                   MI.getAlignment()) {
 }
 
 //===----------------------------------------------------------------------===//
@@ -1173,22 +1179,6 @@
   setName(Name);
 }
 
-ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
-                                       const std::string &Name,
-                                       Instruction *InsertBef)
-  : Instruction(cast<VectorType>(Val->getType())->getElementType(),
-                ExtractElement,
-                OperandTraits<ExtractElementInst>::op_begin(this),
-                2, InsertBef) {
-  Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
-  assert(isValidOperands(Val, Index) &&
-         "Invalid extractelement instruction operands!");
-  Op<0>() = Val;
-  Op<1>() = Index;
-  setName(Name);
-}
-
-
 ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
                                        const std::string &Name,
                                        BasicBlock *InsertAE)
@@ -1204,22 +1194,6 @@
   setName(Name);
 }
 
-ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
-                                       const std::string &Name,
-                                       BasicBlock *InsertAE)
-  : Instruction(cast<VectorType>(Val->getType())->getElementType(),
-                ExtractElement,
-                OperandTraits<ExtractElementInst>::op_begin(this),
-                2, InsertAE) {
-  Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
-  assert(isValidOperands(Val, Index) &&
-         "Invalid extractelement instruction operands!");
-  
-  Op<0>() = Val;
-  Op<1>() = Index;
-  setName(Name);
-}
-
 
 bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
   if (!isa<VectorType>(Val->getType()) || Index->getType() != Type::Int32Ty)
@@ -1253,22 +1227,6 @@
   setName(Name);
 }
 
-InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
-                                     const std::string &Name,
-                                     Instruction *InsertBef)
-  : Instruction(Vec->getType(), InsertElement,
-                OperandTraits<InsertElementInst>::op_begin(this),
-                3, InsertBef) {
-  Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
-  assert(isValidOperands(Vec, Elt, Index) &&
-         "Invalid insertelement instruction operands!");
-  Op<0>() = Vec;
-  Op<1>() = Elt;
-  Op<2>() = Index;
-  setName(Name);
-}
-
-
 InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
                                      const std::string &Name,
                                      BasicBlock *InsertAE)
@@ -1284,22 +1242,6 @@
   setName(Name);
 }
 
-InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
-                                     const std::string &Name,
-                                     BasicBlock *InsertAE)
-: Instruction(Vec->getType(), InsertElement,
-              OperandTraits<InsertElementInst>::op_begin(this),
-              3, InsertAE) {
-  Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
-  assert(isValidOperands(Vec, Elt, Index) &&
-         "Invalid insertelement instruction operands!");
-  
-  Op<0>() = Vec;
-  Op<1>() = Elt;
-  Op<2>() = Index;
-  setName(Name);
-}
-
 bool InsertElementInst::isValidOperands(const Value *Vec, const Value *Elt, 
                                         const Value *Index) {
   if (!isa<VectorType>(Vec->getType()))

Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContext.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContext.cpp Tue Jul 14 18:09:55 2009
@@ -90,18 +90,30 @@
 
 Constant* LLVMContext::getConstantInt(const Type* Ty, uint64_t V,
                                          bool isSigned) {
-  return ConstantInt::get(Ty, V, isSigned);
+  Constant *C = getConstantInt(cast<IntegerType>(Ty->getScalarType()),
+                               V, isSigned);
+
+  // For vectors, broadcast the value.
+  if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
+    return
+      getConstantVector(std::vector<Constant *>(VTy->getNumElements(), C));
+
+  return C;
 }
 
 
 ConstantInt* LLVMContext::getConstantInt(const IntegerType* Ty, uint64_t V,
                                          bool isSigned) {
-  return ConstantInt::get(Ty, V, isSigned);
+  return getConstantInt(APInt(Ty->getBitWidth(), V, isSigned));
 }
 
 ConstantInt* LLVMContext::getConstantIntSigned(const IntegerType* Ty,
                                                int64_t V) {
-  return ConstantInt::getSigned(Ty, V);
+  return getConstantInt(Ty, V, true);
+}
+
+Constant *LLVMContext::getConstantIntSigned(const Type *Ty, int64_t V) {
+  return getConstantInt(Ty, V, true);
 }
 
 ConstantInt* LLVMContext::getConstantInt(const APInt& V) {
@@ -109,7 +121,16 @@
 }
 
 Constant* LLVMContext::getConstantInt(const Type* Ty, const APInt& V) {
-  return ConstantInt::get(Ty, V);
+  ConstantInt *C = getConstantInt(V);
+  assert(C->getType() == Ty->getScalarType() &&
+         "ConstantInt type doesn't match the type implied by its value!");
+
+  // For vectors, broadcast the value.
+  if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
+    return
+      ConstantVector::get(std::vector<Constant *>(VTy->getNumElements(), C));
+
+  return C;
 }
 
 // ConstantPointerNull accessors.
@@ -153,9 +174,25 @@
   return ConstantArray::get(T, Vals, NumVals);
 }
 
-Constant* LLVMContext::getConstantArray(const std::string& Initializer,
+/// ConstantArray::get(const string&) - Return an array that is initialized to
+/// contain the specified string.  If length is zero then a null terminator is 
+/// added to the specified string so that it may be used in a natural way. 
+/// Otherwise, the length parameter specifies how much of the string to use 
+/// and it won't be null terminated.
+///
+Constant* LLVMContext::getConstantArray(const std::string& Str,
                                         bool AddNull) {
-  return ConstantArray::get(Initializer, AddNull);
+  std::vector<Constant*> ElementVals;
+  for (unsigned i = 0; i < Str.length(); ++i)
+    ElementVals.push_back(getConstantInt(Type::Int8Ty, Str[i]));
+
+  // Add a null terminator to the string...
+  if (AddNull) {
+    ElementVals.push_back(getConstantInt(Type::Int8Ty, 0));
+  }
+
+  ArrayType *ATy = getArrayType(Type::Int8Ty, ElementVals.size());
+  return getConstantArray(ATy, ElementVals);
 }
 
 

Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Tue Jul 14 18:09:55 2009
@@ -74,7 +74,7 @@
 
   // If this instruction produces a value, replace any users with null values
   if (isa<StructType>(TheInst->getType()))
-    TheInst->replaceAllUsesWith(UndefValue::get(TheInst->getType()));
+    TheInst->replaceAllUsesWith(Context.getUndef(TheInst->getType()));
   else if (TheInst->getType() != Type::VoidTy)
     TheInst->replaceAllUsesWith(Context.getNullValue(TheInst->getType()));
 
@@ -183,14 +183,15 @@
 /// as a constant array.
 static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) {
   assert(!TorList.empty() && "Don't create empty tor list!");
+  LLVMContext &Context = *TorList[0].first->getContext();
   std::vector<Constant*> ArrayElts;
   for (unsigned i = 0, e = TorList.size(); i != e; ++i) {
     std::vector<Constant*> Elts;
-    Elts.push_back(ConstantInt::get(Type::Int32Ty, TorList[i].second));
+    Elts.push_back(Context.getConstantInt(Type::Int32Ty, TorList[i].second));
     Elts.push_back(TorList[i].first);
-    ArrayElts.push_back(ConstantStruct::get(Elts));
+    ArrayElts.push_back(Context.getConstantStruct(Elts));
   }
-  return ConstantArray::get(ArrayType::get(ArrayElts[0]->getType(), 
+  return Context.getConstantArray(Context.getArrayType(ArrayElts[0]->getType(), 
                                            ArrayElts.size()),
                             ArrayElts);
 }

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

==============================================================================
--- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original)
+++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Tue Jul 14 18:09:55 2009
@@ -67,7 +67,7 @@
     BD.EmitProgressBitcode("pass-error",  false);
     exit(BD.debugOptimizerCrash());
   }
-
+  
   // Check to see if the finished program matches the reference output...
   if (BD.diffProgram(BitcodeResult, "", true /*delete bitcode*/)) {
     std::cout << " nope.\n";
@@ -640,6 +640,8 @@
 ///
 static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
                                      Module *Safe) {
+  LLVMContext &Context = BD.getContext(); 
+  
   // Clean up the modules, removing extra cruft that we don't need anymore...
   Test = BD.performFinalCleanups(Test);
 
@@ -689,8 +691,8 @@
   // Prototype: void *getPointerToNamedFunction(const char* Name)
   Constant *resolverFunc =
     Safe->getOrInsertFunction("getPointerToNamedFunction",
-                              PointerType::getUnqual(Type::Int8Ty),
-                              PointerType::getUnqual(Type::Int8Ty), (Type *)0);
+                        Context.getPointerTypeUnqual(Type::Int8Ty),
+                        Context.getPointerTypeUnqual(Type::Int8Ty), (Type *)0);
 
   // Use the function we just added to get addresses of functions we need.
   for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
@@ -701,7 +703,7 @@
       // Don't forward functions which are external in the test module too.
       if (TestFn && !TestFn->isDeclaration()) {
         // 1. Add a string constant with its name to the global file
-        Constant *InitArray = ConstantArray::get(F->getName());
+        Constant *InitArray = Context.getConstantArray(F->getName());
         GlobalVariable *funcName =
           new GlobalVariable(*Safe, InitArray->getType(), true /*isConstant*/,
                              GlobalValue::InternalLinkage, InitArray,
@@ -711,9 +713,9 @@
         // sbyte* so it matches the signature of the resolver function.
 
         // GetElementPtr *funcName, ulong 0, ulong 0
-        std::vector<Constant*> GEPargs(2,
-                                   BD.getContext().getNullValue(Type::Int32Ty));
-        Value *GEP = ConstantExpr::getGetElementPtr(funcName, &GEPargs[0], 2);
+        std::vector<Constant*> GEPargs(2, Context.getNullValue(Type::Int32Ty));
+        Value *GEP =
+                Context.getConstantExprGetElementPtr(funcName, &GEPargs[0], 2);
         std::vector<Value*> ResolverArgs;
         ResolverArgs.push_back(GEP);
 
@@ -721,7 +723,7 @@
         // function that dynamically resolves the calls to F via our JIT API
         if (!F->use_empty()) {
           // Create a new global to hold the cached function pointer.
-          Constant *NullPtr = ConstantPointerNull::get(F->getType());
+          Constant *NullPtr = Context.getConstantPointerNull(F->getType());
           GlobalVariable *Cache =
             new GlobalVariable(*F->getParent(), F->getType(), 
                                false, GlobalValue::InternalLinkage,
@@ -753,7 +755,7 @@
           // Cast the result from the resolver to correctly-typed function.
           CastInst *CastedResolver =
             new BitCastInst(Resolver,
-                            PointerType::getUnqual(F->getFunctionType()),
+                            Context.getPointerTypeUnqual(F->getFunctionType()),
                             "resolverCast", LookupBB);
 
           // Save the value in our cache.

Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Tue Jul 14 18:09:55 2009
@@ -30,14 +30,16 @@
 
 Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) {
   std::vector<const Type*> params;
-  const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(),
+  const FunctionType *FTy =
+    getGlobalContext().getFunctionType(G->getType()->getElementType(),
                                               params, false);
   Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M);
   BasicBlock *Entry = BasicBlock::Create("entry", F);
   IRBuilder<> builder(Entry);
   Value *Load = builder.CreateLoad(G);
   const Type *GTy = G->getType()->getElementType();
-  Value *Add = builder.CreateAdd(Load, ConstantInt::get(GTy, 1LL));
+  Value *Add = builder.CreateAdd(Load,
+    getGlobalContext().getConstantInt(GTy, 1LL));
   builder.CreateStore(Add, G);
   builder.CreateRet(Add);
   return F;

Modified: llvm/trunk/unittests/Support/ValueHandleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ValueHandleTest.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/unittests/Support/ValueHandleTest.cpp (original)
+++ llvm/trunk/unittests/Support/ValueHandleTest.cpp Tue Jul 14 18:09:55 2009
@@ -25,8 +25,9 @@
   Constant *ConstantV;
   std::auto_ptr<BitCastInst> BitcastV;
 
-  ValueHandle() : ConstantV(ConstantInt::get(Type::Int32Ty, 0)),
-                  BitcastV(new BitCastInst(ConstantV, Type::Int32Ty)) {
+  ValueHandle() :
+    ConstantV(getGlobalContext().getConstantInt(Type::Int32Ty, 0)),
+    BitcastV(new BitCastInst(ConstantV, Type::Int32Ty)) {
   }
 };
 

Modified: llvm/trunk/unittests/VMCore/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/MetadataTest.cpp?rev=75703&r1=75702&r2=75703&view=diff

==============================================================================
--- llvm/trunk/unittests/VMCore/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/VMCore/MetadataTest.cpp Tue Jul 14 18:09:55 2009
@@ -23,9 +23,9 @@
 // MDString objects, even with the same string pointer and nulls in the string.
 TEST(MDStringTest, CreateDifferent) {
   char x[3] = { 'f', 0, 'A' };
-  MDString *s1 = MDString::get(&x[0], &x[3]);
+  MDString *s1 = getGlobalContext().getMDString(&x[0], &x[3]);
   x[2] = 'B';
-  MDString *s2 = MDString::get(&x[0], &x[3]);
+  MDString *s2 = getGlobalContext().getMDString(&x[0], &x[3]);
   EXPECT_NE(s1, s2);
 }
 
@@ -35,8 +35,8 @@
   char x[4] = { 'a', 'b', 'c', 'X' };
   char y[4] = { 'a', 'b', 'c', 'Y' };
 
-  MDString *s1 = MDString::get(&x[0], &x[3]);
-  MDString *s2 = MDString::get(&y[0], &y[3]);
+  MDString *s1 = getGlobalContext().getMDString(&x[0], &x[3]);
+  MDString *s2 = getGlobalContext().getMDString(&y[0], &y[3]);
   EXPECT_EQ(s1, s2);
 }
 
@@ -44,7 +44,7 @@
 TEST(MDStringTest, PrintingSimple) {
   char *str = new char[13];
   strncpy(str, "testing 1 2 3", 13);
-  MDString *s = MDString::get(str, str+13);
+  MDString *s = getGlobalContext().getMDString(str, str+13);
   strncpy(str, "aaaaaaaaaaaaa", 13);
   delete[] str;
 
@@ -56,7 +56,7 @@
 // Test printing of MDString with non-printable characters.
 TEST(MDStringTest, PrintingComplex) {
   char str[5] = {0, '\n', '"', '\\', -1};
-  MDString *s = MDString::get(str+0, str+5);
+  MDString *s = getGlobalContext().getMDString(str+0, str+5);
   std::ostringstream oss;
   s->print(oss);
   EXPECT_STREQ("metadata !\"\\00\\0A\\22\\5C\\FF\"", oss.str().c_str());
@@ -67,19 +67,19 @@
   char x[3] = { 'a', 'b', 'c' };
   char y[3] = { '1', '2', '3' };
 
-  MDString *s1 = MDString::get(&x[0], &x[3]);
-  MDString *s2 = MDString::get(&y[0], &y[3]);
-  ConstantInt *CI = ConstantInt::get(APInt(8, 0));
+  MDString *s1 = getGlobalContext().getMDString(&x[0], &x[3]);
+  MDString *s2 = getGlobalContext().getMDString(&y[0], &y[3]);
+  ConstantInt *CI = getGlobalContext().getConstantInt(APInt(8, 0));
 
   std::vector<Value *> V;
   V.push_back(s1);
   V.push_back(CI);
   V.push_back(s2);
 
-  MDNode *n1 = MDNode::get(&V[0], 3);
+  MDNode *n1 = getGlobalContext().getMDNode(&V[0], 3);
   Value *const c1 = n1;
-  MDNode *n2 = MDNode::get(&c1, 1);
-  MDNode *n3 = MDNode::get(&V[0], 3);
+  MDNode *n2 = getGlobalContext().getMDNode(&c1, 1);
+  MDNode *n3 = getGlobalContext().getMDNode(&V[0], 3);
   EXPECT_NE(n1, n2);
   EXPECT_EQ(n1, n3);
 
@@ -102,15 +102,15 @@
 }
 
 TEST(MDNodeTest, RAUW) {
-  Constant *C = ConstantInt::get(Type::Int32Ty, 1);
+  Constant *C = getGlobalContext().getConstantInt(Type::Int32Ty, 1);
   Instruction *I = new BitCastInst(C, Type::Int32Ty);
 
   Value *const V1 = I;
-  MDNode *n1 = MDNode::get(&V1, 1);
+  MDNode *n1 = getGlobalContext().getMDNode(&V1, 1);
   WeakVH wn1 = n1;
 
   Value *const V2 = C;
-  MDNode *n2 = MDNode::get(&V2, 1);
+  MDNode *n2 = getGlobalContext().getMDNode(&V2, 1);
   WeakVH wn2 = n2;
 
   EXPECT_NE(wn1, wn2);
@@ -121,11 +121,11 @@
 }
 
 TEST(MDNodeTest, Delete) {
-  Constant *C = ConstantInt::get(Type::Int32Ty, 1);
+  Constant *C = getGlobalContext().getConstantInt(Type::Int32Ty, 1);
   Instruction *I = new BitCastInst(C, Type::Int32Ty);
 
   Value *const V = I;
-  MDNode *n = MDNode::get(&V, 1);
+  MDNode *n = getGlobalContext().getMDNode(&V, 1);
   WeakVH wvh = n;
 
   EXPECT_EQ(n, wvh);





More information about the llvm-commits mailing list