Author: lattner Date: Fri Aug 24 15:48:18 2007 New Revision: 41371 URL: http://llvm.org/viewvc/llvm-project?rev=41371&view=rev Log: sink clone() down the class hierarchy from CmpInst into ICmpInst/FCmpInst. This eliminates a conditional on that path, and ensures ICmpInst/FCmpInst both have an out-of-line virtual method to home the class.
Modified: llvm/trunk/include/llvm/InstrTypes.h llvm/trunk/include/llvm/Instructions.h llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=41371&r1=41370&r2=41371&view=diff ============================================================================== --- llvm/trunk/include/llvm/InstrTypes.h (original) +++ llvm/trunk/include/llvm/InstrTypes.h Fri Aug 24 15:48:18 2007 @@ -494,9 +494,6 @@ Value *S2, const std::string &Name, BasicBlock *InsertAtEnd); - /// @brief Implement superclass method. - virtual CmpInst *clone() const; - /// @brief Get the opcode casted to the right type OtherOps getOpcode() const { return static_cast<OtherOps>(Instruction::getOpcode()); Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=41371&r1=41370&r2=41371&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Fri Aug 24 15:48:18 2007 @@ -603,6 +603,8 @@ std::swap(Ops[0], Ops[1]); } + virtual ICmpInst *clone() const; + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ICmpInst *) { return true; } static inline bool classof(const Instruction *I) { @@ -725,6 +727,8 @@ std::swap(Ops[0], Ops[1]); } + virtual FCmpInst *clone() const; + /// @brief Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const FCmpInst *) { return true; } static inline bool classof(const Instruction *I) { Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=41371&r1=41370&r2=41371&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Fri Aug 24 15:48:18 2007 @@ -2595,8 +2595,11 @@ return create(getOpcode(), Ops[0], Ops[1]); } -CmpInst* CmpInst::clone() const { - return create(getOpcode(), getPredicate(), Ops[0], Ops[1]); +FCmpInst* FCmpInst::clone() const { + return new FCmpInst(getPredicate(), Ops[0], Ops[1]); +} +ICmpInst* ICmpInst::clone() const { + return new ICmpInst(getPredicate(), Ops[0], Ops[1]); } MallocInst *MallocInst::clone() const { return new MallocInst(*this); } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits