This started as a small change, I swear. Unfortunately, lots of things call the...
authorOwen Anderson <resistor@mac.com>
Thu, 9 Jul 2009 23:48:35 +0000 (23:48 +0000)
committerOwen Anderson <resistor@mac.com>
Thu, 9 Jul 2009 23:48:35 +0000 (23:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75200 91177308-0d34-0410-b5e6-96231b3b80d8

37 files changed:
examples/BrainF/BrainF.cpp
examples/Fibonacci/fibonacci.cpp
examples/ParallelJIT/ParallelJIT.cpp
include/llvm/InstrTypes.h
include/llvm/Instruction.h
include/llvm/Instructions.h
include/llvm/LLVMContext.h
include/llvm/Support/IRBuilder.h
lib/AsmParser/LLParser.cpp
lib/Bitcode/Reader/BitcodeReader.cpp
lib/CodeGen/StackProtector.cpp
lib/Transforms/IPO/GlobalOpt.cpp
lib/Transforms/Instrumentation/RSProfiling.cpp
lib/Transforms/Scalar/CodeGenPrepare.cpp
lib/Transforms/Scalar/GVN.cpp
lib/Transforms/Scalar/GVNPRE.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
lib/Transforms/Scalar/InstructionCombining.cpp
lib/Transforms/Scalar/JumpThreading.cpp
lib/Transforms/Scalar/LICM.cpp
lib/Transforms/Scalar/LoopIndexSplit.cpp
lib/Transforms/Scalar/LoopRotation.cpp
lib/Transforms/Scalar/LoopStrengthReduce.cpp
lib/Transforms/Scalar/LoopUnswitch.cpp
lib/Transforms/Scalar/PredicateSimplifier.cpp
lib/Transforms/Scalar/ScalarReplAggregates.cpp
lib/Transforms/Scalar/TailDuplication.cpp
lib/Transforms/Utils/BasicBlockUtils.cpp
lib/Transforms/Utils/CloneFunction.cpp
lib/Transforms/Utils/InlineFunction.cpp
lib/Transforms/Utils/Local.cpp
lib/Transforms/Utils/LowerInvoke.cpp
lib/Transforms/Utils/LowerSwitch.cpp
lib/Transforms/Utils/SimplifyCFG.cpp
lib/VMCore/Instructions.cpp
lib/VMCore/LLVMContext.cpp
tools/bugpoint/Miscompilation.cpp

index 058ef8c72de874f0eaed81eff06794c958ddba8f..cd9e850728f153f10a0dcfac06cb1e0e128bc4be 100644 (file)
@@ -427,9 +427,8 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
       LoadInst *tape_0 = new LoadInst(head_0, tapereg, testbb);
 
       //%test.%d = icmp eq i8 %tape.%d, 0
       LoadInst *tape_0 = new LoadInst(head_0, tapereg, testbb);
 
       //%test.%d = icmp eq i8 %tape.%d, 0
-      ICmpInst *test_0 = new ICmpInst(ICmpInst::ICMP_EQ, tape_0,
-                                      ConstantInt::get(APInt(8, 0)), testreg,
-                                      testbb);
+      ICmpInst *test_0 = new ICmpInst(*testbb, ICmpInst::ICMP_EQ, tape_0,
+                                      ConstantInt::get(APInt(8, 0)), testreg);
 
       //br i1 %test.%d, label %main.%d, label %main.%d
       BasicBlock *bb_0 = BasicBlock::Create(label, brainf_func);
 
       //br i1 %test.%d, label %main.%d, label %main.%d
       BasicBlock *bb_0 = BasicBlock::Create(label, brainf_func);
index c3431fc3527e0340c283c2da807779f9f3b2472d..89f3ef2d753d2c6bf984724e67b5e86ff880f31c 100644 (file)
@@ -60,7 +60,7 @@ static Function *CreateFibFunction(Module *M) {
   BasicBlock* RecurseBB = BasicBlock::Create("recurse", FibF);
 
   // Create the "if (arg <= 2) goto exitbb"
   BasicBlock* RecurseBB = BasicBlock::Create("recurse", FibF);
 
   // Create the "if (arg <= 2) goto exitbb"
-  Value *CondInst = new ICmpInst(ICmpInst::ICMP_SLE, ArgX, Two, "cond", BB);
+  Value *CondInst = new ICmpInst(*BB, ICmpInst::ICMP_SLE, ArgX, Two, "cond");
   BranchInst::Create(RetBB, RecurseBB, CondInst, BB);
 
   // Create: ret int 1
   BranchInst::Create(RetBB, RecurseBB, CondInst, BB);
 
   // Create: ret int 1
index eadd0f58e5d50d6f3029f846077cf7e658ab25eb..e80dc4986ae7aefc620a327d4574299978ebaaaf 100644 (file)
@@ -85,7 +85,7 @@ static Function *CreateFibFunction(Module *M) {
   BasicBlock* RecurseBB = BasicBlock::Create("recurse", FibF);
 
   // Create the "if (arg < 2) goto exitbb"
   BasicBlock* RecurseBB = BasicBlock::Create("recurse", FibF);
 
   // Create the "if (arg < 2) goto exitbb"
-  Value *CondInst = new ICmpInst(ICmpInst::ICMP_SLE, ArgX, Two, "cond", BB);
+  Value *CondInst = new ICmpInst(*BB, ICmpInst::ICMP_SLE, ArgX, Two, "cond");
   BranchInst::Create(RetBB, RecurseBB, CondInst, BB);
 
   // Create: ret int 1
   BranchInst::Create(RetBB, RecurseBB, CondInst, BB);
 
   // Create: ret int 1
index 0a018de5e9baf4d374b124caf6db403c3b3be2f0..76827191f1d5e19cb050e2c80a6904996c19d2d7 100644 (file)
@@ -22,6 +22,8 @@
 
 namespace llvm {
 
 
 namespace llvm {
 
+class LLVMContext;
+
 //===----------------------------------------------------------------------===//
 //                            TerminatorInst Class
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 //                            TerminatorInst Class
 //===----------------------------------------------------------------------===//
@@ -50,7 +52,7 @@ protected:
   virtual void setSuccessorV(unsigned idx, BasicBlock *B) = 0;
 public:
 
   virtual void setSuccessorV(unsigned idx, BasicBlock *B) = 0;
 public:
 
-  virtual Instruction *clone() const = 0;
+  virtual Instruction *clone(LLVMContext &Context) const = 0;
 
   /// getNumSuccessors - Return the number of successors that this terminator
   /// has.
 
   /// getNumSuccessors - Return the number of successors that this terminator
   /// has.
@@ -235,7 +237,7 @@ public:
     return static_cast<BinaryOps>(Instruction::getOpcode());
   }
 
     return static_cast<BinaryOps>(Instruction::getOpcode());
   }
 
-  virtual BinaryOperator *clone() const;
+  virtual BinaryOperator *clone(LLVMContext &Context) const;
 
   /// swapOperands - Exchange the two operands to this instruction.
   /// This instruction is safe to use on any binary instruction and
 
   /// swapOperands - Exchange the two operands to this instruction.
   /// This instruction is safe to use on any binary instruction and
@@ -569,7 +571,8 @@ public:
   /// instruction into a BasicBlock right before the specified instruction.
   /// The specified Instruction is allowed to be a dereferenced end iterator.
   /// @brief Create a CmpInst
   /// instruction into a BasicBlock right before the specified instruction.
   /// The specified Instruction is allowed to be a dereferenced end iterator.
   /// @brief Create a CmpInst
-  static CmpInst *Create(OtherOps Op, unsigned short predicate, Value *S1,
+  static CmpInst *Create(LLVMContext &Context, OtherOps Op,
+                         unsigned short predicate, Value *S1,
                          Value *S2, const std::string &Name = "",
                          Instruction *InsertBefore = 0);
 
                          Value *S2, const std::string &Name = "",
                          Instruction *InsertBefore = 0);
 
@@ -660,13 +663,6 @@ public:
   static inline bool classof(const Value *V) {
     return isa<Instruction>(V) && classof(cast<Instruction>(V));
   }
   static inline bool classof(const Value *V) {
     return isa<Instruction>(V) && classof(cast<Instruction>(V));
   }
-  /// @brief Create a result type for fcmp/icmp
-  static const Type* makeCmpResultType(const Type* opnd_type) {
-    if (const VectorType* vt = dyn_cast<const VectorType>(opnd_type)) {
-      return VectorType::get(Type::Int1Ty, vt->getNumElements());
-    }
-    return Type::Int1Ty;
-  }
 };
 
 
 };
 
 
index 7d946e85a6d006b325b6f6dea25752bf7950f009..e06ae2d71120db8b59296d10d6dd93fc9b43fed4 100644 (file)
@@ -20,6 +20,8 @@
 
 namespace llvm {
 
 
 namespace llvm {
 
+class LLVMContext;
+
 template<typename ValueSubClass, typename ItemParentClass>
   class SymbolTableListTraits;
 
 template<typename ValueSubClass, typename ItemParentClass>
   class SymbolTableListTraits;
 
@@ -45,7 +47,7 @@ public:
   ///   * The instruction has no parent
   ///   * The instruction has no name
   ///
   ///   * The instruction has no parent
   ///   * The instruction has no name
   ///
-  virtual Instruction *clone() const = 0;
+  virtual Instruction *clone(LLVMContext &Context) const = 0;
 
   /// isIdenticalTo - Return true if the specified instruction is exactly
   /// identical to the current one.  This means that all operands match and any
 
   /// isIdenticalTo - Return true if the specified instruction is exactly
   /// identical to the current one.  This means that all operands match and any
index aef77f0a93d81fd71f8520eb912fc90259a720de..5bd3066ef957d163686c6b23cf4968a1e63a8c80 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Attributes.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Attributes.h"
 #include "llvm/BasicBlock.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/ADT/SmallVector.h"
 #include <iterator>
 
 #include "llvm/ADT/SmallVector.h"
 #include <iterator>
 
@@ -74,7 +75,7 @@ public:
   unsigned getAlignment() const { return (1u << SubclassData) >> 1; }
   void setAlignment(unsigned Align);
 
   unsigned getAlignment() const { return (1u << SubclassData) >> 1; }
   void setAlignment(unsigned Align);
 
-  virtual Instruction *clone() const = 0;
+  virtual Instruction *clone(LLVMContext &Context) const = 0;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const AllocationInst *) { return true; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const AllocationInst *) { return true; }
@@ -120,7 +121,7 @@ public:
                       Instruction *InsertBefore = 0)
     : AllocationInst(Ty, ArraySize, Malloc, Align, NameStr, InsertBefore) {}
 
                       Instruction *InsertBefore = 0)
     : AllocationInst(Ty, ArraySize, Malloc, Align, NameStr, InsertBefore) {}
 
-  virtual MallocInst *clone() const;
+  virtual MallocInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const MallocInst *) { return true; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const MallocInst *) { return true; }
@@ -164,7 +165,7 @@ public:
              const std::string &NameStr, BasicBlock *InsertAtEnd)
     : AllocationInst(Ty, ArraySize, Alloca, Align, NameStr, InsertAtEnd) {}
 
              const std::string &NameStr, BasicBlock *InsertAtEnd)
     : AllocationInst(Ty, ArraySize, Alloca, Align, NameStr, InsertAtEnd) {}
 
-  virtual AllocaInst *clone() const;
+  virtual AllocaInst *clone(LLVMContext &Context) const;
 
   /// isStaticAlloca - Return true if this alloca is in the entry block of the
   /// function and is a constant size.  If so, the code generator will fold it
 
   /// isStaticAlloca - Return true if this alloca is in the entry block of the
   /// function and is a constant size.  If so, the code generator will fold it
@@ -194,7 +195,7 @@ public:
   explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
   FreeInst(Value *Ptr, BasicBlock *InsertAfter);
 
   explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
   FreeInst(Value *Ptr, BasicBlock *InsertAfter);
 
-  virtual FreeInst *clone() const;
+  virtual FreeInst *clone(LLVMContext &Context) const;
 
   // Accessor methods for consistency with other memory operations
   Value *getPointerOperand() { return getOperand(0); }
 
   // Accessor methods for consistency with other memory operations
   Value *getPointerOperand() { return getOperand(0); }
@@ -260,7 +261,7 @@ public:
     SubclassData = (SubclassData & ~1) | (V ? 1 : 0);
   }
 
     SubclassData = (SubclassData & ~1) | (V ? 1 : 0);
   }
 
-  virtual LoadInst *clone() const;
+  virtual LoadInst *clone(LLVMContext &Context) const;
 
   /// getAlignment - Return the alignment of the access that is being performed
   ///
 
   /// getAlignment - Return the alignment of the access that is being performed
   ///
@@ -344,7 +345,7 @@ public:
 
   void setAlignment(unsigned Align);
 
 
   void setAlignment(unsigned Align);
 
-  virtual StoreInst *clone() const;
+  virtual StoreInst *clone(LLVMContext &Context) const;
 
   Value *getPointerOperand() { return getOperand(1); }
   const Value *getPointerOperand() const { return getOperand(1); }
 
   Value *getPointerOperand() { return getOperand(1); }
   const Value *getPointerOperand() const { return getOperand(1); }
@@ -485,7 +486,7 @@ public:
     return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertAtEnd);
   }
 
     return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertAtEnd);
   }
 
-  virtual GetElementPtrInst *clone() const;
+  virtual GetElementPtrInst *clone(LLVMContext &Context) const;
 
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -626,12 +627,13 @@ class ICmpInst: public CmpInst {
 public:
   /// @brief Constructor with insert-before-instruction semantics.
   ICmpInst(
 public:
   /// @brief Constructor with insert-before-instruction semantics.
   ICmpInst(
+    Instruction *InsertBefore,  ///< Where to insert
     Predicate pred,  ///< The predicate to use for the comparison
     Value *LHS,      ///< The left-hand-side of the expression
     Value *RHS,      ///< The right-hand-side of the expression
     Predicate pred,  ///< The predicate to use for the comparison
     Value *LHS,      ///< The left-hand-side of the expression
     Value *RHS,      ///< The right-hand-side of the expression
-    const std::string &NameStr = "",  ///< Name of the instruction
-    Instruction *InsertBefore = 0  ///< Where to insert
-  ) : CmpInst(makeCmpResultType(LHS->getType()),
+    const std::string &NameStr = ""  ///< Name of the instruction
+  ) : CmpInst(InsertBefore->getParent()->getContext()->
+                makeCmpResultType(LHS->getType()),
               Instruction::ICmp, pred, LHS, RHS, NameStr,
               InsertBefore) {
     assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
               Instruction::ICmp, pred, LHS, RHS, NameStr,
               InsertBefore) {
     assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
@@ -645,16 +647,36 @@ public:
            "Invalid operand types for ICmp instruction");
   }
 
            "Invalid operand types for ICmp instruction");
   }
 
-  /// @brief Constructor with insert-at-block-end semantics.
+  /// @brief Constructor with insert-at-end semantics.
+  ICmpInst(
+    BasicBlock &InsertAtEnd, ///< Block to insert into.
+    Predicate pred,  ///< The predicate to use for the comparison
+    Value *LHS,      ///< The left-hand-side of the expression
+    Value *RHS,      ///< The right-hand-side of the expression
+    const std::string &NameStr = ""  ///< Name of the instruction
+  ) : CmpInst(InsertAtEnd.getContext()->makeCmpResultType(LHS->getType()),
+              Instruction::ICmp, pred, LHS, RHS, NameStr,
+              &InsertAtEnd) {
+    assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
+          pred <= CmpInst::LAST_ICMP_PREDICATE &&
+          "Invalid ICmp predicate value");
+    assert(getOperand(0)->getType() == getOperand(1)->getType() &&
+          "Both operands to ICmp instruction are not of the same type!");
+    // Check that the operands are the right type
+    assert((getOperand(0)->getType()->isIntOrIntVector() ||
+            isa<PointerType>(getOperand(0)->getType())) &&
+           "Invalid operand types for ICmp instruction");
+  }
+
+  /// @brief Constructor with no-insertion semantics
   ICmpInst(
   ICmpInst(
+    LLVMContext &Context, ///< Context to construct within
     Predicate pred, ///< The predicate to use for the comparison
     Value *LHS,     ///< The left-hand-side of the expression
     Value *RHS,     ///< The right-hand-side of the expression
     Predicate pred, ///< The predicate to use for the comparison
     Value *LHS,     ///< The left-hand-side of the expression
     Value *RHS,     ///< The right-hand-side of the expression
-    const std::string &NameStr,  ///< Name of the instruction
-    BasicBlock *InsertAtEnd   ///< Block to insert into.
-  ) : CmpInst(makeCmpResultType(LHS->getType()),
-              Instruction::ICmp, pred, LHS, RHS, NameStr,
-              InsertAtEnd) {
+    const std::string &NameStr = "" ///< Name of the instruction
+  ) : CmpInst(Context.makeCmpResultType(LHS->getType()),
+              Instruction::ICmp, pred, LHS, RHS, NameStr) {
     assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
            pred <= CmpInst::LAST_ICMP_PREDICATE &&
            "Invalid ICmp predicate value");
     assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
            pred <= CmpInst::LAST_ICMP_PREDICATE &&
            "Invalid ICmp predicate value");
@@ -756,7 +778,7 @@ public:
     Op<0>().swap(Op<1>());
   }
 
     Op<0>().swap(Op<1>());
   }
 
-  virtual ICmpInst *clone() const;
+  virtual ICmpInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ICmpInst *) { return true; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ICmpInst *) { return true; }
@@ -781,12 +803,13 @@ class FCmpInst: public CmpInst {
 public:
   /// @brief Constructor with insert-before-instruction semantics.
   FCmpInst(
 public:
   /// @brief Constructor with insert-before-instruction semantics.
   FCmpInst(
+    Instruction *InsertBefore, ///< Where to insert
     Predicate pred,  ///< The predicate to use for the comparison
     Value *LHS,      ///< The left-hand-side of the expression
     Value *RHS,      ///< The right-hand-side of the expression
     Predicate pred,  ///< The predicate to use for the comparison
     Value *LHS,      ///< The left-hand-side of the expression
     Value *RHS,      ///< The right-hand-side of the expression
-    const std::string &NameStr = "",  ///< Name of the instruction
-    Instruction *InsertBefore = 0  ///< Where to insert
-  ) : CmpInst(makeCmpResultType(LHS->getType()),
+    const std::string &NameStr = ""  ///< Name of the instruction
+  ) : CmpInst(InsertBefore->getParent()->getContext()->
+                makeCmpResultType(LHS->getType()),
               Instruction::FCmp, pred, LHS, RHS, NameStr,
               InsertBefore) {
     assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
               Instruction::FCmp, pred, LHS, RHS, NameStr,
               InsertBefore) {
     assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
@@ -797,17 +820,35 @@ public:
     assert(getOperand(0)->getType()->isFPOrFPVector() &&
            "Invalid operand types for FCmp instruction");
   }
     assert(getOperand(0)->getType()->isFPOrFPVector() &&
            "Invalid operand types for FCmp instruction");
   }
+  
+  /// @brief Constructor with insert-at-end semantics.
+  FCmpInst(
+    BasicBlock &InsertAtEnd, ///< Block to insert into.
+    Predicate pred,  ///< The predicate to use for the comparison
+    Value *LHS,      ///< The left-hand-side of the expression
+    Value *RHS,      ///< The right-hand-side of the expression
+    const std::string &NameStr = ""  ///< Name of the instruction
+  ) : CmpInst(InsertAtEnd.getContext()->makeCmpResultType(LHS->getType()),
+              Instruction::FCmp, pred, LHS, RHS, NameStr,
+              &InsertAtEnd) {
+    assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
+           "Invalid FCmp predicate value");
+    assert(getOperand(0)->getType() == getOperand(1)->getType() &&
+           "Both operands to FCmp instruction are not of the same type!");
+    // Check that the operands are the right type
+    assert(getOperand(0)->getType()->isFPOrFPVector() &&
+           "Invalid operand types for FCmp instruction");
+  }
 
 
-  /// @brief Constructor with insert-at-block-end semantics.
+  /// @brief Constructor with no-insertion semantics
   FCmpInst(
   FCmpInst(
+    LLVMContext &Context, ///< Context to build in
     Predicate pred, ///< The predicate to use for the comparison
     Value *LHS,     ///< The left-hand-side of the expression
     Value *RHS,     ///< The right-hand-side of the expression
     Predicate pred, ///< The predicate to use for the comparison
     Value *LHS,     ///< The left-hand-side of the expression
     Value *RHS,     ///< The right-hand-side of the expression
-    const std::string &NameStr,  ///< Name of the instruction
-    BasicBlock *InsertAtEnd   ///< Block to insert into.
-  ) : CmpInst(makeCmpResultType(LHS->getType()),
-              Instruction::FCmp, pred, LHS, RHS, NameStr,
-              InsertAtEnd) {
+    const std::string &NameStr = "" ///< Name of the instruction
+  ) : CmpInst(Context.makeCmpResultType(LHS->getType()),
+              Instruction::FCmp, pred, LHS, RHS, NameStr) {
     assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
            "Invalid FCmp predicate value");
     assert(getOperand(0)->getType() == getOperand(1)->getType() &&
     assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
            "Invalid FCmp predicate value");
     assert(getOperand(0)->getType() == getOperand(1)->getType() &&
@@ -848,7 +889,7 @@ public:
     Op<0>().swap(Op<1>());
   }
 
     Op<0>().swap(Op<1>());
   }
 
-  virtual FCmpInst *clone() const;
+  virtual FCmpInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FCmpInst *) { return true; }
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FCmpInst *) { return true; }
@@ -959,7 +1000,7 @@ public:
     SubclassData = (SubclassData & ~1) | unsigned(isTC);
   }
 
     SubclassData = (SubclassData & ~1) | unsigned(isTC);
   }
 
-  virtual CallInst *clone() const;
+  virtual CallInst *clone(LLVMContext &Context) const;
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -1152,7 +1193,7 @@ public:
     return static_cast<OtherOps>(Instruction::getOpcode());
   }
 
     return static_cast<OtherOps>(Instruction::getOpcode());
   }
 
-  virtual SelectInst *clone() const;
+  virtual SelectInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SelectInst *) { return true; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SelectInst *) { return true; }
@@ -1192,7 +1233,7 @@ public:
     setName(NameStr);
   }
 
     setName(NameStr);
   }
 
-  virtual VAArgInst *clone() const;
+  virtual VAArgInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const VAArgInst *) { return true; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const VAArgInst *) { return true; }
@@ -1236,7 +1277,7 @@ public:
   /// formed with the specified operands.
   static bool isValidOperands(const Value *Vec, const Value *Idx);
 
   /// formed with the specified operands.
   static bool isValidOperands(const Value *Vec, const Value *Idx);
 
-  virtual ExtractElementInst *clone() const;
+  virtual ExtractElementInst *clone(LLVMContext &Context) const;
 
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -1306,7 +1347,7 @@ public:
   static bool isValidOperands(const Value *Vec, const Value *NewElt,
                               const Value *Idx);
 
   static bool isValidOperands(const Value *Vec, const Value *NewElt,
                               const Value *Idx);
 
-  virtual InsertElementInst *clone() const;
+  virtual InsertElementInst *clone(LLVMContext &Context) const;
 
   /// getType - Overload to return most specific vector type.
   ///
 
   /// getType - Overload to return most specific vector type.
   ///
@@ -1358,7 +1399,7 @@ public:
   static bool isValidOperands(const Value *V1, const Value *V2,
                               const Value *Mask);
 
   static bool isValidOperands(const Value *V1, const Value *V2,
                               const Value *Mask);
 
-  virtual ShuffleVectorInst *clone() const;
+  virtual ShuffleVectorInst *clone(LLVMContext &Context) const;
 
   /// getType - Overload to return most specific vector type.
   ///
 
   /// getType - Overload to return most specific vector type.
   ///
@@ -1502,7 +1543,7 @@ public:
     return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertAtEnd);
   }
 
     return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertAtEnd);
   }
 
-  virtual ExtractValueInst *clone() const;
+  virtual ExtractValueInst *clone(LLVMContext &Context) const;
 
   /// getIndexedType - Returns the type of the element that would be extracted
   /// with an extractvalue instruction with the specified parameters.
 
   /// getIndexedType - Returns the type of the element that would be extracted
   /// with an extractvalue instruction with the specified parameters.
@@ -1672,7 +1713,7 @@ public:
     return new InsertValueInst(Agg, Val, Idx, NameStr, InsertAtEnd);
   }
 
     return new InsertValueInst(Agg, Val, Idx, NameStr, InsertAtEnd);
   }
 
-  virtual InsertValueInst *clone() const;
+  virtual InsertValueInst *clone(LLVMContext &Context) const;
 
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -1801,7 +1842,7 @@ public:
     resizeOperands(NumValues*2);
   }
 
     resizeOperands(NumValues*2);
   }
 
-  virtual PHINode *clone() const;
+  virtual PHINode *clone(LLVMContext &Context) const;
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -1960,7 +2001,7 @@ public:
   }
   virtual ~ReturnInst();
 
   }
   virtual ~ReturnInst();
 
-  virtual ReturnInst *clone() const;
+  virtual ReturnInst *clone(LLVMContext &Context) const;
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -2042,7 +2083,7 @@ public:
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
-  virtual BranchInst *clone() const;
+  virtual BranchInst *clone(LLVMContext &Context) const;
 
   bool isUnconditional() const { return getNumOperands() == 1; }
   bool isConditional()   const { return getNumOperands() == 3; }
 
   bool isUnconditional() const { return getNumOperands() == 1; }
   bool isConditional()   const { return getNumOperands() == 3; }
@@ -2212,7 +2253,7 @@ public:
   ///
   void removeCase(unsigned idx);
 
   ///
   void removeCase(unsigned idx);
 
-  virtual SwitchInst *clone() const;
+  virtual SwitchInst *clone(LLVMContext &Context) const;
 
   unsigned getNumSuccessors() const { return getNumOperands()/2; }
   BasicBlock *getSuccessor(unsigned idx) const {
 
   unsigned getNumSuccessors() const { return getNumOperands()/2; }
   BasicBlock *getSuccessor(unsigned idx) const {
@@ -2326,7 +2367,7 @@ public:
                                   Values, NameStr, InsertAtEnd);
   }
 
                                   Values, NameStr, InsertAtEnd);
   }
 
-  virtual InvokeInst *clone() const;
+  virtual InvokeInst *clone(LLVMContext &Context) const;
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -2514,7 +2555,7 @@ public:
   explicit UnwindInst(Instruction *InsertBefore = 0);
   explicit UnwindInst(BasicBlock *InsertAtEnd);
 
   explicit UnwindInst(Instruction *InsertBefore = 0);
   explicit UnwindInst(BasicBlock *InsertAtEnd);
 
-  virtual UnwindInst *clone() const;
+  virtual UnwindInst *clone(LLVMContext &Context) const;
 
   unsigned getNumSuccessors() const { return 0; }
 
 
   unsigned getNumSuccessors() const { return 0; }
 
@@ -2551,7 +2592,7 @@ public:
   explicit UnreachableInst(Instruction *InsertBefore = 0);
   explicit UnreachableInst(BasicBlock *InsertAtEnd);
 
   explicit UnreachableInst(Instruction *InsertBefore = 0);
   explicit UnreachableInst(BasicBlock *InsertAtEnd);
 
-  virtual UnreachableInst *clone() const;
+  virtual UnreachableInst *clone(LLVMContext &Context) const;
 
   unsigned getNumSuccessors() const { return 0; }
 
 
   unsigned getNumSuccessors() const { return 0; }
 
@@ -2597,7 +2638,7 @@ public:
   );
 
   /// @brief Clone an identical TruncInst
   );
 
   /// @brief Clone an identical TruncInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const TruncInst *) { return true; }
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const TruncInst *) { return true; }
@@ -2637,7 +2678,7 @@ public:
   );
 
   /// @brief Clone an identical ZExtInst
   );
 
   /// @brief Clone an identical ZExtInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ZExtInst *) { return true; }
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ZExtInst *) { return true; }
@@ -2677,7 +2718,7 @@ public:
   );
 
   /// @brief Clone an identical SExtInst
   );
 
   /// @brief Clone an identical SExtInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SExtInst *) { return true; }
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SExtInst *) { return true; }
@@ -2716,7 +2757,7 @@ public:
   );
 
   /// @brief Clone an identical FPTruncInst
   );
 
   /// @brief Clone an identical FPTruncInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPTruncInst *) { return true; }
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPTruncInst *) { return true; }
@@ -2755,7 +2796,7 @@ public:
   );
 
   /// @brief Clone an identical FPExtInst
   );
 
   /// @brief Clone an identical FPExtInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPExtInst *) { return true; }
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPExtInst *) { return true; }
@@ -2794,7 +2835,7 @@ public:
   );
 
   /// @brief Clone an identical UIToFPInst
   );
 
   /// @brief Clone an identical UIToFPInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const UIToFPInst *) { return true; }
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const UIToFPInst *) { return true; }
@@ -2833,7 +2874,7 @@ public:
   );
 
   /// @brief Clone an identical SIToFPInst
   );
 
   /// @brief Clone an identical SIToFPInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SIToFPInst *) { return true; }
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SIToFPInst *) { return true; }
@@ -2872,7 +2913,7 @@ public:
   );
 
   /// @brief Clone an identical FPToUIInst
   );
 
   /// @brief Clone an identical FPToUIInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPToUIInst *) { return true; }
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPToUIInst *) { return true; }
@@ -2911,7 +2952,7 @@ public:
   );
 
   /// @brief Clone an identical FPToSIInst
   );
 
   /// @brief Clone an identical FPToSIInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPToSIInst *) { return true; }
 
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const FPToSIInst *) { return true; }
@@ -2950,7 +2991,7 @@ public:
   );
 
   /// @brief Clone an identical IntToPtrInst
   );
 
   /// @brief Clone an identical IntToPtrInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const IntToPtrInst *) { return true; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const IntToPtrInst *) { return true; }
@@ -2989,7 +3030,7 @@ public:
   );
 
   /// @brief Clone an identical PtrToIntInst
   );
 
   /// @brief Clone an identical PtrToIntInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const PtrToIntInst *) { return true; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const PtrToIntInst *) { return true; }
@@ -3028,7 +3069,7 @@ public:
   );
 
   /// @brief Clone an identical BitCastInst
   );
 
   /// @brief Clone an identical BitCastInst
-  virtual CastInst *clone() const;
+  virtual CastInst *clone(LLVMContext &Context) const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const BitCastInst *) { return true; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const BitCastInst *) { return true; }
index 60da89eb4acbb28e96db6a2c522d17cdb0806372..75b7e59cebc91b0a55e8397b0641be4222a2a1ac 100644 (file)
@@ -213,6 +213,10 @@ public:
   VectorType* getVectorTypeInteger(const VectorType* VTy);
   VectorType* getVectorTypeExtendedElement(const VectorType* VTy);
   VectorType* getVectorTypeTruncatedElement(const VectorType* VTy);
   VectorType* getVectorTypeInteger(const VectorType* VTy);
   VectorType* getVectorTypeExtendedElement(const VectorType* VTy);
   VectorType* getVectorTypeTruncatedElement(const VectorType* VTy);
+  
+  // Other helpers
+  /// @brief Create a result type for fcmp/icmp
+  const Type* makeCmpResultType(const Type* opnd_type);
 };
 
 /// FOR BACKWARDS COMPATIBILITY - Returns a global context.
 };
 
 /// FOR BACKWARDS COMPATIBILITY - Returns a global context.
index 0fe0c3ce1f6b75d1ab221b579f4e285a89626d3e..fe794c65eff9ac42a8bb8bb09fd731a728874529 100644 (file)
@@ -565,14 +565,14 @@ public:
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return Folder.CreateICmp(P, LC, RC);
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return Folder.CreateICmp(P, LC, RC);
-    return Insert(new ICmpInst(P, LHS, RHS), Name);
+    return Insert(new ICmpInst(Context, P, LHS, RHS), Name);
   }
   Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
                     const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return Folder.CreateFCmp(P, LC, RC);
   }
   Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
                     const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return Folder.CreateFCmp(P, LC, RC);
-    return Insert(new FCmpInst(P, LHS, RHS), Name);
+    return Insert(new FCmpInst(Context, P, LHS, RHS), Name);
   }
 
   //===--------------------------------------------------------------------===//
   }
 
   //===--------------------------------------------------------------------===//
index 826c64fc8973b733d9d8dbad694e98cc90d66e5d..64212f61934991fe6654ee63d8081be6e9a7be0b 100644 (file)
@@ -2887,13 +2887,13 @@ bool LLParser::ParseCompare(Instruction *&Inst, PerFunctionState &PFS,
   if (Opc == Instruction::FCmp) {
     if (!LHS->getType()->isFPOrFPVector())
       return Error(Loc, "fcmp requires floating point operands");
   if (Opc == Instruction::FCmp) {
     if (!LHS->getType()->isFPOrFPVector())
       return Error(Loc, "fcmp requires floating point operands");
-    Inst = new FCmpInst(CmpInst::Predicate(Pred), LHS, RHS);
+    Inst = new FCmpInst(Context, CmpInst::Predicate(Pred), LHS, RHS);
   } else {
     assert(Opc == Instruction::ICmp && "Unknown opcode for CmpInst!");
     if (!LHS->getType()->isIntOrIntVector() &&
         !isa<PointerType>(LHS->getType()))
       return Error(Loc, "icmp requires integer operands");
   } else {
     assert(Opc == Instruction::ICmp && "Unknown opcode for CmpInst!");
     if (!LHS->getType()->isIntOrIntVector() &&
         !isa<PointerType>(LHS->getType()))
       return Error(Loc, "icmp requires integer operands");
-    Inst = new ICmpInst(CmpInst::Predicate(Pred), LHS, RHS);
+    Inst = new ICmpInst(Context, CmpInst::Predicate(Pred), LHS, RHS);
   }
   return false;
 }
   }
   return false;
 }
index d69895e0cc4473cac3ccc7207d8d49e98f0c64ed..e4d3c5e1ade85cef16052a174f4aed1ea49a6a04 100644 (file)
@@ -1643,9 +1643,9 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
         return Error("Invalid CMP record");
       
       if (LHS->getType()->isFPOrFPVector())
         return Error("Invalid CMP record");
       
       if (LHS->getType()->isFPOrFPVector())
-        I = new FCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS);
+        I = new FCmpInst(Context, (FCmpInst::Predicate)Record[OpNum], LHS, RHS);
       else
       else
-        I = new ICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS);
+        I = new ICmpInst(Context, (ICmpInst::Predicate)Record[OpNum], LHS, RHS);
       break;
     }
 
       break;
     }
 
index c179f1e3df97cea83db1dd22641ffcb36c5e6988..9043b89e354e8650265295defe23e23d055bddc0 100644 (file)
@@ -201,7 +201,7 @@ bool StackProtector::InsertStackProtectors() {
     // Generate the stack protector instructions in the old basic block.
     LoadInst *LI1 = new LoadInst(StackGuardVar, "", false, BB);
     LoadInst *LI2 = new LoadInst(AI, "", true, BB);
     // Generate the stack protector instructions in the old basic block.
     LoadInst *LI1 = new LoadInst(StackGuardVar, "", false, BB);
     LoadInst *LI2 = new LoadInst(AI, "", true, BB);
-    ICmpInst *Cmp = new ICmpInst(CmpInst::ICMP_EQ, LI1, LI2, "", BB);
+    ICmpInst *Cmp = new ICmpInst(*BB, CmpInst::ICMP_EQ, LI1, LI2, "");
     BranchInst::Create(NewBB, FailBB, Cmp, BB);
   }
 
     BranchInst::Create(NewBB, FailBB, Cmp, BB);
   }
 
index 2cd8b6b79a04aef33684c982c2d45a794e3173bd..366005bb132112be1fc0556937d073bf5a059a96 100644 (file)
@@ -1185,9 +1185,9 @@ static void RewriteHeapSROALoadUser(Instruction *LoadUser,
                                    InsertedScalarizedValues, PHIsToRewrite,
                                    Context);
     
                                    InsertedScalarizedValues, PHIsToRewrite,
                                    Context);
     
-    Value *New = new ICmpInst(SCI->getPredicate(), NPtr,
-                              Context->getNullValue(NPtr->getType()),
-                              SCI->getName(), SCI);
+    Value *New = new ICmpInst(SCI, SCI->getPredicate(), NPtr,
+                              Context->getNullValue(NPtr->getType()), 
+                              SCI->getName());
     SCI->replaceAllUsesWith(New);
     SCI->eraseFromParent();
     return;
     SCI->replaceAllUsesWith(New);
     SCI->eraseFromParent();
     return;
