diff options
37 files changed, 481 insertions, 332 deletions
diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp index 058ef8c72d..cd9e850728 100644 --- a/examples/BrainF/BrainF.cpp +++ b/examples/BrainF/BrainF.cpp @@ -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 - 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); diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp index c3431fc352..89f3ef2d75 100644 --- a/examples/Fibonacci/fibonacci.cpp +++ b/examples/Fibonacci/fibonacci.cpp @@ -60,7 +60,7 @@ static Function *CreateFibFunction(Module *M) { 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 diff --git a/examples/ParallelJIT/ParallelJIT.cpp b/examples/ParallelJIT/ParallelJIT.cpp index eadd0f58e5..e80dc4986a 100644 --- a/examples/ParallelJIT/ParallelJIT.cpp +++ b/examples/ParallelJIT/ParallelJIT.cpp @@ -85,7 +85,7 @@ static Function *CreateFibFunction(Module *M) { 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 diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 0a018de5e9..76827191f1 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -22,6 +22,8 @@ namespace llvm { +class LLVMContext; + //===----------------------------------------------------------------------===// // TerminatorInst Class //===----------------------------------------------------------------------===// @@ -50,7 +52,7 @@ protected: 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. @@ -235,7 +237,7 @@ public: 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 @@ -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 - 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); @@ -660,13 +663,6 @@ public: 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; - } }; diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 7d946e85a6..e06ae2d711 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -20,6 +20,8 @@ namespace llvm { +class LLVMContext; + template<typename ValueSubClass, typename ItemParentClass> class SymbolTableListTraits; @@ -45,7 +47,7 @@ public: /// * 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 diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index aef77f0a93..5bd3066ef9 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -20,6 +20,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Attributes.h" #include "llvm/BasicBlock.h" +#include "llvm/LLVMContext.h" #include "llvm/ADT/SmallVector.h" #include <iterator> @@ -74,7 +75,7 @@ public: 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; } @@ -120,7 +121,7 @@ public: 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; } @@ -164,7 +165,7 @@ public: 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 @@ -194,7 +195,7 @@ public: 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); } @@ -260,7 +261,7 @@ public: 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 /// @@ -344,7 +345,7 @@ public: 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); } @@ -485,7 +486,7 @@ public: 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); @@ -626,12 +627,13 @@ class ICmpInst: public CmpInst { 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 - 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 && @@ -645,16 +647,36 @@ public: "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( + 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 - 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"); @@ -756,7 +778,7 @@ public: 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; } @@ -781,12 +803,13 @@ class FCmpInst: public CmpInst { 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 - 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 && @@ -797,17 +820,35 @@ public: 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( + 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 - 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() && @@ -848,7 +889,7 @@ public: 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; } @@ -959,7 +1000,7 @@ public: SubclassData = (SubclassData & ~1) | unsigned(isTC); } - virtual CallInst *clone() const; + virtual CallInst *clone(LLVMContext &Context) const; /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -1152,7 +1193,7 @@ public: 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; } @@ -1192,7 +1233,7 @@ public: 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; } @@ -1236,7 +1277,7 @@ public: /// 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); @@ -1306,7 +1347,7 @@ public: 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. /// @@ -1358,7 +1399,7 @@ public: 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. /// @@ -1502,7 +1543,7 @@ public: 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. @@ -1672,7 +1713,7 @@ public: 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); @@ -1801,7 +1842,7 @@ public: resizeOperands(NumValues*2); } - virtual PHINode *clone() const; + virtual PHINode *clone(LLVMContext &Context) const; /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -1960,7 +2001,7 @@ public: } virtual ~ReturnInst(); - virtual ReturnInst *clone() const; + virtual ReturnInst *clone(LLVMContext &Context) const; /// 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); - virtual BranchInst *clone() const; + virtual BranchInst *clone(LLVMContext &Context) const; bool isUnconditional() const { return getNumOperands() == 1; } bool isConditional() const { return getNumOperands() == 3; } @@ -2212,7 +2253,7 @@ public: /// 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 { @@ -2326,7 +2367,7 @@ public: Values, NameStr, InsertAtEnd); } - virtual InvokeInst *clone() const; + virtual InvokeInst *clone(LLVMContext &Context) const; /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -2514,7 +2555,7 @@ public: explicit UnwindInst(Instruction *InsertBefore = 0); explicit UnwindInst(BasicBlock *InsertAtEnd); - virtual UnwindInst *clone() const; + virtual UnwindInst *clone(LLVMContext &Context) const; unsigned getNumSuccessors() const { return 0; } @@ -2551,7 +2592,7 @@ public: explicit UnreachableInst(Instruction *InsertBefore = 0); explicit UnreachableInst(BasicBlock *InsertAtEnd); - virtual UnreachableInst *clone() const; + virtual UnreachableInst *clone(LLVMContext &Context) const; unsigned getNumSuccessors() const { return 0; } @@ -2597,7 +2638,7 @@ public: ); /// @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; } @@ -2637,7 +2678,7 @@ public: ); /// @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; } @@ -2677,7 +2718,7 @@ public: ); /// @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; } @@ -2716,7 +2757,7 @@ public: ); /// @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; } @@ -2755,7 +2796,7 @@ public: ); /// @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; } @@ -2794,7 +2835,7 @@ public: ); /// @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; } @@ -2833,7 +2874,7 @@ public: ); /// @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; } @@ -2872,7 +2913,7 @@ public: ); /// @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; } @@ -2911,7 +2952,7 @@ public: ); /// @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; } @@ -2950,7 +2991,7 @@ public: ); /// @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; } @@ -2989,7 +3030,7 @@ public: ); /// @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; } @@ -3028,7 +3069,7 @@ public: ); /// @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; } diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 60da89eb4a..75b7e59ceb 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -213,6 +213,10 @@ public: 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. diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 0fe0c3ce1f..fe794c65ef 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -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); - 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); - return Insert(new FCmpInst(P, LHS, RHS), Name); + return Insert(new FCmpInst(Context, P, LHS, RHS), Name); } //===--------------------------------------------------------------------===// diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 826c64fc89..64212f6193 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -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"); - 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"); - Inst = new ICmpInst(CmpInst::Predicate(Pred), LHS, RHS); + Inst = new ICmpInst(Context, CmpInst::Predicate(Pred), LHS, RHS); } return false; } diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index d69895e0cc..e4d3c5e1ad 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1643,9 +1643,9 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { 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 - I = new ICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS); + I = new ICmpInst(Context, (ICmpInst::Predicate)Record[OpNum], LHS, RHS); break; } diff --git a/lib/CodeGen/StackProtector.cpp b/lib/CodeGen/StackProtector.cpp index c179f1e3df..9043b89e35 100644 --- a/lib/CodeGen/StackProtector.cpp +++ b/li |