@@ -1310,9 +1310,9 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI,
   //    }
   Value *RunningOr = 0;
   for (unsigned i = 0, e = FieldMallocs.size(); i != e; ++i) {
   //    }
   Value *RunningOr = 0;
   for (unsigned i = 0, e = FieldMallocs.size(); i != e; ++i) {
-    Value *Cond = new ICmpInst(ICmpInst::ICMP_EQ, FieldMallocs[i],
+    Value *Cond = new ICmpInst(MI, ICmpInst::ICMP_EQ, FieldMallocs[i],
                               Context->getNullValue(FieldMallocs[i]->getType()),
                               Context->getNullValue(FieldMallocs[i]->getType()),
-                                  "isnull", MI);
+                                  "isnull");
     if (!RunningOr)
       RunningOr = Cond;   // First seteq
     else
     if (!RunningOr)
       RunningOr = Cond;   // First seteq
     else
@@ -1337,9 +1337,9 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI,
   // pointer, because some may be null while others are not.
   for (unsigned i = 0, e = FieldGlobals.size(); i != e; ++i) {
     Value *GVVal = new LoadInst(FieldGlobals[i], "tmp", NullPtrBlock);
   // pointer, because some may be null while others are not.
   for (unsigned i = 0, e = FieldGlobals.size(); i != e; ++i) {
     Value *GVVal = new LoadInst(FieldGlobals[i], "tmp", NullPtrBlock);
-    Value *Cmp = new ICmpInst(ICmpInst::ICMP_NE, GVVal, 
+    Value *Cmp = new ICmpInst(*NullPtrBlock, ICmpInst::ICMP_NE, GVVal, 
                               Context->getNullValue(GVVal->getType()),
                               Context->getNullValue(GVVal->getType()),
-                              "tmp", NullPtrBlock);
+                              "tmp");
     BasicBlock *FreeBlock = BasicBlock::Create("free_it", OrigBB->getParent());
     BasicBlock *NextBlock = BasicBlock::Create("next", OrigBB->getParent());
     BranchInst::Create(FreeBlock, NextBlock, Cmp, NullPtrBlock);
     BasicBlock *FreeBlock = BasicBlock::Create("free_it", OrigBB->getParent());
     BasicBlock *NextBlock = BasicBlock::Create("next", OrigBB->getParent());
     BranchInst::Create(FreeBlock, NextBlock, Cmp, NullPtrBlock);
index 510122095396d8b8f0294ea240f508a533e42007..c1f29fec55fa40c7161189ddd58eabfd53e4e60e 100644 (file)
@@ -213,9 +213,9 @@ void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) {
   //decrement counter
   LoadInst* l = new LoadInst(Counter, "counter", t);
   
   //decrement counter
   LoadInst* l = new LoadInst(Counter, "counter", t);
   
-  ICmpInst* s = new ICmpInst(ICmpInst::ICMP_EQ, l,
+  ICmpInst* s = new ICmpInst(t, ICmpInst::ICMP_EQ, l,
                              Context->getConstantInt(T, 0), 
                              Context->getConstantInt(T, 0), 
-                             "countercc", t);
+                             "countercc");
 
   Value* nv = BinaryOperator::CreateSub(l, Context->getConstantInt(T, 1),
                                         "counternew", t);
 
   Value* nv = BinaryOperator::CreateSub(l, Context->getConstantInt(T, 1),
                                         "counternew", t);
@@ -287,9 +287,9 @@ void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) {
   //decrement counter
   LoadInst* l = new LoadInst(AI, "counter", t);
   
   //decrement counter
   LoadInst* l = new LoadInst(AI, "counter", t);
   
-  ICmpInst* s = new ICmpInst(ICmpInst::ICMP_EQ, l,
+  ICmpInst* s = new ICmpInst(t, ICmpInst::ICMP_EQ, l,
                              Context->getConstantInt(T, 0), 
                              Context->getConstantInt(T, 0), 
-                             "countercc", t);
+                             "countercc");
 
   Value* nv = BinaryOperator::CreateSub(l, Context->getConstantInt(T, 1),
                                         "counternew", t);
 
   Value* nv = BinaryOperator::CreateSub(l, Context->getConstantInt(T, 1),
                                         "counternew", t);
@@ -324,9 +324,9 @@ void CycleCounter::ProcessChoicePoint(BasicBlock* bb) {
     BinaryOperator::CreateAnd(c, Context->getConstantInt(Type::Int64Ty, rm),
                               "mrdcc", t);
   
     BinaryOperator::CreateAnd(c, Context->getConstantInt(Type::Int64Ty, rm),
                               "mrdcc", t);
   
-  ICmpInst *s = new ICmpInst(ICmpInst::ICMP_EQ, b,
+  ICmpInst *s = new ICmpInst(t, ICmpInst::ICMP_EQ, b,
                              Context->getConstantInt(Type::Int64Ty, 0), 
                              Context->getConstantInt(Type::Int64Ty, 0), 
-                             "mrdccc", t);
+                             "mrdccc");
 
   t->setCondition(s);
 }
 
   t->setCondition(s);
 }
@@ -394,7 +394,7 @@ Value* ProfilerRS::Translate(Value* v) {
       return i;
     } else {
       //translate this
       return i;
     } else {
       //translate this
-      Instruction* i2 = i->clone();
+      Instruction* i2 = i->clone(*Context);
       if (i->hasName())
         i2->setName("dup_" + i->getName());
       TransCache[i] = i2;
       if (i->hasName())
         i2->setName("dup_" + i->getName());
       TransCache[i] = i2;
index 85e9243e3ce8e3bf7fea22d9ca50e077e5915ad6..b3a26acc5ed9c5a80c2b9ec91f485e43d5eb7a3b 100644 (file)
@@ -520,7 +520,8 @@ static bool OptimizeCmpExpression(CmpInst *CI) {
       BasicBlock::iterator InsertPt = UserBB->getFirstNonPHI();
 
       InsertedCmp =
       BasicBlock::iterator InsertPt = UserBB->getFirstNonPHI();
 
       InsertedCmp =
-        CmpInst::Create(CI->getOpcode(), CI->getPredicate(), CI->getOperand(0),
+        CmpInst::Create(*DefBB->getContext(), CI->getOpcode(), 
+                        CI->getPredicate(),  CI->getOperand(0),
                         CI->getOperand(1), "", InsertPt);
       MadeChange = true;
     }
                         CI->getOperand(1), "", InsertPt);
       MadeChange = true;
     }
index 962ba71dc74dae29b3d942c6bc67fddc25e51da1..b2fdd24c2c28e411ec535097bc515f7ba575d7d4 100644 (file)
@@ -1627,7 +1627,7 @@ bool GVN::performPRE(Function& F) {
       // will be available in the predecessor by the time we need them.  Any
       // that weren't original present will have been instantiated earlier
       // in this loop.
       // will be available in the predecessor by the time we need them.  Any
       // that weren't original present will have been instantiated earlier
       // in this loop.
-      Instruction* PREInstr = CurInst->clone();
+      Instruction* PREInstr = CurInst->clone(*Context);
       bool success = true;
       for (unsigned i = 0, e = CurInst->getNumOperands(); i != e; ++i) {
         Value *Op = PREInstr->getOperand(i);
       bool success = true;
       for (unsigned i = 0, e = CurInst->getNumOperands(); i != e; ++i) {
         Value *Op = PREInstr->getOperand(i);
index 0f3153f2a7b1d72b71da36cfb588c049f60f3041..af7e039eb97946cba0025f8c1039767584a96705 100644 (file)
@@ -861,7 +861,7 @@ Value* GVNPRE::phi_translate(Value* V, BasicBlock* pred, BasicBlock* succ) {
                                         newOp1, newOp2,
                                         BO->getName()+".expr");
       else if (CmpInst* C = dyn_cast<CmpInst>(U))
                                         newOp1, newOp2,
                                         BO->getName()+".expr");
       else if (CmpInst* C = dyn_cast<CmpInst>(U))
-        newVal = CmpInst::Create(C->getOpcode(),
+        newVal = CmpInst::Create(*Context, C->getOpcode(),
                                  C->getPredicate(),
                                  newOp1, newOp2,
                                  C->getName()+".expr");
                                  C->getPredicate(),
                                  newOp1, newOp2,
                                  C->getName()+".expr");
@@ -1679,7 +1679,8 @@ void GVNPRE::insertion_pre(Value* e, BasicBlock* BB,
                                         BO->getName()+".gvnpre",
                                         (*PI)->getTerminator());
       else if (CmpInst* C = dyn_cast<CmpInst>(U))
                                         BO->getName()+".gvnpre",
                                         (*PI)->getTerminator());
       else if (CmpInst* C = dyn_cast<CmpInst>(U))
-        newVal = CmpInst::Create(C->getOpcode(), C->getPredicate(), s1, s2,
+        newVal = CmpInst::Create(*Context, C->getOpcode(),
+                                 C->getPredicate(), s1, s2,
                                  C->getName()+".gvnpre", 
                                  (*PI)->getTerminator());
       else if (ShuffleVectorInst* S = dyn_cast<ShuffleVectorInst>(U))
                                  C->getName()+".gvnpre", 
                                  (*PI)->getTerminator());
       else if (ShuffleVectorInst* S = dyn_cast<ShuffleVectorInst>(U))
index 03a17d673dc0b92f0e37f417abcdcf0e1ea75f94..365589dc0dab99b68309976ad0cf7531f8478269 100644 (file)
@@ -188,7 +188,7 @@ ICmpInst *IndVarSimplify::LinearFunctionTestReplace(Loop *L,
        << (Opcode == ICmpInst::ICMP_NE ? "!=" : "==") << "\n"
        << "      RHS:\t" << *RHS << "\n";
 
        << (Opcode == ICmpInst::ICMP_NE ? "!=" : "==") << "\n"
        << "      RHS:\t" << *RHS << "\n";
 
-  ICmpInst *Cond = new ICmpInst(Opcode, CmpIndVar, ExitCnt, "exitcond", BI);
+  ICmpInst *Cond = new ICmpInst(BI, Opcode, CmpIndVar, ExitCnt, "exitcond");
 
   Instruction *OrigCond = cast<Instruction>(BI->getCondition());
   // It's tempting to use replaceAllUsesWith here to fully replace the old
 
   Instruction *OrigCond = cast<Instruction>(BI->getCondition());
   // It's tempting to use replaceAllUsesWith here to fully replace the old
@@ -294,7 +294,7 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L,
       if (ExitBlocks.size() != 1) {
         // Clone the PHI and delete the original one. This lets IVUsers and
         // any other maps purge the original user from their records.
       if (ExitBlocks.size() != 1) {
         // Clone the PHI and delete the original one. This lets IVUsers and
         // any other maps purge the original user from their records.
-        PHINode *NewPN = PN->clone();
+        PHINode *NewPN = PN->clone(*Context);
         NewPN->takeName(PN);
         NewPN->insertBefore(PN);
         PN->replaceAllUsesWith(NewPN);
         NewPN->takeName(PN);
         NewPN->insertBefore(PN);
         PN->replaceAllUsesWith(NewPN);
@@ -726,8 +726,8 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
   ConstantInt *NewEV = Context->getConstantInt(Type::Int32Ty, intEV);
   Value *LHS = (EVIndex == 1 ? NewPHI->getIncomingValue(1) : NewEV);
   Value *RHS = (EVIndex == 1 ? NewEV : NewPHI->getIncomingValue(1));
   ConstantInt *NewEV = Context->getConstantInt(Type::Int32Ty, intEV);
   Value *LHS = (EVIndex == 1 ? NewPHI->getIncomingValue(1) : NewEV);
   Value *RHS = (EVIndex == 1 ? NewEV : NewPHI->getIncomingValue(1));
-  ICmpInst *NewEC = new ICmpInst(NewPred, LHS, RHS, EC->getNameStart(),
-                                 EC->getParent()->getTerminator());
+  ICmpInst *NewEC = new ICmpInst(EC->getParent()->getTerminator(),
+                                 NewPred, LHS, RHS, EC->getNameStart());
 
   // In the following deltions, PH may become dead and may be deleted.
   // Use a WeakVH to observe whether this happens.
 
   // In the following deltions, PH may become dead and may be deleted.
   // Use a WeakVH to observe whether this happens.
index 8d36f74372772407610dea157198056c3a0c972a..89b4c6569be05e113060ece805d5e989e73d2dda 100644 (file)
@@ -1924,8 +1924,8 @@ static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO,
   if (BinaryOperator *BO = dyn_cast<BinaryOperator>(&I))
     New = BinaryOperator::Create(BO->getOpcode(), Op0, Op1,SO->getName()+".op");
   else if (CmpInst *CI = dyn_cast<CmpInst>(&I))
   if (BinaryOperator *BO = dyn_cast<BinaryOperator>(&I))
     New = BinaryOperator::Create(BO->getOpcode(), Op0, Op1,SO->getName()+".op");
   else if (CmpInst *CI = dyn_cast<CmpInst>(&I))
-    New = CmpInst::Create(CI->getOpcode(), CI->getPredicate(), Op0, Op1, 
-                          SO->getName()+".cmp");
+    New = CmpInst::Create(*Context, CI->getOpcode(), CI->getPredicate(),
+                          Op0, Op1, SO->getName()+".cmp");
   else {
     assert(0 && "Unknown binary instruction type!");
     abort();
   else {
     assert(0 && "Unknown binary instruction type!");
     abort();
@@ -2014,7 +2014,7 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
                                        PN->getIncomingValue(i), C, "phitmp",
                                        NonConstBB->getTerminator());
         else if (CmpInst *CI = dyn_cast<CmpInst>(&I))
                                        PN->getIncomingValue(i), C, "phitmp",
                                        NonConstBB->getTerminator());
         else if (CmpInst *CI = dyn_cast<CmpInst>(&I))
-          InV = CmpInst::Create(CI->getOpcode(), 
+          InV = CmpInst::Create(*Context, CI->getOpcode(), 
                                 CI->getPredicate(),
                                 PN->getIncomingValue(i), C, "phitmp",
                                 NonConstBB->getTerminator());
                                 CI->getPredicate(),
                                 PN->getIncomingValue(i), C, "phitmp",
                                 NonConstBB->getTerminator());
@@ -3042,7 +3042,8 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) {
 
     // X udiv C, where C >= signbit
     if (C->getValue().isNegative()) {
 
     // X udiv C, where C >= signbit
     if (C->getValue().isNegative()) {
-      Value *IC = InsertNewInstBefore(new ICmpInst(ICmpInst::ICMP_ULT, Op0, C),
+      Value *IC = InsertNewInstBefore(new ICmpInst(*Context,
+                                                    ICmpInst::ICMP_ULT, Op0, C),
                                       I);
       return SelectInst::Create(IC, Context->getNullValue(I.getType()),
                                 Context->getConstantInt(I.getType(), 1));
                                       I);
       return SelectInst::Create(IC, Context->getNullValue(I.getType()),
                                 Context->getConstantInt(I.getType(), 1));
@@ -3395,26 +3396,26 @@ static Value *getICmpValue(bool sign, unsigned code, Value *LHS, Value *RHS,
   case  0: return Context->getConstantIntFalse();
   case  1: 
     if (sign)
   case  0: return Context->getConstantIntFalse();
   case  1: 
     if (sign)
-      return new ICmpInst(ICmpInst::ICMP_SGT, LHS, RHS);
+      return new ICmpInst(*Context, ICmpInst::ICMP_SGT, LHS, RHS);
     else
     else
-      return new ICmpInst(ICmpInst::ICMP_UGT, LHS, RHS);
-  case  2: return new ICmpInst(ICmpInst::ICMP_EQ,  LHS, RHS);
+      return new ICmpInst(*Context, ICmpInst::ICMP_UGT, LHS, RHS);
+  case  2: return new ICmpInst(*Context, ICmpInst::ICMP_EQ,  LHS, RHS);
   case  3: 
     if (sign)
   case  3: 
     if (sign)
-      return new ICmpInst(ICmpInst::ICMP_SGE, LHS, RHS);
+      return new ICmpInst(*Context, ICmpInst::ICMP_SGE, LHS, RHS);
     else
     else
-      return new ICmpInst(ICmpInst::ICMP_UGE, LHS, RHS);
+      return new ICmpInst(*Context, ICmpInst::ICMP_UGE, LHS, RHS);
   case  4: 
     if (sign)
   case  4: 
     if (sign)
-      return new ICmpInst(ICmpInst::ICMP_SLT, LHS, RHS);
+      return new ICmpInst(*Context, ICmpInst::ICMP_SLT, LHS, RHS);
     else
     else
-      return new ICmpInst(ICmpInst::ICMP_ULT, LHS, RHS);
-  case  5: return new ICmpInst(ICmpInst::ICMP_NE,  LHS, RHS);
+      return new ICmpInst(*Context, ICmpInst::ICMP_ULT, LHS, RHS);
+  case  5: return new ICmpInst(*Context, ICmpInst::ICMP_NE,  LHS, RHS);
   case  6: 
     if (sign)
   case  6: 
     if (sign)
-      return new ICmpInst(ICmpInst::ICMP_SLE, LHS, RHS);
+      return new ICmpInst(*Context, ICmpInst::ICMP_SLE, LHS, RHS);
     else
     else
-      return new ICmpInst(ICmpInst::ICMP_ULE, LHS, RHS);
+      return new ICmpInst(*Context, ICmpInst::ICMP_ULE, LHS, RHS);
   case  7: return Context->getConstantIntTrue();
   }
 }
   case  7: return Context->getConstantIntTrue();
   }
 }
@@ -3428,39 +3429,39 @@ static Value *getFCmpValue(bool isordered, unsigned code,
   default: assert(0 && "Illegal FCmp code!");
   case  0:
     if (isordered)
   default: assert(0 && "Illegal FCmp code!");
   case  0:
     if (isordered)
-      return new FCmpInst(FCmpInst::FCMP_ORD, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_ORD, LHS, RHS);
     else
     else
-      return new FCmpInst(FCmpInst::FCMP_UNO, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_UNO, LHS, RHS);
   case  1: 
     if (isordered)
   case  1: 
     if (isordered)
-      return new FCmpInst(FCmpInst::FCMP_OGT, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_OGT, LHS, RHS);
     else
     else
-      return new FCmpInst(FCmpInst::FCMP_UGT, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_UGT, LHS, RHS);
   case  2: 
     if (isordered)
   case  2: 
     if (isordered)
-      return new FCmpInst(FCmpInst::FCMP_OEQ, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_OEQ, LHS, RHS);
     else
     else
-      return new FCmpInst(FCmpInst::FCMP_UEQ, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_UEQ, LHS, RHS);
   case  3: 
     if (isordered)
   case  3: 
     if (isordered)
-      return new FCmpInst(FCmpInst::FCMP_OGE, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_OGE, LHS, RHS);
     else
     else
-      return new FCmpInst(FCmpInst::FCMP_UGE, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_UGE, LHS, RHS);
   case  4: 
     if (isordered)
   case  4: 
     if (isordered)
-      return new FCmpInst(FCmpInst::FCMP_OLT, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_OLT, LHS, RHS);
     else
     else
-      return new FCmpInst(FCmpInst::FCMP_ULT, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_ULT, LHS, RHS);
   case  5: 
     if (isordered)
   case  5: 
     if (isordered)
-      return new FCmpInst(FCmpInst::FCMP_ONE, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_ONE, LHS, RHS);
     else
     else
-      return new FCmpInst(FCmpInst::FCMP_UNE, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_UNE, LHS, RHS);
   case  6: 
     if (isordered)
   case  6: 
     if (isordered)
-      return new FCmpInst(FCmpInst::FCMP_OLE, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_OLE, LHS, RHS);
     else
     else
-      return new FCmpInst(FCmpInst::FCMP_ULE, LHS, RHS);
+      return new FCmpInst(*Context, FCmpInst::FCMP_ULE, LHS, RHS);
   case  7: return Context->getConstantIntTrue();
   }
 }
   case  7: return Context->getConstantIntTrue();
   }
 }
@@ -3665,13 +3666,13 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi,
     
   if (Inside) {
     if (Lo == Hi)  // Trivially false.
     
   if (Inside) {
     if (Lo == Hi)  // Trivially false.
-      return new ICmpInst(ICmpInst::ICMP_NE, V, V);
+      return new ICmpInst(*Context, ICmpInst::ICMP_NE, V, V);
 
     // V >= Min && V < Hi --> V < Hi
     if (cast<ConstantInt>(Lo)->isMinValue(isSigned)) {
       ICmpInst::Predicate pred = (isSigned ? 
         ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT);
 
     // V >= Min && V < Hi --> V < Hi
     if (cast<ConstantInt>(Lo)->isMinValue(isSigned)) {
       ICmpInst::Predicate pred = (isSigned ? 
         ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT);
-      return new ICmpInst(pred, V, Hi);
+      return new ICmpInst(*Context, pred, V, Hi);
     }
 
     // Emit V-Lo <u Hi-Lo
     }
 
     // Emit V-Lo <u Hi-Lo
@@ -3679,18 +3680,18 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi,
     Instruction *Add = BinaryOperator::CreateAdd(V, NegLo, V->getName()+".off");
     InsertNewInstBefore(Add, IB);
     Constant *UpperBound = Context->getConstantExprAdd(NegLo, Hi);
     Instruction *Add = BinaryOperator::CreateAdd(V, NegLo, V->getName()+".off");
     InsertNewInstBefore(Add, IB);
     Constant *UpperBound = Context->getConstantExprAdd(NegLo, Hi);
-    return new ICmpInst(ICmpInst::ICMP_ULT, Add, UpperBound);
+    return new ICmpInst(*Context, ICmpInst::ICMP_ULT, Add, UpperBound);
   }
 
   if (Lo == Hi)  // Trivially true.
   }
 
   if (Lo == Hi)  // Trivially true.
-    return new ICmpInst(ICmpInst::ICMP_EQ, V, V);
+    return new ICmpInst(*Context, ICmpInst::ICMP_EQ, V, V);
 
   // V < Min || V >= Hi -> V > Hi-1
   Hi = SubOne(cast<ConstantInt>(Hi), Context);
   if (cast<ConstantInt>(Lo)->isMinValue(isSigned)) {
     ICmpInst::Predicate pred = (isSigned ? 
         ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT);
 
   // V < Min || V >= Hi -> V > Hi-1
   Hi = SubOne(cast<ConstantInt>(Hi), Context);
   if (cast<ConstantInt>(Lo)->isMinValue(isSigned)) {
     ICmpInst::Predicate pred = (isSigned ? 
         ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT);
-    return new ICmpInst(pred, V, Hi);
+    return new ICmpInst(*Context, pred, V, Hi);
   }
 
   // Emit V-Lo >u Hi-1-Lo
   }
 
   // Emit V-Lo >u Hi-1-Lo
@@ -3699,7 +3700,7 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi,
   Instruction *Add = BinaryOperator::CreateAdd(V, NegLo, V->getName()+".off");
   InsertNewInstBefore(Add, IB);
   Constant *LowerBound = Context->getConstantExprAdd(NegLo, Hi);
   Instruction *Add = BinaryOperator::CreateAdd(V, NegLo, V->getName()+".off");
   InsertNewInstBefore(Add, IB);
   Constant *LowerBound = Context->getConstantExprAdd(NegLo, Hi);
-  return new ICmpInst(ICmpInst::ICMP_UGT, Add, LowerBound);
+  return new ICmpInst(*Context, ICmpInst::ICMP_UGT, Add, LowerBound);
 }
 
 // isRunOfOnes - Returns true iff Val consists of one contiguous run of 1s with
 }
 
 // isRunOfOnes - Returns true iff Val consists of one contiguous run of 1s with
@@ -3795,7 +3796,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
       LHSCst->getValue().isPowerOf2()) {
     Instruction *NewOr = BinaryOperator::CreateOr(Val, Val2);
     InsertNewInstBefore(NewOr, I);
       LHSCst->getValue().isPowerOf2()) {
     Instruction *NewOr = BinaryOperator::CreateOr(Val, Val2);
     InsertNewInstBefore(NewOr, I);
-    return new ICmpInst(LHSCC, NewOr, LHSCst);
+    return new ICmpInst(*Context, LHSCC, NewOr, LHSCst);
   }
   
   // From here on, we only handle:
   }
   
   // From here on, we only handle:
@@ -3855,11 +3856,11 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
     default: assert(0 && "Unknown integer condition code!");
     case ICmpInst::ICMP_ULT:
       if (LHSCst == SubOne(RHSCst, Context)) // (X != 13 & X u< 14) -> X < 13
     default: assert(0 && "Unknown integer condition code!");
     case ICmpInst::ICMP_ULT:
       if (LHSCst == SubOne(RHSCst, Context)) // (X != 13 & X u< 14) -> X < 13
-        return new ICmpInst(ICmpInst::ICMP_ULT, Val, LHSCst);
+        return new ICmpInst(*Context, ICmpInst::ICMP_ULT, Val, LHSCst);
       break;                        // (X != 13 & X u< 15) -> no change
     case ICmpInst::ICMP_SLT:
       if (LHSCst == SubOne(RHSCst, Context)) // (X != 13 & X s< 14) -> X < 13
       break;                        // (X != 13 & X u< 15) -> no change
     case ICmpInst::ICMP_SLT:
       if (LHSCst == SubOne(RHSCst, Context)) // (X != 13 & X s< 14) -> X < 13
-        return new ICmpInst(ICmpInst::ICMP_SLT, Val, LHSCst);
+        return new ICmpInst(*Context, ICmpInst::ICMP_SLT, Val, LHSCst);
       break;                        // (X != 13 & X s< 15) -> no change
     case ICmpInst::ICMP_EQ:         // (X != 13 & X == 15) -> X == 15
     case ICmpInst::ICMP_UGT:        // (X != 13 & X u> 15) -> X u> 15
       break;                        // (X != 13 & X s< 15) -> no change
     case ICmpInst::ICMP_EQ:         // (X != 13 & X == 15) -> X == 15
     case ICmpInst::ICMP_UGT:        // (X != 13 & X u> 15) -> X u> 15
@@ -3871,7 +3872,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
         Instruction *Add = BinaryOperator::CreateAdd(Val, AddCST,
                                                      Val->getName()+".off");
         InsertNewInstBefore(Add, I);
         Instruction *Add = BinaryOperator::CreateAdd(Val, AddCST,
                                                      Val->getName()+".off");
         InsertNewInstBefore(Add, I);
-        return new ICmpInst(ICmpInst::ICMP_UGT, Add,
+        return new ICmpInst(*Context, ICmpInst::ICMP_UGT, Add,
                             Context->getConstantInt(Add->getType(), 1));
       }
       break;                        // (X != 13 & X != 15) -> no change
                             Context->getConstantInt(Add->getType(), 1));
       }
       break;                        // (X != 13 & X != 15) -> no change
@@ -3917,7 +3918,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
       break;
     case ICmpInst::ICMP_NE:
       if (RHSCst == AddOne(LHSCst, Context)) // (X u> 13 & X != 14) -> X u> 14
       break;
     case ICmpInst::ICMP_NE:
       if (RHSCst == AddOne(LHSCst, Context)) // (X u> 13 & X != 14) -> X u> 14
-        return new ICmpInst(LHSCC, Val, RHSCst);
+        return new ICmpInst(*Context, LHSCC, Val, RHSCst);
       break;                        // (X u> 13 & X != 15) -> no change
     case ICmpInst::ICMP_ULT:        // (X u> 13 & X u< 15) -> (X-14) <u 1
       return InsertRangeTest(Val, AddOne(LHSCst, Context),
       break;                        // (X u> 13 & X != 15) -> no change
     case ICmpInst::ICMP_ULT:        // (X u> 13 & X u< 15) -> (X-14) <u 1
       return InsertRangeTest(Val, AddOne(LHSCst, Context),
@@ -3936,7 +3937,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
       break;
     case ICmpInst::ICMP_NE:
       if (RHSCst == AddOne(LHSCst, Context)) // (X s> 13 & X != 14) -> X s> 14
       break;
     case ICmpInst::ICMP_NE:
       if (RHSCst == AddOne(LHSCst, Context)) // (X s> 13 & X != 14) -> X s> 14
-        return new ICmpInst(LHSCC, Val, RHSCst);
+        return new ICmpInst(*Context, LHSCC, Val, RHSCst);
       break;                        // (X s> 13 & X != 15) -> no change
     case ICmpInst::ICMP_SLT:        // (X s> 13 & X s< 15) -> (X-14) s< 1
       return InsertRangeTest(Val, AddOne(LHSCst, Context),
       break;                        // (X s> 13 & X != 15) -> no change
     case ICmpInst::ICMP_SLT:        // (X s> 13 & X s< 15) -> (X-14) s< 1
       return InsertRangeTest(Val, AddOne(LHSCst, Context),
@@ -4048,8 +4049,8 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
         // (1 << x) & 1 --> zext(x == 0)
         // (1 >> x) & 1 --> zext(x == 0)
         if (AndRHSMask == 1 && Op0LHS == AndRHS) {
         // (1 << x) & 1 --> zext(x == 0)
         // (1 >> x) & 1 --> zext(x == 0)
         if (AndRHSMask == 1 && Op0LHS == AndRHS) {
-          Instruction *NewICmp = new ICmpInst(ICmpInst::ICMP_EQ, Op0RHS,
-                                           Context->getNullValue(I.getType()));
+          Instruction *NewICmp = new ICmpInst(*Context, ICmpInst::ICMP_EQ,
+                                    Op0RHS, Context->getNullValue(I.getType()));
           InsertNewInstBefore(NewICmp, I);
           return new ZExtInst(NewICmp, I.getType());
         }
           InsertNewInstBefore(NewICmp, I);
           return new ZExtInst(NewICmp, I.getType());
         }
@@ -4231,8 +4232,8 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
             // false.
             if (LHSC->getValueAPF().isNaN() || RHSC->getValueAPF().isNaN())
               return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
             // false.
             if (LHSC->getValueAPF().isNaN() || RHSC->getValueAPF().isNaN())
               return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
-            return new FCmpInst(FCmpInst::FCMP_ORD, LHS->getOperand(0),
-                                RHS->getOperand(0));
+            return new FCmpInst(*Context, FCmpInst::FCMP_ORD, 
+                                LHS->getOperand(0), RHS->getOperand(0));
           }
       } else {
         Value *Op0LHS, *Op0RHS, *Op1LHS, *Op1RHS;
           }
       } else {
         Value *Op0LHS, *Op0RHS, *Op1LHS, *Op1RHS;
@@ -4247,7 +4248,8 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
           if (Op0LHS == Op1LHS && Op0RHS == Op1RHS) {
             // Simplify (fcmp cc0 x, y) & (fcmp cc1 x, y).
             if (Op0CC == Op1CC)
           if (Op0LHS == Op1LHS && Op0RHS == Op1RHS) {
             // Simplify (fcmp cc0 x, y) & (fcmp cc1 x, y).
             if (Op0CC == Op1CC)
-              return new FCmpInst((FCmpInst::Predicate)Op0CC, Op0LHS, Op0RHS);
+              return new FCmpInst(*Context, (FCmpInst::Predicate)Op0CC,
+                                  Op0LHS, Op0RHS);
             else if (Op0CC == FCmpInst::FCMP_FALSE ||
                      Op1CC == FCmpInst::FCMP_FALSE)
               return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
             else if (Op0CC == FCmpInst::FCMP_FALSE ||
                      Op1CC == FCmpInst::FCMP_FALSE)
               return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
@@ -4532,7 +4534,7 @@ Instruction *InstCombiner::FoldOrOfICmps(Instruction &I,
                                                      Val->getName()+".off");
         InsertNewInstBefore(Add, I);
         AddCST = Context->getConstantExprSub(AddOne(RHSCst, Context), LHSCst);
                                                      Val->getName()+".off");
         InsertNewInstBefore(Add, I);
         AddCST = Context->getConstantExprSub(AddOne(RHSCst, Context), LHSCst);
-        return new ICmpInst(ICmpInst::ICMP_ULT, Add, AddCST);
+        return new ICmpInst(*Context, ICmpInst::ICMP_ULT, Add, AddCST);
       }
       break;                         // (X == 13 | X == 15) -> no change
     case ICmpInst::ICMP_UGT:         // (X == 13 | X u> 14) -> no change
       }
       break;                         // (X == 13 | X == 15) -> no change
     case ICmpInst::ICMP_UGT:         // (X == 13 | X u> 14) -> no change
@@ -4932,8 +4934,8 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
             
             // Otherwise, no need to compare the two constants, compare the
             // rest.
             
             // Otherwise, no need to compare the two constants, compare the
             // rest.
-            return new FCmpInst(FCmpInst::FCMP_UNO, LHS->getOperand(0),
-                                RHS->getOperand(0));
+            return new FCmpInst(*Context, FCmpInst::FCMP_UNO, 
+                                LHS->getOperand(0), RHS->getOperand(0));
           }
       } else {
         Value *Op0LHS, *Op0RHS, *Op1LHS, *Op1RHS;
           }
       } else {
         Value *Op0LHS, *Op0RHS, *Op1LHS, *Op1RHS;
@@ -4948,7 +4950,8 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
           if (Op0LHS == Op1LHS && Op0RHS == Op1RHS) {
             // Simplify (fcmp cc0 x, y) | (fcmp cc1 x, y).
             if (Op0CC == Op1CC)
           if (Op0LHS == Op1LHS && Op0RHS == Op1RHS) {
             // Simplify (fcmp cc0 x, y) | (fcmp cc1 x, y).
             if (Op0CC == Op1CC)
-              return new FCmpInst((FCmpInst::Predicate)Op0CC, Op0LHS, Op0RHS);
+              return new FCmpInst(*Context, (FCmpInst::Predicate)Op0CC,
+                                  Op0LHS, Op0RHS);
             else if (Op0CC == FCmpInst::FCMP_TRUE ||
                      Op1CC == FCmpInst::FCMP_TRUE)
               return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
             else if (Op0CC == FCmpInst::FCMP_TRUE ||
                      Op1CC == FCmpInst::FCMP_TRUE)
               return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
@@ -5046,11 +5049,11 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
     if (RHS == Context->getConstantIntTrue() && Op0->hasOneUse()) {
       // xor (cmp A, B), true = not (cmp A, B) = !cmp A, B
       if (ICmpInst *ICI = dyn_cast<ICmpInst>(Op0))
     if (RHS == Context->getConstantIntTrue() && Op0->hasOneUse()) {
       // xor (cmp A, B), true = not (cmp A, B) = !cmp A, B
       if (ICmpInst *ICI = dyn_cast<ICmpInst>(Op0))
-        return new ICmpInst(ICI->getInversePredicate(),
+        return new ICmpInst(*Context, ICI->getInversePredicate(),
                             ICI->getOperand(0), ICI->getOperand(1));
 
       if (FCmpInst *FCI = dyn_cast<FCmpInst>(Op0))
                             ICI->getOperand(0), ICI->getOperand(1));
 
       if (FCmpInst *FCI = dyn_cast<FCmpInst>(Op0))
-        return new FCmpInst(FCI->getInversePredicate(),
+        return new FCmpInst(*Context, FCI->getInversePredicate(),
                             FCI->getOperand(0), FCI->getOperand(1));
     }
 
                             FCI->getOperand(0), FCI->getOperand(1));
     }
 
@@ -5064,6 +5067,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
                                              Context->getConstantIntTrue(),
                                              Op0C->getDestTy())) {
               Instruction *NewCI = InsertNewInstBefore(CmpInst::Create(
                                              Context->getConstantIntTrue(),
                                              Op0C->getDestTy())) {
               Instruction *NewCI = InsertNewInstBefore(CmpInst::Create(
+                                     *Context,
                                      CI->getOpcode(), CI->getInversePredicate(),
                                      CI->getOperand(0), CI->getOperand(1)), I);
               NewCI->takeName(CI);
                                      CI->getOpcode(), CI->getInversePredicate(),
                                      CI->getOperand(0), CI->getOperand(1)), I);
               NewCI->takeName(CI);
@@ -5554,7 +5558,7 @@ Instruction *InstCombiner::FoldGEPICmp(User *GEPLHS, Value *RHS,
     // If not, synthesize the offset the hard way.
     if (Offset == 0)
       Offset = EmitGEPOffset(GEPLHS, I, *this);
     // If not, synthesize the offset the hard way.
     if (Offset == 0)
       Offset = EmitGEPOffset(GEPLHS, I, *this);
-    return new ICmpInst(ICmpInst::getSignedPredicate(Cond), Offset,
+    return new ICmpInst(*Context, ICmpInst::getSignedPredicate(Cond), Offset,
                         Context->getNullValue(Offset->getType()));
   } else if (User *GEPRHS = dyn_castGetElementPtr(RHS)) {
     // If the base pointers are different, but the indices are the same, just
                         Context->getNullValue(Offset->getType()));
   } else if (User *GEPRHS = dyn_castGetElementPtr(RHS)) {
     // If the base pointers are different, but the indices are the same, just
@@ -5572,7 +5576,7 @@ Instruction *InstCombiner::FoldGEPICmp(User *GEPLHS, Value *RHS,
 
       // If all indices are the same, just compare the base pointers.
       if (IndicesTheSame)
 
       // If all indices are the same, just compare the base pointers.
       if (IndicesTheSame)
-        return new ICmpInst(ICmpInst::getSignedPredicate(Cond), 
+        return new ICmpInst(*Context, ICmpInst::getSignedPredicate(Cond), 
                             GEPLHS->getOperand(0), GEPRHS->getOperand(0));
 
       // Otherwise, the base pointers are different and the indices are
                             GEPLHS->getOperand(0), GEPRHS->getOperand(0));
 
       // Otherwise, the base pointers are different and the indices are
@@ -5629,7 +5633,8 @@ Instruction *InstCombiner::FoldGEPICmp(User *GEPLHS, Value *RHS,
         Value *LHSV = GEPLHS->getOperand(DiffOperand);
         Value *RHSV = GEPRHS->getOperand(DiffOperand);
         // Make sure we do a signed comparison here.
         Value *LHSV = GEPLHS->getOperand(DiffOperand);
         Value *RHSV = GEPRHS->getOperand(DiffOperand);
         // Make sure we do a signed comparison here.
-        return new ICmpInst(ICmpInst::getSignedPredicate(Cond), LHSV, RHSV);
+        return new ICmpInst(*Context,
+                            ICmpInst::getSignedPredicate(Cond), LHSV, RHSV);
       }
     }
 
       }
     }
 
@@ -5640,7 +5645,7 @@ Instruction *InstCombiner::FoldGEPICmp(User *GEPLHS, Value *RHS,
       // ((gep Ptr, OFFSET1) cmp (gep Ptr, OFFSET2)  --->  (OFFSET1 cmp OFFSET2)
       Value *L = EmitGEPOffset(GEPLHS, I, *this);
       Value *R = EmitGEPOffset(GEPRHS, I, *this);
       // ((gep Ptr, OFFSET1) cmp (gep Ptr, OFFSET2)  --->  (OFFSET1 cmp OFFSET2)
       Value *L = EmitGEPOffset(GEPLHS, I, *this);
       Value *R = EmitGEPOffset(GEPRHS, I, *this);
-      return new ICmpInst(ICmpInst::getSignedPredicate(Cond), L, R);
+      return new ICmpInst(*Context, ICmpInst::getSignedPredicate(Cond), L, R);
     }
   }
   return 0;
     }
   }
   return 0;
@@ -5835,7 +5840,7 @@ Instruction *InstCombiner::FoldFCmp_IntToFP_Cst(FCmpInst &I,
 
   // Lower this FP comparison into an appropriate integer version of the
   // comparison.
 
   // Lower this FP comparison into an appropriate integer version of the
   // comparison.
-  return new ICmpInst(Pred, LHSI->getOperand(0), RHSInt);
+  return new ICmpInst(*Context, Pred, LHSI->getOperand(0), RHSInt);
 }
 
 Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
 }
 
 Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
@@ -5923,14 +5928,14 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
             // Fold the known value into the constant operand.
             Op1 = Context->getConstantExprCompare(I.getPredicate(), C, RHSC);
             // Insert a new FCmp of the other select operand.
             // Fold the known value into the constant operand.
             Op1 = Context->getConstantExprCompare(I.getPredicate(), C, RHSC);
             // Insert a new FCmp of the other select operand.
-            Op2 = InsertNewInstBefore(new FCmpInst(I.getPredicate(),
+            Op2 = InsertNewInstBefore(new FCmpInst(*Context, I.getPredicate(),
                                                       LHSI->getOperand(2), RHSC,
                                                       I.getName()), I);
           } else if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(2))) {
             // Fold the known value into the constant operand.
             Op2 = Context->getConstantExprCompare(I.getPredicate(), C, RHSC);
             // Insert a new FCmp of the other select operand.
                                                       LHSI->getOperand(2), RHSC,
                                                       I.getName()), I);
           } else if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(2))) {
             // Fold the known value into the constant operand.
             Op2 = Context->getConstantExprCompare(I.getPredicate(), C, RHSC);
             // Insert a new FCmp of the other select operand.
-            Op1 = InsertNewInstBefore(new FCmpInst(I.getPredicate(),
+            Op1 = InsertNewInstBefore(new FCmpInst(*Context, I.getPredicate(),
                                                       LHSI->getOperand(1), RHSC,
                                                       I.getName()), I);
           }
                                                       LHSI->getOperand(1), RHSC,
                                                       I.getName()), I);
           }
@@ -6030,7 +6035,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
     if (I.isEquality() && CI->isNullValue() &&
         match(Op0, m_Sub(m_Value(A), m_Value(B)))) {
       // (icmp cond A B) if cond is equality
     if (I.isEquality() && CI->isNullValue() &&
         match(Op0, m_Sub(m_Value(A), m_Value(B)))) {
       // (icmp cond A B) if cond is equality
-      return new ICmpInst(I.getPredicate(), A, B);
+      return new ICmpInst(*Context, I.getPredicate(), A, B);
     }
     
     // If we have an icmp le or icmp ge instruction, turn it into the
     }
     
     // If we have an icmp le or icmp ge instruction, turn it into the
@@ -6041,19 +6046,23 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
     case ICmpInst::ICMP_ULE:
       if (CI->isMaxValue(false))                 // A <=u MAX -> TRUE
         return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
     case ICmpInst::ICMP_ULE:
       if (CI->isMaxValue(false))                 // A <=u MAX -> TRUE
         return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
-      return new ICmpInst(ICmpInst::ICMP_ULT, Op0, AddOne(CI, Context));
+      return new ICmpInst(*Context, ICmpInst::ICMP_ULT, Op0,
+                          AddOne(CI, Context));
     case ICmpInst::ICMP_SLE:
       if (CI->isMaxValue(true))                  // A <=s MAX -> TRUE
         return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
     case ICmpInst::ICMP_SLE:
       if (CI->isMaxValue(true))                  // A <=s MAX -> TRUE
         return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
-      return new ICmpInst(ICmpInst::ICMP_SLT, Op0, AddOne(CI, Context));
+      return new ICmpInst(*Context, ICmpInst::ICMP_SLT, Op0,
+                          AddOne(CI, Context));
     case ICmpInst::ICMP_UGE:
       if (CI->isMinValue(false))                 // A >=u MIN -> TRUE
         return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
     case ICmpInst::ICMP_UGE:
       if (CI->isMinValue(false))                 // A >=u MIN -> TRUE
         return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
-      return new ICmpInst( ICmpInst::ICMP_UGT, Op0, SubOne(CI, Context));
+      return new ICmpInst(*Context, ICmpInst::ICMP_UGT, Op0,
+                          SubOne(CI, Context));
     case ICmpInst::ICMP_SGE:
       if (CI->isMinValue(true))                  // A >=s MIN -> TRUE
         return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
     case ICmpInst::ICMP_SGE:
       if (CI->isMinValue(true))                  // A >=s MIN -> TRUE
         return ReplaceInstUsesWith(I, Context->getConstantIntTrue());
-      return new ICmpInst(ICmpInst::ICMP_SGT, Op0, SubOne(CI, Context));
+      return new ICmpInst(*Context, ICmpInst::ICMP_SGT, Op0,
+                          SubOne(CI, Context));
     }
     
     // If this comparison is a normal comparison, it demands all
     }
     
     // If this comparison is a normal comparison, it demands all
@@ -6099,10 +6108,10 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
     // figured out that the LHS is a constant.  Just constant fold this now so
     // that code below can assume that Min != Max.
     if (!isa<Constant>(Op0) && Op0Min == Op0Max)
     // figured out that the LHS is a constant.  Just constant fold this now so
     // that code below can assume that Min != Max.
     if (!isa<Constant>(Op0) && Op0Min == Op0Max)
-      return new ICmpInst(I.getPredicate(),
+      return new ICmpInst(*Context, I.getPredicate(),
                           Context->getConstantInt(Op0Min), Op1);
     if (!isa<Constant>(Op1) && Op1Min == Op1Max)
                           Context->getConstantInt(Op0Min), Op1);
     if (!isa<Constant>(Op1) && Op1Min == Op1Max)
-      return new ICmpInst(I.getPredicate(), Op0, 
+      return new ICmpInst(*Context, I.getPredicate(), Op0, 
                           Context->getConstantInt(Op1Min));
 
     // Based on the range information we know about the LHS, see if we can
                           Context->getConstantInt(Op1Min));
 
     // Based on the range information we know about the LHS, see if we can
@@ -6123,14 +6132,15 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
       if (Op0Min.uge(Op1Max))          // A <u B -> false if min(A) >= max(B)
         return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
       if (Op1Min == Op0Max)            // A <u B -> A != B if max(A) == min(B)
       if (Op0Min.uge(Op1Max))          // A <u B -> false if min(A) >= max(B)
         return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
       if (Op1Min == Op0Max)            // A <u B -> A != B if max(A) == min(B)
-        return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
+        return new ICmpInst(*Context, ICmpInst::ICMP_NE, Op0, Op1);
       if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
         if (Op1Max == Op0Min+1)        // A <u C -> A == C-1 if min(A)+1 == C
       if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
         if (Op1Max == Op0Min+1)        // A <u C -> A == C-1 if min(A)+1 == C
-          return new ICmpInst(ICmpInst::ICMP_EQ, Op0, SubOne(CI, Context));
+          return new ICmpInst(*Context, ICmpInst::ICMP_EQ, Op0,
+                              SubOne(CI, Context));
 
         // (x <u 2147483648) -> (x >s -1)  -> true if sign bit clear
         if (CI->isMinValue(true))
 
         // (x <u 2147483648) -> (x >s -1)  -> true if sign bit clear
         if (CI->isMinValue(true))
-          return new ICmpInst(ICmpInst::ICMP_SGT, Op0,
+          return new ICmpInst(*Context, ICmpInst::ICMP_SGT, Op0,
                            Context->getConstantIntAllOnesValue(Op0->getType()));
       }
       break;
                            Context->getConstantIntAllOnesValue(Op0->getType()));
       }
       break;
@@ -6141,14 +6151,15 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
         return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
 
       if (Op1Max == Op0Min)            // A >u B -> A != B if min(A) == max(B)
         return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
 
       if (Op1Max == Op0Min)            // A >u B -> A != B if min(A) == max(B)
-        return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
+        return new ICmpInst(*Context, ICmpInst::ICMP_NE, Op0, Op1);
       if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
         if (Op1Min == Op0Max-1)        // A >u C -> A == C+1 if max(a)-1 == C
       if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
         if (Op1Min == Op0Max-1)        // A >u C -> A == C+1 if max(a)-1 == C
-          return new ICmpInst(ICmpInst::ICMP_EQ, Op0, AddOne(CI, Context));
+          return new ICmpInst(*Context, ICmpInst::ICMP_EQ, Op0,
+                              AddOne(CI, Context));
 
         // (x >u 2147483647) -> (x <s 0)  -> true if sign bit set
         if (CI->isMaxValue(true))
 
         // (x >u 2147483647) -> (x <s 0)  -> true if sign bit set
         if (CI->isMaxValue(true))
-          return new ICmpInst(ICmpInst::ICMP_SLT, Op0,
+          return new ICmpInst(*Context, ICmpInst::ICMP_SLT, Op0,
                               Context->getNullValue(Op0->getType()));
       }
       break;
                               Context->getNullValue(Op0->getType()));
       }
       break;
@@ -6158,10 +6169,11 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
       if (Op0Min.sge(Op1Max))          // A <s B -> false if min(A) >= max(C)
         return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
       if (Op1Min == Op0Max)            // A <s B -> A != B if max(A) == min(B)
       if (Op0Min.sge(Op1Max))          // A <s B -> false if min(A) >= max(C)
         return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
       if (Op1Min == Op0Max)            // A <s B -> A != B if max(A) == min(B)
-        return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
+        return new ICmpInst(*Context, ICmpInst::ICMP_NE, Op0, Op1);
       if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
         if (Op1Max == Op0Min+1)        // A <s C -> A == C-1 if min(A)+1 == C
       if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
         if (Op1Max == Op0Min+1)        // A <s C -> A == C-1 if min(A)+1 == C
-          return new ICmpInst(ICmpInst::ICMP_EQ, Op0, SubOne(CI, Context));
+          return new ICmpInst(*Context, ICmpInst::ICMP_EQ, Op0,
+                              SubOne(CI, Context));
       }
       break;
     case ICmpInst::ICMP_SGT:
       }
       break;
     case ICmpInst::ICMP_SGT:
@@ -6171,10 +6183,11 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
         return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
 
       if (Op1Max == Op0Min)            // A >s B -> A != B if min(A) == max(B)
         return ReplaceInstUsesWith(I, Context->getConstantIntFalse());
 
       if (Op1Max == Op0Min)            // A >s B -> A != B if min(A) == max(B)
-        return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
+        return new ICmpInst(*Context, ICmpInst::ICMP_NE, Op0, Op1);
       if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
         if (Op1Min == Op0Max-1)        // A >s C -> A == C+1 if max(A)-1 == C
       if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
         if (Op1Min == Op0Max-1)        // A >s C -> A == C+1 if max(A)-1 == C
-          return new ICmpInst(ICmpInst::ICMP_EQ, Op0, AddOne(CI, Context));
+          return new ICmpInst(*Context, ICmpInst::ICMP_EQ, Op0,
+                              AddOne(CI, Context));
       }
       break;
     case ICmpInst::ICMP_SGE:
       }
       break;
     case ICmpInst::ICMP_SGE:
@@ -6212,7 +6225,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
     if (I.isSignedPredicate() &&
         ((Op0KnownZero.isNegative() && Op1KnownZero.isNegative()) ||
          (Op0KnownOne.isNegative() && Op1KnownOne.isNegative())))
     if (I.isSignedPredicate() &&
         ((Op0KnownZero.isNegative() && Op1KnownZero.isNegative()) ||
          (Op0KnownOne.isNegative() && Op1KnownOne.isNegative())))
-      return new ICmpInst(I.getUnsignedPredicate(), Op0, Op1);
+      return new ICmpInst(*Context, I.getUnsignedPredicate(), Op0, Op1);
   }
 
   // Test if the ICmpInst instruction is used exclusively by a select as
   }
 
   // Test if the ICmpInst instruction is used exclusively by a select as
@@ -6254,7 +6267,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
               break;
             }
           if (isAllZeros)
               break;
             }
           if (isAllZeros)
-            return new ICmpInst(I.getPredicate(), LHSI->getOperand(0),
+            return new ICmpInst(*Context, I.getPredicate(), LHSI->getOperand(0),
                     Context->getNullValue(LHSI->getOperand(0)->getType()));
         }
         break;
                     Context->getNullValue(LHSI->getOperand(0)->getType()));
         }
         break;
@@ -6277,14 +6290,14 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
             // Fold the known value into the constant operand.
             Op1 = Context->getConstantExprICmp(I.getPredicate(), C, RHSC);
             // Insert a new ICmp of the other select operand.
             // Fold the known value into the constant operand.
             Op1 = Context->getConstantExprICmp(I.getPredicate(), C, RHSC);
             // Insert a new ICmp of the other select operand.
-            Op2 = InsertNewInstBefore(new ICmpInst(I.getPredicate(),
+            Op2 = InsertNewInstBefore(new ICmpInst(*Context, I.getPredicate(),
                                                    LHSI->getOperand(2), RHSC,
                                                    I.getName()), I);
           } else if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(2))) {
             // Fold the known value into the constant operand.
             Op2 = Context->getConstantExprICmp(I.getPredicate(), C, RHSC);
             // Insert a new ICmp of the other select operand.
                                                    LHSI->getOperand(2), RHSC,
                                                    I.getName()), I);
           } else if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(2))) {
             // Fold the known value into the constant operand.
             Op2 = Context->getConstantExprICmp(I.getPredicate(), C, RHSC);
             // Insert a new ICmp of the other select operand.
-            Op1 = InsertNewInstBefore(new ICmpInst(I.getPredicate(),
+            Op1 = InsertNewInstBefore(new ICmpInst(*Context, I.getPredicate(),
                                                    LHSI->getOperand(1), RHSC,
                                                    I.getName()), I);
           }
                                                    LHSI->getOperand(1), RHSC,
                                                    I.getName()), I);
           }
@@ -6339,7 +6352,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
           Op1 = InsertBitCastBefore(Op1, Op0->getType(), I);
         }
       }
           Op1 = InsertBitCastBefore(Op1, Op0->getType(), I);
         }
       }
-      return new ICmpInst(I.getPredicate(), Op0, Op1);
+      return new ICmpInst(*Context, I.getPredicate(), Op0, Op1);
     }
   }
   
     }
   }
   
@@ -6366,7 +6379,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
         case Instruction::Sub:
         case Instruction::Xor:
           if (I.isEquality())    // a+x icmp eq/ne b+x --> a icmp b
         case Instruction::Sub:
         case Instruction::Xor:
           if (I.isEquality())    // a+x icmp eq/ne b+x --> a icmp b
-            return new ICmpInst(I.getPredicate(), Op0I->getOperand(0),
+            return new ICmpInst(*Context, I.getPredicate(), Op0I->getOperand(0),
                                 Op1I->getOperand(0));
           // icmp u/s (a ^ signbit), (b ^ signbit) --> icmp s/u a, b
           if (ConstantInt *CI = dyn_cast<ConstantInt>(Op0I->getOperand(1))) {
                                 Op1I->getOperand(0));
           // icmp u/s (a ^ signbit), (b ^ signbit) --> icmp s/u a, b
           if (ConstantInt *CI = dyn_cast<ConstantInt>(Op0I->getOperand(1))) {
@@ -6374,7 +6387,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
               ICmpInst::Predicate Pred = I.isSignedPredicate()
                                              ? I.getUnsignedPredicate()
                                              : I.getSignedPredicate();
               ICmpInst::Predicate Pred = I.isSignedPredicate()
                                              ? I.getUnsignedPredicate()
                                              : I.getSignedPredicate();
-              return new ICmpInst(Pred, Op0I->getOperand(0),
+              return new ICmpInst(*Context, Pred, Op0I->getOperand(0),
                                   Op1I->getOperand(0));
             }
             
                                   Op1I->getOperand(0));
             }
             
@@ -6383,7 +6396,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
                                              ? I.getUnsignedPredicate()
                                              : I.getSignedPredicate();
               Pred = I.getSwappedPredicate(Pred);
                                              ? I.getUnsignedPredicate()
                                              : I.getSignedPredicate();
               Pred = I.getSwappedPredicate(Pred);
-              return new ICmpInst(Pred, Op0I->getOperand(0),
+              return new ICmpInst(*Context, Pred, Op0I->getOperand(0),
                                   Op1I->getOperand(0));
             }
           }
                                   Op1I->getOperand(0));
             }
           }
@@ -6407,7 +6420,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
                                                             Mask);
               InsertNewInstBefore(And1, I);
               InsertNewInstBefore(And2, I);
                                                             Mask);
               InsertNewInstBefore(And1, I);
               InsertNewInstBefore(And2, I);
-              return new ICmpInst(I.getPredicate(), And1, And2);
+              return new ICmpInst(*Context, I.getPredicate(), And1, And2);
             }
           }
           break;
             }
           }
           break;
@@ -6420,7 +6433,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
   { Value *A, *B;
     if (match(Op0, m_Not(m_Value(A))) &&
         match(Op1, m_Not(m_Value(B))))
   { Value *A, *B;
     if (match(Op0, m_Not(m_Value(A))) &&
         match(Op1, m_Not(m_Value(B))))
-      return new ICmpInst(I.getPredicate(), B, A);
+      return new ICmpInst(*Context, I.getPredicate(), B, A);
   }
   
   if (I.isEquality()) {
   }
   
   if (I.isEquality()) {
@@ -6429,12 +6442,12 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
     // -x == -y --> x == y
     if (match(Op0, m_Neg(m_Value(A))) &&
         match(Op1, m_Neg(m_Value(B))))
     // -x == -y --> x == y
     if (match(Op0, m_Neg(m_Value(A))) &&
         match(Op1, m_Neg(m_Value(B))))
-      return new ICmpInst(I.getPredicate(), A, B);
+      return new ICmpInst(*Context, I.getPredicate(), A, B);
     
     if (match(Op0, m_Xor(m_Value(A), m_Value(B)))) {
       if (A == Op1 || B == Op1) {    // (A^B) == A  ->  B == 0
         Value *OtherVal = A == Op1 ? B : A;
     
     if (match(Op0, m_Xor(m_Value(A), m_Value(B)))) {
       if (A == Op1 || B == Op1) {    // (A^B) == A  ->  B == 0
         Value *OtherVal = A == Op1 ? B : A;
-        return new ICmpInst(I.getPredicate(), OtherVal,
+        return new ICmpInst(*Context, I.getPredicate(), OtherVal,
                             Context->getNullValue(A->getType()));
       }
 
                             Context->getNullValue(A->getType()));
       }
 
@@ -6446,15 +6459,15 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
           Constant *NC = 
                        Context->getConstantInt(C1->getValue() ^ C2->getValue());
           Instruction *Xor = BinaryOperator::CreateXor(C, NC, "tmp");
           Constant *NC = 
                        Context->getConstantInt(C1->getValue() ^ C2->getValue());
           Instruction *Xor = BinaryOperator::CreateXor(C, NC, "tmp");
-          return new ICmpInst(I.getPredicate(), A,
+          return new ICmpInst(*Context, I.getPredicate(), A,
                               InsertNewInstBefore(Xor, I));
         }
         
         // A^B == A^D -> B == D
                               InsertNewInstBefore(Xor, I));
         }
         
         // A^B == A^D -> B == D
-        if (A == C) return new ICmpInst(I.getPredicate(), B, D);
-        if (A == D) return new ICmpInst(I.getPredicate(), B, C);
-        if (B == C) return new ICmpInst(I.getPredicate(), A, D);
-        if (B == D) return new ICmpInst(I.getPredicate(), A, C);
+        if (A == C) return new ICmpInst(*Context, I.getPredicate(), B, D);
+        if (A == D) return new ICmpInst(*Context, I.getPredicate(), B, C);
+        if (B == C) return new ICmpInst(*Context, I.getPredicate(), A, D);
+        if (B == D) return new ICmpInst(*Context, I.getPredicate(), A, C);
       }
     }
     
       }
     }
     
@@ -6462,18 +6475,18 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
         (A == Op0 || B == Op0)) {
       // A == (A^B)  ->  B == 0
       Value *OtherVal = A == Op0 ? B : A;
         (A == Op0 || B == Op0)) {
       // A == (A^B)  ->  B == 0
       Value *OtherVal = A == Op0 ? B : A;
-      return new ICmpInst(I.getPredicate(), OtherVal,
+      return new ICmpInst(*Context, I.getPredicate(), OtherVal,
                           Context->getNullValue(A->getType()));
     }
 
     // (A-B) == A  ->  B == 0
     if (match(Op0, m_Sub(m_Specific(Op1), m_Value(B))))
                           Context->getNullValue(A->getType()));
     }
 
     // (A-B) == A  ->  B == 0
     if (match(Op0, m_Sub(m_Specific(Op1), m_Value(B))))
-      return new ICmpInst(I.getPredicate(), B, 
+      return new ICmpInst(*Context, I.getPredicate(), B, 
                           Context->getNullValue(B->getType()));
 
     // A == (A-B)  ->  B == 0
     if (match(Op1, m_Sub(m_Specific(Op0), m_Value(B))))
                           Context->getNullValue(B->getType()));
 
     // A == (A-B)  ->  B == 0
     if (match(Op1, m_Sub(m_Specific(Op0), m_Value(B))))
-      return new ICmpInst(I.getPredicate(), B,
+      return new ICmpInst(*Context, I.getPredicate(), B,
                           Context->getNullValue(B->getType()));
     
     // (X&Z) == (Y&Z) -> (X^Y) & Z == 0
                           Context->getNullValue(B->getType()));
     
     // (X&Z) == (Y&Z) -> (X^Y) & Z == 0
@@ -6618,10 +6631,10 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
     if (LoOverflow && HiOverflow)
       return ReplaceInstUsesWith(ICI, Context->getConstantIntFalse());
     else if (HiOverflow)
     if (LoOverflow && HiOverflow)
       return ReplaceInstUsesWith(ICI, Context->getConstantIntFalse());
     else if (HiOverflow)
-      return new ICmpInst(DivIsSigned ? ICmpInst::ICMP_SGE : 
+      return new ICmpInst(*Context, DivIsSigned ? ICmpInst::ICMP_SGE : 
                           ICmpInst::ICMP_UGE, X, LoBound);
     else if (LoOverflow)
                           ICmpInst::ICMP_UGE, X, LoBound);
     else if (LoOverflow)
-      return new ICmpInst(DivIsSigned ? ICmpInst::ICMP_SLT : 
+      return new ICmpInst(*Context, DivIsSigned ? ICmpInst::ICMP_SLT : 
                           ICmpInst::ICMP_ULT, X, HiBound);
     else
       return InsertRangeTest(X, LoBound, HiBound, DivIsSigned, true, ICI);
                           ICmpInst::ICMP_ULT, X, HiBound);
     else
       return InsertRangeTest(X, LoBound, HiBound, DivIsSigned, true, ICI);
@@ -6629,10 +6642,10 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
     if (LoOverflow && HiOverflow)
       return ReplaceInstUsesWith(ICI, Context->getConstantIntTrue());
     else if (HiOverflow)
     if (LoOverflow && HiOverflow)
       return ReplaceInstUsesWith(ICI, Context->getConstantIntTrue());
     else if (HiOverflow)
-      return new ICmpInst(DivIsSigned ? ICmpInst::ICMP_SLT : 
+      return new ICmpInst(*Context, DivIsSigned ? ICmpInst::ICMP_SLT : 
                           ICmpInst::ICMP_ULT, X, LoBound);
     else if (LoOverflow)
                           ICmpInst::ICMP_ULT, X, LoBound);
     else if (LoOverflow)
-      return new ICmpInst(DivIsSigned ? ICmpInst::ICMP_SGE : 
+      return new ICmpInst(*Context, DivIsSigned ? ICmpInst::ICMP_SGE : 
                           ICmpInst::ICMP_UGE, X, HiBound);
     else
       return InsertRangeTest(X, LoBound, HiBound, DivIsSigned, false, ICI);
                           ICmpInst::ICMP_UGE, X, HiBound);
     else
       return InsertRangeTest(X, LoBound, HiBound, DivIsSigned, false, ICI);
@@ -6642,7 +6655,7 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
       return ReplaceInstUsesWith(ICI, Context->getConstantIntTrue());
     if (LoOverflow == -1)   // Low bound is less than input range.
       return ReplaceInstUsesWith(ICI, Context->getConstantIntFalse());
       return ReplaceInstUsesWith(ICI, Context->getConstantIntTrue());
     if (LoOverflow == -1)   // Low bound is less than input range.
       return ReplaceInstUsesWith(ICI, Context->getConstantIntFalse());
-    return new ICmpInst(Pred, X, LoBound);
+    return new ICmpInst(*Context, Pred, X, LoBound);
   case ICmpInst::ICMP_UGT:
   case ICmpInst::ICMP_SGT:
     if (HiOverflow == +1)       // High bound greater than input range.
   case ICmpInst::ICMP_UGT:
   case ICmpInst::ICMP_SGT:
     if (HiOverflow == +1)       // High bound greater than input range.
@@ -6650,9 +6663,9 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
     else if (HiOverflow == -1)  // High bound less than input range.
       return ReplaceInstUsesWith(ICI, Context->getConstantIntTrue());
     if (Pred == ICmpInst::ICMP_UGT)
     else if (HiOverflow == -1)  // High bound less than input range.
       return ReplaceInstUsesWith(ICI, Context->getConstantIntTrue());
     if (Pred == ICmpInst::ICMP_UGT)
-      return new ICmpInst(ICmpInst::ICMP_UGE, X, HiBound);
+      return new ICmpInst(*Context, ICmpInst::ICMP_UGE, X, HiBound);
     else
     else
-      return new ICmpInst(ICmpInst::ICMP_SGE, X, HiBound);
+      return new ICmpInst(*Context, ICmpInst::ICMP_SGE, X, HiBound);
   }
 }
 
   }
 }
 
@@ -6681,7 +6694,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
         APInt NewRHS(RHS->getValue());
         NewRHS.zext(SrcBits);
         NewRHS |= KnownOne;
         APInt NewRHS(RHS->getValue());
         NewRHS.zext(SrcBits);
         NewRHS |= KnownOne;
-        return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
+        return new ICmpInst(*Context, ICI.getPredicate(), LHSI->getOperand(0),
                             Context->getConstantInt(NewRHS));
       }
     }
                             Context->getConstantInt(NewRHS));
       }
     }
@@ -6710,10 +6723,10 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
         isTrueIfPositive ^= true;
         
         if (isTrueIfPositive)
         isTrueIfPositive ^= true;
         
         if (isTrueIfPositive)
-          return new ICmpInst(ICmpInst::ICMP_SGT, CompareVal,
+          return new ICmpInst(*Context, ICmpInst::ICMP_SGT, CompareVal,
                               SubOne(RHS, Context));
         else
                               SubOne(RHS, Context));
         else
-          return new ICmpInst(ICmpInst::ICMP_SLT, CompareVal,
+          return new ICmpInst(*Context, ICmpInst::ICMP_SLT, CompareVal,
                               AddOne(RHS, Context));
       }
 
                               AddOne(RHS, Context));
       }
 
@@ -6724,7 +6737,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
           ICmpInst::Predicate Pred = ICI.isSignedPredicate()
                                          ? ICI.getUnsignedPredicate()
                                          : ICI.getSignedPredicate();
           ICmpInst::Predicate Pred = ICI.isSignedPredicate()
                                          ? ICI.getUnsignedPredicate()
                                          : ICI.getSignedPredicate();
-          return new ICmpInst(Pred, LHSI->getOperand(0),
+          return new ICmpInst(*Context, Pred, LHSI->getOperand(0),
                               Context->getConstantInt(RHSV ^ SignBit));
         }
 
                               Context->getConstantInt(RHSV ^ SignBit));
         }
 
@@ -6735,7 +6748,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
                                          ? ICI.getUnsignedPredicate()
                                          : ICI.getSignedPredicate();
           Pred = ICI.getSwappedPredicate(Pred);
                                          ? ICI.getUnsignedPredicate()
                                          : ICI.getSignedPredicate();
           Pred = ICI.getSwappedPredicate(Pred);
-          return new ICmpInst(Pred, LHSI->getOperand(0),
+          return new ICmpInst(*Context, Pred, LHSI->getOperand(0),
                               Context->getConstantInt(RHSV ^ NotSignBit));
         }
       }
                               Context->getConstantInt(RHSV ^ NotSignBit));
         }
       }
@@ -6767,7 +6780,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
             BinaryOperator::CreateAnd(Cast->getOperand(0),
                                Context->getConstantInt(NewCST),LHSI->getName());
           InsertNewInstBefore(NewAnd, ICI);
             BinaryOperator::CreateAnd(Cast->getOperand(0),
                                Context->getConstantInt(NewCST),LHSI->getName());
           InsertNewInstBefore(NewAnd, ICI);
-          return new ICmpInst(ICI.getPredicate(), NewAnd,
+          return new ICmpInst(*Context, ICI.getPredicate(), NewAnd,
                               Context->getConstantInt(NewCI));
         }
       }
                               Context->getConstantInt(NewCI));
         }
       }
@@ -6900,7 +6913,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
           BinaryOperator::CreateAnd(LHSI->getOperand(0),
                                     Mask, LHSI->getName()+".mask");
         Value *And = InsertNewInstBefore(AndI, ICI);
           BinaryOperator::CreateAnd(LHSI->getOperand(0),
                                     Mask, LHSI->getName()+".mask");
         Value *And = InsertNewInstBefore(AndI, ICI);
-        return new ICmpInst(ICI.getPredicate(), And,
+        return new ICmpInst(*Context, ICI.getPredicate(), And,
                             Context->getConstantInt(RHSV.lshr(ShAmtVal)));
       }
     }
                             Context->getConstantInt(RHSV.lshr(ShAmtVal)));
       }
     }
@@ -6917,7 +6930,8 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
                                   Mask, LHSI->getName()+".mask");
       Value *And = InsertNewInstBefore(AndI, ICI);
       
                                   Mask, LHSI->getName()+".mask");
       Value *And = InsertNewInstBefore(AndI, ICI);
       
-      return new ICmpInst(TrueIfSigned ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ,
+      return new ICmpInst(*Context,
+                          TrueIfSigned ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ,
                           And, Context->getNullValue(And->getType()));
     }
     break;
                           And, Context->getNullValue(And->getType()));
     }
     break;
@@ -6958,7 +6972,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
     if (LHSI->hasOneUse() &&
         MaskedValueIsZero(LHSI->getOperand(0), 
                           APInt::getLowBitsSet(Comp.getBitWidth(), ShAmtVal))) {
     if (LHSI->hasOneUse() &&
         MaskedValueIsZero(LHSI->getOperand(0), 
                           APInt::getLowBitsSet(Comp.getBitWidth(), ShAmtVal))) {
-      return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
+      return new ICmpInst(*Context, ICI.getPredicate(), LHSI->getOperand(0),
                           Context->getConstantExprShl(RHS, ShAmt));
     }
       
                           Context->getConstantExprShl(RHS, ShAmt));
     }
       
@@ -6971,7 +6985,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
         BinaryOperator::CreateAnd(LHSI->getOperand(0),
                                   Mask, LHSI->getName()+".mask");
       Value *And = InsertNewInstBefore(AndI, ICI);
         BinaryOperator::CreateAnd(LHSI->getOperand(0),
                                   Mask, LHSI->getName()+".mask");
       Value *And = InsertNewInstBefore(AndI, ICI);
-      return new ICmpInst(ICI.getPredicate(), And,
+      return new ICmpInst(*Context, ICI.getPredicate(), And,
                           Context->getConstantExprShl(RHS, ShAmt));
     }
     break;
                           Context->getConstantExprShl(RHS, ShAmt));
     }
     break;
@@ -7004,18 +7018,18 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
 
       if (ICI.isSignedPredicate()) {
         if (CR.getLower().isSignBit()) {
 
       if (ICI.isSignedPredicate()) {
         if (CR.getLower().isSignBit()) {
-          return new ICmpInst(ICmpInst::ICMP_SLT, LHSI->getOperand(0),
+          return new ICmpInst(*Context, ICmpInst::ICMP_SLT, LHSI->getOperand(0),
                               Context->getConstantInt(CR.getUpper()));
         } else if (CR.getUpper().isSignBit()) {
                               Context->getConstantInt(CR.getUpper()));
         } else if (CR.getUpper().isSignBit()) {
-          return new ICmpInst(ICmpInst::ICMP_SGE, LHSI->getOperand(0),
+          return new ICmpInst(*Context, ICmpInst::ICMP_SGE, LHSI->getOperand(0),
                               Context->getConstantInt(CR.getLower()));
         }
       } else {
         if (CR.getLower().isMinValue()) {
                               Context->getConstantInt(CR.getLower()));
         }
       } else {
         if (CR.getLower().isMinValue()) {
-          return new ICmpInst(ICmpInst::ICMP_ULT, LHSI->getOperand(0),
+          return new ICmpInst(*Context, ICmpInst::ICMP_ULT, LHSI->getOperand(0),
                               Context->getConstantInt(CR.getUpper()));
         } else if (CR.getUpper().isMinValue()) {
                               Context->getConstantInt(CR.getUpper()));
         } else if (CR.getUpper().isMinValue()) {
-          return new ICmpInst(ICmpInst::ICMP_UGE, LHSI->getOperand(0),
+          return new ICmpInst(*Context, ICmpInst::ICMP_UGE, LHSI->getOperand(0),
                               Context->getConstantInt(CR.getLower()));
         }
       }
                               Context->getConstantInt(CR.getLower()));
         }
       }
@@ -7040,7 +7054,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
               BinaryOperator::CreateURem(BO->getOperand(0), BO->getOperand(1),
                                          BO->getName());
             InsertNewInstBefore(NewRem, ICI);
               BinaryOperator::CreateURem(BO->getOperand(0), BO->getOperand(1),
                                          BO->getName());
             InsertNewInstBefore(NewRem, ICI);
-            return new ICmpInst(ICI.getPredicate(), NewRem, 
+            return new ICmpInst(*Context, ICI.getPredicate(), NewRem, 
                                 Context->getNullValue(BO->getType()));
           }
         }
                                 Context->getNullValue(BO->getType()));
           }
         }
@@ -7049,7 +7063,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
         // Replace ((add A, B) != C) with (A != C-B) if B & C are constants.
         if (ConstantInt *BOp1C = dyn_cast<ConstantInt>(BO->getOperand(1))) {
           if (BO->hasOneUse())
         // Replace ((add A, B) != C) with (A != C-B) if B & C are constants.
         if (ConstantInt *BOp1C = dyn_cast<ConstantInt>(BO->getOperand(1))) {
           if (BO->hasOneUse())
-            return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
+            return new ICmpInst(*Context, ICI.getPredicate(), BO->getOperand(0),
                                 Context->getConstantExprSub(RHS, BOp1C));
         } else if (RHSV == 0) {
           // Replace ((add A, B) != 0) with (A != -B) if A or B is
                                 Context->getConstantExprSub(RHS, BOp1C));
         } else if (RHSV == 0) {
           // Replace ((add A, B) != 0) with (A != -B) if A or B is
@@ -7057,14 +7071,14 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
           Value *BOp0 = BO->getOperand(0), *BOp1 = BO->getOperand(1);
           
           if (Value *NegVal = dyn_castNegVal(BOp1, Context))
           Value *BOp0 = BO->getOperand(0), *BOp1 = BO->getOperand(1);
           
           if (Value *NegVal = dyn_castNegVal(BOp1, Context))
-            return new ICmpInst(ICI.getPredicate(), BOp0, NegVal);
+            return new ICmpInst(*Context, ICI.getPredicate(), BOp0, NegVal);
           else if (Value *NegVal = dyn_castNegVal(BOp0, Context))
           else if (Value *NegVal = dyn_castNegVal(BOp0, Context))
-            return new ICmpInst(ICI.getPredicate(), NegVal, BOp1);
+            return new ICmpInst(*Context, ICI.getPredicate(), NegVal, BOp1);
           else if (BO->hasOneUse()) {
             Instruction *Neg = BinaryOperator::CreateNeg(BOp1);
             InsertNewInstBefore(Neg, ICI);
             Neg->takeName(BO);
           else if (BO->hasOneUse()) {
             Instruction *Neg = BinaryOperator::CreateNeg(BOp1);
             InsertNewInstBefore(Neg, ICI);
             Neg->takeName(BO);
-            return new ICmpInst(ICI.getPredicate(), BOp0, Neg);
+            return new ICmpInst(*Context, ICI.getPredicate(), BOp0, Neg);
           }
         }
         break;
           }
         }
         break;
@@ -7072,14 +7086,14 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
         // For the xor case, we can xor two constants together, eliminating
         // the explicit xor.
         if (Constant *BOC = dyn_cast<Constant>(BO->getOperand(1)))
         // For the xor case, we can xor two constants together, eliminating
         // the explicit xor.
         if (Constant *BOC = dyn_cast<Constant>(BO->getOperand(1)))
-          return new ICmpInst(ICI.getPredicate(), BO->getOperand(0), 
+          return new ICmpInst(*Context, ICI.getPredicate(), BO->getOperand(0), 
                               Context->getConstantExprXor(RHS, BOC));
         
         // FALLTHROUGH
       case Instruction::Sub:
         // Replace (([sub|xor] A, B) != 0) with (A != B)
         if (RHSV == 0)
                               Context->getConstantExprXor(RHS, BOC));
         
         // FALLTHROUGH
       case Instruction::Sub:
         // Replace (([sub|xor] A, B) != 0) with (A != B)
         if (RHSV == 0)
-          return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
+          return new ICmpInst(*Context, ICI.getPredicate(), BO->getOperand(0),
                               BO->getOperand(1));
         break;
         
                               BO->getOperand(1));
         break;
         
@@ -7106,7 +7120,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
           
           // If we have ((X & C) == C), turn it into ((X & C) != 0).
           if (RHS == BOC && RHSV.isPowerOf2())
           
           // If we have ((X & C) == C), turn it into ((X & C) != 0).
           if (RHS == BOC && RHSV.isPowerOf2())
-            return new ICmpInst(isICMP_NE ? ICmpInst::ICMP_EQ :
+            return new ICmpInst(*Context, isICMP_NE ? ICmpInst::ICMP_EQ :
                                 ICmpInst::ICMP_NE, LHSI,
                                 Context->getNullValue(RHS->getType()));
           
                                 ICmpInst::ICMP_NE, LHSI,
                                 Context->getNullValue(RHS->getType()));
           
@@ -7116,7 +7130,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
             Constant *Zero = Context->getNullValue(X->getType());
             ICmpInst::Predicate pred = isICMP_NE ? 
               ICmpInst::ICMP_SLT : ICmpInst::ICMP_SGE;
             Constant *Zero = Context->getNullValue(X->getType());
             ICmpInst::Predicate pred = isICMP_NE ? 
               ICmpInst::ICMP_SLT : ICmpInst::ICMP_SGE;
-            return new ICmpInst(pred, X, Zero);
+            return new ICmpInst(*Context, pred, X, Zero);
           }
           
           // ((X & ~7) == 0) --> X < 8
           }
           
           // ((X & ~7) == 0) --> X < 8
@@ -7125,7 +7139,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
             Constant *NegX = Context->getConstantExprNeg(BOC);
             ICmpInst::Predicate pred = isICMP_NE ? 
               ICmpInst::ICMP_UGE : ICmpInst::ICMP_ULT;
             Constant *NegX = Context->getConstantExprNeg(BOC);
             ICmpInst::Predicate pred = isICMP_NE ? 
               ICmpInst::ICMP_UGE : ICmpInst::ICMP_ULT;
-            return new ICmpInst(pred, X, NegX);
+            return new ICmpInst(*Context, pred, X, NegX);
           }
         }
       default: break;
           }
         }
       default: break;
@@ -7169,7 +7183,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
     }
 
     if (RHSOp)
     }
 
     if (RHSOp)
-      return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSOp);
+      return new ICmpInst(*Context, ICI.getPredicate(), LHSCIOp, RHSOp);
   }
   
   // The code below only handles extension cast instructions, so far.
   }
   
   // The code below only handles extension cast instructions, so far.
@@ -7194,15 +7208,15 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
 
     // Deal with equality cases early.
     if (ICI.isEquality())
 
     // Deal with equality cases early.
     if (ICI.isEquality())
-      return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSCIOp);
+      return new ICmpInst(*Context, ICI.getPredicate(), LHSCIOp, RHSCIOp);
 
     // A signed comparison of sign extended values simplifies into a
     // signed comparison.
     if (isSignedCmp && isSignedExt)
 
     // A signed comparison of sign extended values simplifies into a
     // signed comparison.
     if (isSignedCmp && isSignedExt)
-      return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSCIOp);
+      return new ICmpInst(*Context, ICI.getPredicate(), LHSCIOp, RHSCIOp);
 
     // The other three cases all fold into an unsigned comparison.
 
     // The other three cases all fold into an unsigned comparison.
-    return new ICmpInst(ICI.getUnsignedPredicate(), LHSCIOp, RHSCIOp);
+    return new ICmpInst(*Context, ICI.getUnsignedPredicate(), LHSCIOp, RHSCIOp);
   }
 
   // If we aren't dealing with a constant on the RHS, exit early
   }
 
   // If we aren't dealing with a constant on the RHS, exit early
@@ -7229,7 +7243,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
     // However, we allow this when the compare is EQ/NE, because they are
     // signless.
     if (isSignedExt == isSignedCmp || ICI.isEquality())
     // However, we allow this when the compare is EQ/NE, because they are
     // signless.
     if (isSignedExt == isSignedCmp || ICI.isEquality())
-      return new ICmpInst(ICI.getPredicate(), LHSCIOp, Res1);
+      return new ICmpInst(*Context, ICI.getPredicate(), LHSCIOp, Res1);
     return 0;
   }
 
     return 0;
   }
 
@@ -7258,8 +7272,8 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
       // We're performing an unsigned comp with a sign extended value.
       // This is true if the input is >= 0. [aka >s -1]
       Constant *NegOne = Context->getConstantIntAllOnesValue(SrcTy);
       // We're performing an unsigned comp with a sign extended value.
       // This is true if the input is >= 0. [aka >s -1]
       Constant *NegOne = Context->getConstantIntAllOnesValue(SrcTy);
-      Result = InsertNewInstBefore(new ICmpInst(ICmpInst::ICMP_SGT, LHSCIOp,
-                                   NegOne, ICI.getName()), ICI);
+      Result = InsertNewInstBefore(new ICmpInst(*Context, ICmpInst::ICMP_SGT, 
+                                   LHSCIOp, NegOne, ICI.getName()), ICI);
     } else {
       // Unsigned extend & unsigned compare -> always true.
       Result = Context->getConstantIntTrue();
     } else {
       // Unsigned extend & unsigned compare -> always true.
       Result = Context->getConstantIntTrue();
@@ -8455,7 +8469,7 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
     Constant *One = Context->getConstantInt(Src->getType(), 1);
     Src = InsertNewInstBefore(BinaryOperator::CreateAnd(Src, One, "tmp"), CI);
     Value *Zero = Context->getNullValue(Src->getType());
     Constant *One = Context->getConstantInt(Src->getType(), 1);
     Src = InsertNewInstBefore(BinaryOperator::CreateAnd(Src, One, "tmp"), CI);
     Value *Zero = Context->getNullValue(Src->getType());
-    return new ICmpInst(ICmpInst::ICMP_NE, Src, Zero);
+    return new ICmpInst(*Context, ICmpInst::ICMP_NE, Src, Zero);
   }
 
   // Optimize trunc(lshr(), c) to pull the shift through the truncate.
   }
 
   // Optimize trunc(lshr(), c) to pull the shift through the truncate.
@@ -10591,8 +10605,8 @@ Instruction *InstCombiner::FoldPHIArgBinOpIntoPHI(PHINode &PN) {
   if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(FirstInst))
     return BinaryOperator::Create(BinOp->getOpcode(), LHSVal, RHSVal);
   CmpInst *CIOp = cast<CmpInst>(FirstInst);
   if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(FirstInst))
     return BinaryOperator::Create(BinOp->getOpcode(), LHSVal, RHSVal);
   CmpInst *CIOp = cast<CmpInst>(FirstInst);
-  return CmpInst::Create(CIOp->getOpcode(), CIOp->getPredicate(), LHSVal,
-                         RHSVal);
+  return CmpInst::Create(*Context, CIOp->getOpcode(), CIOp->getPredicate(), 
+                         LHSVal, RHSVal);
 }
 
 Instruction *InstCombiner::FoldPHIArgGEPIntoPHI(PHINode &PN) {
 }
 
 Instruction *InstCombiner::FoldPHIArgGEPIntoPHI(PHINode &PN) {
@@ -10838,7 +10852,7 @@ Instruction *InstCombiner::FoldPHIArgOpIntoPHI(PHINode &PN) {
   if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(FirstInst))
     return BinaryOperator::Create(BinOp->getOpcode(), PhiVal, ConstantOp);
   if (CmpInst *CIOp = dyn_cast<CmpInst>(FirstInst))
   if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(FirstInst))
     return BinaryOperator::Create(BinOp->getOpcode(), PhiVal, ConstantOp);
   if (CmpInst *CIOp = dyn_cast<CmpInst>(FirstInst))
-    return CmpInst::Create(CIOp->getOpcode(), CIOp->getPredicate(), 
+    return CmpInst::Create(*Context, CIOp->getOpcode(), CIOp->getPredicate(), 
                            PhiVal, ConstantOp);
   assert(isa<LoadInst>(FirstInst) && "Unknown operation");
   
                            PhiVal, ConstantOp);
   assert(isa<LoadInst>(FirstInst) && "Unknown operation");
   
@@ -12104,7 +12118,7 @@ Instruction *InstCombiner::visitBranchInst(BranchInst &BI) {
          FPred == FCmpInst::FCMP_OGE) && BI.getCondition()->hasOneUse()) {
       FCmpInst *I = cast<FCmpInst>(BI.getCondition());
       FCmpInst::Predicate NewPred = FCmpInst::getInversePredicate(FPred);
          FPred == FCmpInst::FCMP_OGE) && BI.getCondition()->hasOneUse()) {
       FCmpInst *I = cast<FCmpInst>(BI.getCondition());
       FCmpInst::Predicate NewPred = FCmpInst::getInversePredicate(FPred);
-      Instruction *NewSCC = new FCmpInst(NewPred, X, Y, "", I);
+      Instruction *NewSCC = new FCmpInst(I, NewPred, X, Y, "");
       NewSCC->takeName(I);
       // Swap Destinations and condition...
       BI.setCondition(NewSCC);
       NewSCC->takeName(I);
       // Swap Destinations and condition...
       BI.setCondition(NewSCC);
@@ -12125,7 +12139,7 @@ Instruction *InstCombiner::visitBranchInst(BranchInst &BI) {
          IPred == ICmpInst::ICMP_SGE) && BI.getCondition()->hasOneUse()) {
       ICmpInst *I = cast<ICmpInst>(BI.getCondition());
       ICmpInst::Predicate NewPred = ICmpInst::getInversePredicate(IPred);
          IPred == ICmpInst::ICMP_SGE) && BI.getCondition()->hasOneUse()) {
       ICmpInst *I = cast<ICmpInst>(BI.getCondition());
       ICmpInst::Predicate NewPred = ICmpInst::getInversePredicate(IPred);
-      Instruction *NewSCC = new ICmpInst(NewPred, X, Y, "", I);
+      Instruction *NewSCC = new ICmpInst(I, NewPred, X, Y, "");
       NewSCC->takeName(I);
       // Swap Destinations and condition...
       BI.setCondition(NewSCC);
       NewSCC->takeName(I);
       // Swap Destinations and condition...
       BI.setCondition(NewSCC);
index 7b9615b109cdbfc3513424ad3a8147638b339fcb..f3536c10c5756026dbd80355f011602882aae029 100644 (file)
@@ -931,7 +931,7 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB,
   // Clone the non-phi instructions of BB into NewBB, keeping track of the
   // mapping and using it to remap operands in the cloned instructions.
   for (; !isa<TerminatorInst>(BI); ++BI) {
   // Clone the non-phi instructions of BB into NewBB, keeping track of the
   // mapping and using it to remap operands in the cloned instructions.
   for (; !isa<TerminatorInst>(BI); ++BI) {
-    Instruction *New = BI->clone();
+    Instruction *New = BI->clone(*Context);
     New->setName(BI->getNameStart());
     NewBB->getInstList().push_back(New);
     ValueMapping[BI] = New;
     New->setName(BI->getNameStart());
     NewBB->getInstList().push_back(New);
     ValueMapping[BI] = New;
index 2e5864b3a1be5be729b35f2b7fce469fdee60d8c..52dd06affe5fcf2ed46340d18f587fbfc42931f7 100644 (file)
@@ -570,7 +570,7 @@ void LICM::sink(Instruction &I) {
             ExitBlock->getInstList().insert(InsertPt, &I);
             New = &I;
           } else {
             ExitBlock->getInstList().insert(InsertPt, &I);
             New = &I;
           } else {
-            New = I.clone();
+            New = I.clone(*Context);
             CurAST->copyValue(&I, New);
             if (!I.getName().empty())
               New->setName(I.getName()+".le");
             CurAST->copyValue(&I, New);
             if (!I.getName().empty())
               New->setName(I.getName()+".le");
index e58eeee1bdccf8b6c2c548f2639f14c2593358d1..4c6689d6b5d814d9737638287027a8e20f9f7c32 100644 (file)
@@ -309,16 +309,18 @@ static Value *getMinusOne(Value *V, bool Sign, Instruction *InsertPt,
 // Return min(V1, V1)
 static Value *getMin(Value *V1, Value *V2, bool Sign, Instruction *InsertPt) {
  
 // Return min(V1, V1)
 static Value *getMin(Value *V1, Value *V2, bool Sign, Instruction *InsertPt) {
  
-  Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
-                          V1, V2, "lsp", InsertPt);
+  Value *C = new ICmpInst(InsertPt,
+                          Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
+                          V1, V2, "lsp");
   return SelectInst::Create(C, V1, V2, "lsp", InsertPt);
 }
 
 // Return max(V1, V2)
 static Value *getMax(Value *V1, Value *V2, bool Sign, Instruction *InsertPt) {
  
   return SelectInst::Create(C, V1, V2, "lsp", InsertPt);
 }
 
 // Return max(V1, V2)
 static Value *getMax(Value *V1, Value *V2, bool Sign, Instruction *InsertPt) {
  
-  Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
-                          V1, V2, "lsp", InsertPt);
+  Value *C = new ICmpInst(InsertPt, 
+                          Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
+                          V1, V2, "lsp");
   return SelectInst::Create(C, V2, V1, "lsp", InsertPt);
 }
 
   return SelectInst::Create(C, V2, V1, "lsp", InsertPt);
 }
 
@@ -427,15 +429,15 @@ bool LoopIndexSplit::processOneIterationLoop() {
   //      c1 = icmp uge i32 SplitValue, StartValue
   //      c2 = icmp ult i32 SplitValue, ExitValue
   //      and i32 c1, c2 
   //      c1 = icmp uge i32 SplitValue, StartValue
   //      c2 = icmp ult i32 SplitValue, ExitValue
   //      and i32 c1, c2 
-  Instruction *C1 = new ICmpInst(ExitCondition->isSignedPredicate() ? 
+  Instruction *C1 = new ICmpInst(BR, ExitCondition->isSignedPredicate() ? 
                                  ICmpInst::ICMP_SGE : ICmpInst::ICMP_UGE,
                                  ICmpInst::ICMP_SGE : ICmpInst::ICMP_UGE,
-                                 SplitValue, StartValue, "lisplit", BR);
+                                 SplitValue, StartValue, "lisplit");
 
   CmpInst::Predicate C2P  = ExitCondition->getPredicate();
   BranchInst *LatchBR = cast<BranchInst>(Latch->getTerminator());
   if (LatchBR->getOperand(0) != Header)
     C2P = CmpInst::getInversePredicate(C2P);
 
   CmpInst::Predicate C2P  = ExitCondition->getPredicate();
   BranchInst *LatchBR = cast<BranchInst>(Latch->getTerminator());
   if (LatchBR->getOperand(0) != Header)
     C2P = CmpInst::getInversePredicate(C2P);
-  Instruction *C2 = new ICmpInst(C2P, SplitValue, ExitValue, "lisplit", BR);
+  Instruction *C2 = new ICmpInst(BR, C2P, SplitValue, ExitValue, "lisplit");
   Instruction *NSplitCond = BinaryOperator::CreateAnd(C1, C2, "lisplit", BR);
 
   SplitCondition->replaceAllUsesWith(NSplitCond);
   Instruction *NSplitCond = BinaryOperator::CreateAnd(C1, C2, "lisplit", BR);
 
   SplitCondition->replaceAllUsesWith(NSplitCond);
index 1f7892ad10159ce055a3067337a3f5bc88596dfe..6d8036518292ea0a07d2f9bc6deb50c443bdf288 100644 (file)
@@ -238,7 +238,7 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) {
     // This is not a PHI instruction. Insert its clone into original pre-header.
     // If this instruction is using a value from same basic block then
     // update it to use value from cloned instruction.
     // This is not a PHI instruction. Insert its clone into original pre-header.
     // If this instruction is using a value from same basic block then
     // update it to use value from cloned instruction.
-    Instruction *C = In->clone();
+    Instruction *C = In->clone(*Context);
     C->setName(In->getName());
     OrigPreHeader->getInstList().push_back(C);
 
     C->setName(In->getName());
     OrigPreHeader->getInstList().push_back(C);
 
index 76985da0673c3d8bd0ac79f5bbc04b58dcdafdf7..454cc93d31bf2bf0c81e5a5eb21927eacfa58888 100644 (file)
@@ -2019,9 +2019,8 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
     // Create a new compare instruction using new stride / iv.
     ICmpInst *OldCond = Cond;
     // Insert new compare instruction.
     // Create a new compare instruction using new stride / iv.
     ICmpInst *OldCond = Cond;
     // Insert new compare instruction.
-    Cond = new ICmpInst(Predicate, NewCmpLHS, NewCmpRHS,
-                        L->getHeader()->getName() + ".termcond",
-                        OldCond);
+    Cond = new ICmpInst(OldCond, Predicate, NewCmpLHS, NewCmpRHS,
+                        L->getHeader()->getName() + ".termcond");
 
     // Remove the old compare instruction. The old indvar is probably dead too.
     DeadInsts.push_back(CondUse->getOperandValToReplace());
 
     // Remove the old compare instruction. The old indvar is probably dead too.
     DeadInsts.push_back(CondUse->getOperandValToReplace());
@@ -2152,7 +2151,7 @@ ICmpInst *LoopStrengthReduce::OptimizeMax(Loop *L, ICmpInst *Cond,
   // Ok, everything looks ok to change the condition into an SLT or SGE and
   // delete the max calculation.
   ICmpInst *NewCond =
   // Ok, everything looks ok to change the condition into an SLT or SGE and
   // delete the max calculation.
   ICmpInst *NewCond =
-    new ICmpInst(Pred, Cond->getOperand(0), NewRHS, "scmp", Cond);
+    new ICmpInst(Cond, Pred, Cond->getOperand(0), NewRHS, "scmp");
 
   // Delete the max calculation instructions.
   Cond->replaceAllUsesWith(NewCond);
 
   // Delete the max calculation instructions.
   Cond->replaceAllUsesWith(NewCond);
@@ -2383,7 +2382,7 @@ void LoopStrengthReduce::OptimizeLoopTermCond(Loop *L) {
       Cond->moveBefore(TermBr);
     } else {
       // Otherwise, clone the terminating condition and insert into the loopend.
       Cond->moveBefore(TermBr);
     } else {
       // Otherwise, clone the terminating condition and insert into the loopend.
-      Cond = cast<ICmpInst>(Cond->clone());
+      Cond = cast<ICmpInst>(Cond->clone(*Context));
       Cond->setName(L->getHeader()->getName() + ".termcond");
       LatchBlock->getInstList().insert(TermBr, Cond);
       
       Cond->setName(L->getHeader()->getName() + ".termcond");
       LatchBlock->getInstList().insert(TermBr, Cond);
       
index b8e44799ba9ffed511adb966c87c7f064a4c6cbd..0a3659c71de0b49f49e8fb5e98f940f50e4d0ae0 100644 (file)
@@ -507,7 +507,7 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val,
   // code is the true version and the new code is the false version.
   Value *BranchVal = LIC;
   if (!isa<ConstantInt>(Val) || Val->getType() != Type::Int1Ty)
   // code is the true version and the new code is the false version.
   Value *BranchVal = LIC;
   if (!isa<ConstantInt>(Val) || Val->getType() != Type::Int1Ty)
-    BranchVal = new ICmpInst(ICmpInst::ICMP_EQ, LIC, Val, "tmp", InsertPt);
+    BranchVal = new ICmpInst(InsertPt, ICmpInst::ICMP_EQ, LIC, Val, "tmp");
   else if (Val != Context->getConstantIntTrue())
     // We want to enter the new loop when the condition is true.
     std::swap(TrueDest, FalseDest);
   else if (Val != Context->getConstantIntTrue())
     // We want to enter the new loop when the condition is true.
     std::swap(TrueDest, FalseDest);
index a3cb751921d857da1bfc4118edeb9e9c2d80a342..24707bd4d86722a6296c7a529359967bc1f7b3bf 100644 (file)
@@ -2693,8 +2693,8 @@ namespace {
         VRPSolver VRP(VN, IG, UB, VR, PS->DTDFS, PS->modified, &IC);
         if (VRP.isRelatedBy(IC.getOperand(0), NextVal,
                             ICmpInst::getInversePredicate(Pred))) {
         VRPSolver VRP(VN, IG, UB, VR, PS->DTDFS, PS->modified, &IC);
         if (VRP.isRelatedBy(IC.getOperand(0), NextVal,
                             ICmpInst::getInversePredicate(Pred))) {
-          ICmpInst *NewIC = new ICmpInst(ICmpInst::ICMP_EQ, IC.getOperand(0),
-                                         NextVal, "", &IC);
+          ICmpInst *NewIC = new ICmpInst(&IC, ICmpInst::ICMP_EQ, 
+                                         IC.getOperand(0), NextVal, "");
           NewIC->takeName(&IC);
           IC.replaceAllUsesWith(NewIC);
 
           NewIC->takeName(&IC);
           IC.replaceAllUsesWith(NewIC);
 
index cdb06285e0ea35e201866f49606926b4a4e8d9ce..61fc9eed01b3c7b805b7a6c413b1730a10de1f39 100644 (file)
@@ -1193,9 +1193,9 @@ void SROA::CleanupGEP(GetElementPtrInst *GEPI) {
   assert(NumElements == 2 && "Unhandled case!");
   // All users of the GEP must be loads.  At each use of the GEP, insert
   // two loads of the appropriate indexed GEP and select between them.
   assert(NumElements == 2 && "Unhandled case!");
   // All users of the GEP must be loads.  At each use of the GEP, insert
   // two loads of the appropriate indexed GEP and select between them.
-  Value *IsOne = new ICmpInst(ICmpInst::ICMP_NE, I.getOperand(), 
+  Value *IsOne = new ICmpInst(GEPI, ICmpInst::ICMP_NE, I.getOperand(), 
                               Context->getNullValue(I.getOperand()->getType()),
                               Context->getNullValue(I.getOperand()->getType()),
-                              "isone", GEPI);
+                              "isone");
   // Insert the new GEP instructions, which are properly indexed.
   SmallVector<Value*, 8> Indices(GEPI->op_begin()+1, GEPI->op_end());
   Indices[1] = Context->getNullValue(Type::Int32Ty);
   // Insert the new GEP instructions, which are properly indexed.
   SmallVector<Value*, 8> Indices(GEPI->op_begin()+1, GEPI->op_end());
   Indices[1] = Context->getNullValue(Type::Int32Ty);
index 06815d29b2d8bee6d516d4c2e213e59deace8252..684b0963456ea5f2238a33be371f203f55e7db06 100644 (file)
@@ -304,7 +304,7 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
   // keeping track of the mapping...
   //
   for (; BI != DestBlock->end(); ++BI) {
   // keeping track of the mapping...
   //
   for (; BI != DestBlock->end(); ++BI) {
-    Instruction *New = BI->clone();
+    Instruction *New = BI->clone(*Context);
     New->setName(BI->getName());
     SourceBlock->getInstList().push_back(New);
     ValueMapping[BI] = New;
     New->setName(BI->getName());
     SourceBlock->getInstList().push_back(New);
     ValueMapping[BI] = New;
index 32eecb37aa362da3d9ddcad004a051636afac3af..f52546ccc4104e908f689c0d0ba7b18735a35d5d 100644 (file)
@@ -618,7 +618,7 @@ void llvm::CopyPrecedingStopPoint(Instruction *I,
   if (I != I->getParent()->begin()) {
     BasicBlock::iterator BBI = I;  --BBI;
     if (DbgStopPointInst *DSPI = dyn_cast<DbgStopPointInst>(BBI)) {
   if (I != I->getParent()->begin()) {
     BasicBlock::iterator BBI = I;  --BBI;
     if (DbgStopPointInst *DSPI = dyn_cast<DbgStopPointInst>(BBI)) {
-      CallInst *newDSPI = DSPI->clone();
+      CallInst *newDSPI = DSPI->clone(*I->getParent()->getContext());
       newDSPI->insertBefore(InsertPos);
     }
   }
       newDSPI->insertBefore(InsertPos);
     }
   }
index a820c9d3f56faac1ad0956fbaee4004f104457f9..f05c5dc8a7d72839242aa831e389752675ecb25c 100644 (file)
@@ -43,7 +43,7 @@ BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB,
   // Loop over all instructions, and copy them over.
   for (BasicBlock::const_iterator II = BB->begin(), IE = BB->end();
        II != IE; ++II) {
   // Loop over all instructions, and copy them over.
   for (BasicBlock::const_iterator II = BB->begin(), IE = BB->end();
        II != IE; ++II) {
-    Instruction *NewInst = II->clone();
+    Instruction *NewInst = II->clone(*BB->getContext());
     if (II->hasName())
       NewInst->setName(II->getName()+NameSuffix);
     NewBB->getInstList().push_back(NewInst);
     if (II->hasName())
       NewInst->setName(II->getName()+NameSuffix);
     NewBB->getInstList().push_back(NewInst);
@@ -249,7 +249,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
         continue;
     }
       
         continue;
     }
       
-    Instruction *NewInst = II->clone();
+    Instruction *NewInst = II->clone(*BB->getContext());
     if (II->hasName())
       NewInst->setName(II->getName()+NameSuffix);
     NewBB->getInstList().push_back(NewInst);
     if (II->hasName())
       NewInst->setName(II->getName()+NameSuffix);
     NewBB->getInstList().push_back(NewInst);
@@ -297,7 +297,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
   }
   
   if (!TerminatorDone) {
   }
   
   if (!TerminatorDone) {
-    Instruction *NewInst = OldTI->clone();
+    Instruction *NewInst = OldTI->clone(*BB->getContext());
     if (OldTI->hasName())
       NewInst->setName(OldTI->getName()+NameSuffix);
     NewBB->getInstList().push_back(NewInst);
     if (OldTI->hasName())
       NewInst->setName(OldTI->getName()+NameSuffix);
     NewBB->getInstList().push_back(NewInst);
index 06008b63490dc2066981e4fcfd567be128ea93a5..0e50cd11def619e3715d9e6747d839cec8d7c2a7 100644 (file)
@@ -361,7 +361,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
              BE = TheCall->getParent()->end(); BI != BE; ++BI) {
         if (DbgStopPointInst *DSPI = dyn_cast<DbgStopPointInst>(BI)) {
           if (DbgRegionEndInst *NewDREI = 
              BE = TheCall->getParent()->end(); BI != BE; ++BI) {
         if (DbgStopPointInst *DSPI = dyn_cast<DbgStopPointInst>(BI)) {
           if (DbgRegionEndInst *NewDREI = 
-              dyn_cast<DbgRegionEndInst>(DREI->clone()))
+              dyn_cast<DbgRegionEndInst>(DREI->clone(*Context)))
             NewDREI->insertAfter(DSPI);
           break;
         }
             NewDREI->insertAfter(DSPI);
           break;
         }
index 583b26ad8721456c02e76705ce657972607178f2..0bb9614557b5fbeac88db5dc7fe485146bf54677 100644 (file)
@@ -184,8 +184,8 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) {
     } else if (SI->getNumSuccessors() == 2) {
       // Otherwise, we can fold this switch into a conditional branch
       // instruction if it has only one non-default destination.
     } else if (SI->getNumSuccessors() == 2) {
       // Otherwise, we can fold this switch into a conditional branch
       // instruction if it has only one non-default destination.
-      Value *Cond = new ICmpInst(ICmpInst::ICMP_EQ, SI->getCondition(),
-                                 SI->getSuccessorValue(1), "cond", SI);
+      Value *Cond = new ICmpInst(SI, ICmpInst::ICMP_EQ, SI->getCondition(),
+                                 SI->getSuccessorValue(1), "cond");
       // Insert the new branch...
       BranchInst::Create(SI->getSuccessor(1), SI->getSuccessor(0), Cond, SI);
 
       // Insert the new branch...
       BranchInst::Create(SI->getSuccessor(1), SI->getSuccessor(0), Cond, SI);
 
index 8ef060a1f4ad7d32fd2a759c3933e2c004a2f575..b8e0fd88f0888443566aea7d6db18709f19e7245 100644 (file)
@@ -523,9 +523,10 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
                                     EntryBB->getTerminator());
 
     // Compare the return value to zero.
                                     EntryBB->getTerminator());
 
     // Compare the return value to zero.
-    Value *IsNormal = new ICmpInst(ICmpInst::ICMP_EQ, SJRet,
+    Value *IsNormal = new ICmpInst(EntryBB->getTerminator(),
+                                   ICmpInst::ICMP_EQ, SJRet,
                                    Constant::getNullValue(SJRet->getType()),
                                    Constant::getNullValue(SJRet->getType()),
-      "notunwind", EntryBB->getTerminator());
+                                   "notunwind");
     // Nuke the uncond branch.
     EntryBB->getTerminator()->eraseFromParent();
 
     // Nuke the uncond branch.
     EntryBB->getTerminator()->eraseFromParent();
 
@@ -557,9 +558,9 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
   }
 
   // Load the JBList, if it's null, then there was no catch!
   }
 
   // Load the JBList, if it's null, then there was no catch!
-  Value *NotNull = new ICmpInst(ICmpInst::ICMP_NE, BufPtr,
+  Value *NotNull = new ICmpInst(*UnwindHandler, ICmpInst::ICMP_NE, BufPtr,
                                 Constant::getNullValue(BufPtr->getType()),
                                 Constant::getNullValue(BufPtr->getType()),
-    "notnull", UnwindHandler);
+                                "notnull");
   BranchInst::Create(UnwindBlock, TermBlock, NotNull, UnwindHandler);
 
   // Create the block to do the longjmp.
   BranchInst::Create(UnwindBlock, TermBlock, NotNull, UnwindHandler);
 
   // Create the block to do the longjmp.
index ed6eca6c15184532ed0b8c6bf6f156fe21fadfa5..2a7124c9aa0db623bca5d2946c9648745a953fe1 100644 (file)
@@ -162,7 +162,8 @@ BasicBlock* LowerSwitch::switchConvert(CaseItr Begin, CaseItr End,
   Function::iterator FI = OrigBlock;
   F->getBasicBlockList().insert(++FI, NewNode);
 
   Function::iterator FI = OrigBlock;
   F->getBasicBlockList().insert(++FI, NewNode);
 
-  ICmpInst* Comp = new ICmpInst(ICmpInst::ICMP_SLT, Val, Pivot.Low, "Pivot");
+  ICmpInst* Comp = new ICmpInst(*Default->getContext(), ICmpInst::ICMP_SLT,
+                                Val, Pivot.Low, "Pivot");
   NewNode->getInstList().push_back(Comp);
   BranchInst::Create(LBranch, RBranch, Comp, NewNode);
   return NewNode;
   NewNode->getInstList().push_back(Comp);
   BranchInst::Create(LBranch, RBranch, Comp, NewNode);
   return NewNode;
@@ -187,18 +188,18 @@ BasicBlock* LowerSwitch::newLeafBlock(CaseRange& Leaf, Value* Val,
   ICmpInst* Comp = NULL;
   if (Leaf.Low == Leaf.High) {
     // Make the seteq instruction...
   ICmpInst* Comp = NULL;
   if (Leaf.Low == Leaf.High) {
     // Make the seteq instruction...
-    Comp = new ICmpInst(ICmpInst::ICMP_EQ, Val, Leaf.Low,
-                        "SwitchLeaf", NewLeaf);
+    Comp = new ICmpInst(*NewLeaf, ICmpInst::ICMP_EQ, Val,
+                        Leaf.Low, "SwitchLeaf");
   } else {
     // Make range comparison
     if (cast<ConstantInt>(Leaf.Low)->isMinValue(true /*isSigned*/)) {
       // Val >= Min && Val <= Hi --> Val <= Hi
   } else {
     // Make range comparison
     if (cast<ConstantInt>(Leaf.Low)->isMinValue(true /*isSigned*/)) {
       // Val >= Min && Val <= Hi --> Val <= Hi
-      Comp = new ICmpInst(ICmpInst::ICMP_SLE, Val, Leaf.High,
-                          "SwitchLeaf", NewLeaf);
+      Comp = new ICmpInst(*NewLeaf, ICmpInst::ICMP_SLE, Val, Leaf.High,
+                          "SwitchLeaf");
     } else if (cast<ConstantInt>(Leaf.Low)->isZero()) {
       // Val >= 0 && Val <= Hi --> Val <=u Hi
     } else if (cast<ConstantInt>(Leaf.Low)->isZero()) {
       // Val >= 0 && Val <= Hi --> Val <=u Hi
-      Comp = new ICmpInst(ICmpInst::ICMP_ULE, Val, Leaf.High,
-                          "SwitchLeaf", NewLeaf);      
+      Comp = new ICmpInst(*NewLeaf, ICmpInst::ICMP_ULE, Val, Leaf.High,
+                          "SwitchLeaf");      
     } else {
       // Emit V-Lo <=u Hi-Lo
       Constant* NegLo = Context->getConstantExprNeg(Leaf.Low);
     } else {
       // Emit V-Lo <=u Hi-Lo
       Constant* NegLo = Context->getConstantExprNeg(Leaf.Low);
@@ -206,8 +207,8 @@ BasicBlock* LowerSwitch::newLeafBlock(CaseRange& Leaf, Value* Val,
                                                    Val->getName()+".off",
                                                    NewLeaf);
       Constant *UpperBound = Context->getConstantExprAdd(NegLo, Leaf.High);
                                                    Val->getName()+".off",
                                                    NewLeaf);
       Constant *UpperBound = Context->getConstantExprAdd(NegLo, Leaf.High);
-      Comp = new ICmpInst(ICmpInst::ICMP_ULE, Add, UpperBound,
-                          "SwitchLeaf", NewLeaf);
+      Comp = new ICmpInst(*NewLeaf, ICmpInst::ICMP_ULE, Add, UpperBound,
+                          "SwitchLeaf");
     }
   }
 
     }
   }
 
index 9dccfe86f7f71f658f15b9bd0e9e9c9853c027a3..a898d2df2bb6ff7230cc182dcca5e02f39952034 100644 (file)
@@ -938,7 +938,7 @@ HoistTerminator:
     return true;
 
   // Okay, it is safe to hoist the terminator.
     return true;
 
   // Okay, it is safe to hoist the terminator.
-  Instruction *NT = I1->clone();
+  Instruction *NT = I1->clone(*BB1->getContext());
   BIParent->getInstList().insert(BI, NT);
   if (NT->getType() != Type::VoidTy) {
     I1->replaceAllUsesWith(NT);
   BIParent->getInstList().insert(BI, NT);
   if (NT->getType() != Type::VoidTy) {
     I1->replaceAllUsesWith(NT);
@@ -1231,7 +1231,7 @@ static bool FoldCondBranchOnPHI(BranchInst *BI) {
           TranslateMap[PN] = PN->getIncomingValueForBlock(PredBB);
         } else {
           // Clone the instruction.
           TranslateMap[PN] = PN->getIncomingValueForBlock(PredBB);
         } else {
           // Clone the instruction.
-          Instruction *N = BBI->clone();
+          Instruction *N = BBI->clone(*Context);
           if (BBI->hasName()) N->setName(BBI->getName()+".c");
           
           // Update operands due to translation.
           if (BBI->hasName()) N->setName(BBI->getName()+".c");
           
           // Update operands due to translation.
@@ -1581,7 +1581,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI) {
     
     // Clone Cond into the predecessor basic block, and or/and the
     // two conditions together.
     
     // Clone Cond into the predecessor basic block, and or/and the
     // two conditions together.
-    Instruction *New = Cond->clone();
+    Instruction *New = Cond->clone(*BB->getContext());
     PredBlock->getInstList().insert(PBI, New);
     New->takeName(Cond);
     Cond->setName(New->getName()+".old");
     PredBlock->getInstList().insert(PBI, New);
     New->takeName(Cond);
     Cond->setName(New->getName()+".old");
@@ -1841,7 +1841,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
                << "INTO UNCOND BRANCH PRED: " << *Pred;
           Instruction *UncondBranch = Pred->getTerminator();
           // Clone the return and add it to the end of the predecessor.
                << "INTO UNCOND BRANCH PRED: " << *Pred;
           Instruction *UncondBranch = Pred->getTerminator();
           // Clone the return and add it to the end of the predecessor.
-          Instruction *NewRet = RI->clone();
+          Instruction *NewRet = RI->clone(*BB->getContext());
           Pred->getInstList().push_back(NewRet);
 
           BasicBlock::iterator BBI = RI;
           Pred->getInstList().push_back(NewRet);
 
           BasicBlock::iterator BBI = RI;
index bbb22c5a64bb3d2d40d73475f463069bce4d1be2..b56168a969bbb25740cd911460defb038d4803c4 100644 (file)
@@ -2576,25 +2576,35 @@ CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
 }
 
 CmpInst *
 }
 
 CmpInst *
-CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, 
+CmpInst::Create(LLVMContext &Context, OtherOps Op, unsigned short predicate,
+                Value *S1, Value *S2, 
                 const std::string &Name, Instruction *InsertBefore) {
   if (Op == Instruction::ICmp) {
                 const std::string &Name, Instruction *InsertBefore) {
   if (Op == Instruction::ICmp) {
-    return new ICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, 
-                        InsertBefore);
+    if (InsertBefore)
+      return new ICmpInst(InsertBefore, CmpInst::Predicate(predicate),
+                          S1, S2, Name);
+    else
+      return new ICmpInst(Context, CmpInst::Predicate(predicate),
+                          S1, S2, Name);
   }
   }
-  return new FCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, 
-                      InsertBefore);
+  
+  if (InsertBefore)
+    return new FCmpInst(InsertBefore, CmpInst::Predicate(predicate),
+                        S1, S2, Name);
+  else
+    return new FCmpInst(Context, CmpInst::Predicate(predicate),
+                        S1, S2, Name);
 }
 
 CmpInst *
 CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, 
                 const std::string &Name, BasicBlock *InsertAtEnd) {
   if (Op == Instruction::ICmp) {
 }
 
 CmpInst *
 CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, 
                 const std::string &Name, BasicBlock *InsertAtEnd) {
   if (Op == Instruction::ICmp) {
-    return new ICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, 
-                        InsertAtEnd);
+    return new ICmpInst(*InsertAtEnd, CmpInst::Predicate(predicate),
+                        S1, S2, Name);
   }
   }
-  return new FCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, 
-                      InsertAtEnd);
+  return new FCmpInst(*InsertAtEnd, CmpInst::Predicate(predicate),
+                      S1, S2, Name);
 }
 
 void CmpInst::swapOperands() {
 }
 
 void CmpInst::swapOperands() {
@@ -2919,74 +2929,145 @@ void SwitchInst::setSuccessorV(unsigned idx, BasicBlock *B) {
 // Define these methods here so vtables don't get emitted into every translation
 // unit that uses these classes.
 
 // Define these methods here so vtables don't get emitted into every translation
 // unit that uses these classes.
 
-GetElementPtrInst *GetElementPtrInst::clone() const {
+GetElementPtrInst *GetElementPtrInst::clone(LLVMContext&) const {
   return new(getNumOperands()) GetElementPtrInst(*this);
 }
 
   return new(getNumOperands()) GetElementPtrInst(*this);
 }
 
-BinaryOperator *BinaryOperator::clone() const {
+BinaryOperator *BinaryOperator::clone(LLVMContext&) const {
   return Create(getOpcode(), Op<0>(), Op<1>());
 }
 
   return Create(getOpcode(), Op<0>(), Op<1>());
 }
 
-FCmpInst* FCmpInst::clone() const {
-  return new FCmpInst(getPredicate(), Op<0>(), Op<1>());
+FCmpInst* FCmpInst::clone(LLVMContext &Context) const {
+  return new FCmpInst(Context, getPredicate(), Op<0>(), Op<1>());
 }
 }
-ICmpInst* ICmpInst::clone() const {
-  return new ICmpInst(getPredicate(), Op<0>(), Op<1>());
+ICmpInst* ICmpInst::clone(LLVMContext &Context) const {
+  return new ICmpInst(Context, getPredicate(), Op<0>(), Op<1>());
 }
 
 }
 
-ExtractValueInst *ExtractValueInst::clone() const {
+ExtractValueInst *ExtractValueInst::clone(LLVMContext&) const {
   return new ExtractValueInst(*this);
 }
   return new ExtractValueInst(*this);
 }
-InsertValueInst *InsertValueInst::clone() const {
+InsertValueInst *InsertValueInst::clone(LLVMContext&) const {
   return new InsertValueInst(*this);
 }
 
   return new InsertValueInst(*this);
 }
 
+MallocInst *MallocInst::clone(LLVMContext&) const {
+  return new MallocInst(*this);
+}
+
+AllocaInst *AllocaInst::clone(LLVMContext&) const {
+  return new AllocaInst(*this);
+}
+
+FreeInst *FreeInst::clone(LLVMContext&) const {
+  return new FreeInst(getOperand(0));
+}
+
+LoadInst *LoadInst::clone(LLVMContext&) const {
+  return new LoadInst(*this);
+}
+
+StoreInst *StoreInst::clone(LLVMContext&) const {
+  return new StoreInst(*this);
+}
+
+CastInst *TruncInst::clone(LLVMContext&) const {
+  return new TruncInst(*this);
+}
+
+CastInst *ZExtInst::clone(LLVMContext&) const {
+  return new ZExtInst(*this);
+}
+
+CastInst *SExtInst::clone(LLVMContext&) const {
+  return new SExtInst(*this);
+}
+
+CastInst *FPTruncInst::clone(LLVMContext&) const {
+  return new FPTruncInst(*this);
+}
+
+CastInst *FPExtInst::clone(LLVMContext&) const {
+  return new FPExtInst(*this);
+}
+
+CastInst *UIToFPInst::clone(LLVMContext&) const {
+  return new UIToFPInst(*this);
+}
+
+CastInst *SIToFPInst::clone(LLVMContext&) const {
+  return new SIToFPInst(*this);
+}
 
 
-MallocInst *MallocInst::clone()   const { return new MallocInst(*this); }
-AllocaInst *AllocaInst::clone()   const { return new AllocaInst(*this); }
-FreeInst   *FreeInst::clone()     const { return new FreeInst(getOperand(0)); }
-LoadInst   *LoadInst::clone()     const { return new LoadInst(*this); }
-StoreInst  *StoreInst::clone()    const { return new StoreInst(*this); }
-CastInst   *TruncInst::clone()    const { return new TruncInst(*this); }
-CastInst   *ZExtInst::clone()     const { return new ZExtInst(*this); }
-CastInst   *SExtInst::clone()     const { return new SExtInst(*this); }
-CastInst   *FPTruncInst::clone()  const { return new FPTruncInst(*this); }
-CastInst   *FPExtInst::clone()    const { return new FPExtInst(*this); }
-CastInst   *UIToFPInst::clone()   const { return new UIToFPInst(*this); }
-CastInst   *SIToFPInst::clone()   const { return new SIToFPInst(*this); }
-CastInst   *FPToUIInst::clone()   const { return new FPToUIInst(*this); }
-CastInst   *FPToSIInst::clone()   const { return new FPToSIInst(*this); }
-CastInst   *PtrToIntInst::clone() const { return new PtrToIntInst(*this); }
-CastInst   *IntToPtrInst::clone() const { return new IntToPtrInst(*this); }
-CastInst   *BitCastInst::clone()  const { return new BitCastInst(*this); }
-CallInst   *CallInst::clone()     const {
+CastInst *FPToUIInst::clone(LLVMContext&) const {
+  return new FPToUIInst(*this);
+}
+
+CastInst *FPToSIInst::clone(LLVMContext&) const {
+  return new FPToSIInst(*this);
+}
+
+CastInst *PtrToIntInst::clone(LLVMContext&) const {
+  return new PtrToIntInst(*this);
+}
+
+CastInst *IntToPtrInst::clone(LLVMContext&) const {
+  return new IntToPtrInst(*this);
+}
+
+CastInst *BitCastInst::clone(LLVMContext&) const {
+  return new BitCastInst(*this);
+}
+
+CallInst *CallInst::clone(LLVMContext&) const {
   return new(getNumOperands()) CallInst(*this);
 }
   return new(getNumOperands()) CallInst(*this);
 }
-SelectInst *SelectInst::clone()   const {
+
+SelectInst *SelectInst::clone(LLVMContext&)   const {
   return new(getNumOperands()) SelectInst(*this);
 }
   return new(getNumOperands()) SelectInst(*this);
 }
-VAArgInst  *VAArgInst::clone()    const { return new VAArgInst(*this); }
 
 
-ExtractElementInst *ExtractElementInst::clone() const {
+VAArgInst *VAArgInst::clone(LLVMContext&) const {
+  return new VAArgInst(*this);
+}
+
+ExtractElementInst *ExtractElementInst::clone(LLVMContext&) const {
   return new ExtractElementInst(*this);
 }
   return new ExtractElementInst(*this);
 }
-InsertElementInst *InsertElementInst::clone() const {
+
+InsertElementInst *InsertElementInst::clone(LLVMContext&) const {
   return InsertElementInst::Create(*this);
 }
   return InsertElementInst::Create(*this);
 }
-ShuffleVectorInst *ShuffleVectorInst::clone() const {
+
+ShuffleVectorInst *ShuffleVectorInst::clone(LLVMContext&) const {
   return new ShuffleVectorInst(*this);
 }
   return new ShuffleVectorInst(*this);
 }
-PHINode    *PHINode::clone()    const { return new PHINode(*this); }
-ReturnInst *ReturnInst::clone() const {
+
+PHINode *PHINode::clone(LLVMContext&) const {
+  return new PHINode(*this);
+}
+
+ReturnInst *ReturnInst::clone(LLVMContext&) const {
   return new(getNumOperands()) ReturnInst(*this);
 }
   return new(getNumOperands()) ReturnInst(*this);
 }
-BranchInst *BranchInst::clone() const {
+
+BranchInst *BranchInst::clone(LLVMContext&) const {
   unsigned Ops(getNumOperands());
   return new(Ops, Ops == 1) BranchInst(*this);
 }
   unsigned Ops(getNumOperands());
   return new(Ops, Ops == 1) BranchInst(*this);
 }
-SwitchInst *SwitchInst::clone() const { return new SwitchInst(*this); }
-InvokeInst *InvokeInst::clone() const {
+
+SwitchInst *SwitchInst::clone(LLVMContext&) const {
+  return new SwitchInst(*this);
+}
+
+InvokeInst *InvokeInst::clone(LLVMContext&) const {
   return new(getNumOperands()) InvokeInst(*this);
 }
   return new(getNumOperands()) InvokeInst(*this);
 }
-UnwindInst *UnwindInst::clone() const { return new UnwindInst(); }
-UnreachableInst *UnreachableInst::clone() const { return new UnreachableInst();}
+
+UnwindInst *UnwindInst::clone(LLVMContext&) const {
+  return new UnwindInst();
+}
+
+UnreachableInst *UnreachableInst::clone(LLVMContext&) const {
+  return new UnreachableInst();
+}
index 422798d220f9e41c687126d385e444763b1016da..4a9953a4f1e43a5e5120c980e8189a0705fc84a4 100644 (file)
@@ -485,3 +485,10 @@ VectorType* LLVMContext::getVectorTypeExtendedElement(const VectorType* VTy) {
 VectorType* LLVMContext::getVectorTypeTruncatedElement(const VectorType* VTy) {
   return VectorType::getTruncatedElementVectorType(VTy);
 }
 VectorType* LLVMContext::getVectorTypeTruncatedElement(const VectorType* VTy) {
   return VectorType::getTruncatedElementVectorType(VTy);
 }
+
+const Type* LLVMContext::makeCmpResultType(const Type* opnd_type) {
+  if (const VectorType* vt = dyn_cast<const VectorType>(opnd_type)) {
+    return getVectorType(Type::Int1Ty, vt->getNumElements());
+  }
+  return Type::Int1Ty;
+}
index a24ea7778118e3723526e0427c369ec9cf0a7a99..21e141243b37bfe4f80f0ca38c6ca5bb81ee3662 100644 (file)
@@ -738,8 +738,8 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
 
           // Check to see if we already looked up the value.
           Value *CachedVal = new LoadInst(Cache, "fpcache", EntryBB);
 
           // Check to see if we already looked up the value.
           Value *CachedVal = new LoadInst(Cache, "fpcache", EntryBB);
-          Value *IsNull = new ICmpInst(ICmpInst::ICMP_EQ, CachedVal,
-                                       NullPtr, "isNull", EntryBB);
+          Value *IsNull = new ICmpInst(*EntryBB, ICmpInst::ICMP_EQ, CachedVal,
+                                       NullPtr, "isNull");
           BranchInst::Create(LookupBB, DoCallBB, IsNull, EntryBB);
 
           // Resolve the call to function F via the JIT API:
           BranchInst::Create(LookupBB, DoCallBB, IsNull, EntryBB);
 
           // Resolve the call to function F via the JIT API: