llvm.org GIT mirror llvm / 58cfa3b
Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined, and introduce a new Instruction::isIdenticalTo which tests for full identity, including the SubclassOptionalData flags. Also, fix the Instruction::clone implementations to preserve the SubclassOptionalData flags. Finally, teach several optimizations how to handle SubclassOptionalData correctly, given these changes. This fixes the counterintuitive behavior of isIdenticalTo not comparing the full value, and clone not returning an identical clone, as well as some subtle bugs that could be caused by these. Thanks to Nick Lewycky for reporting this, and for an initial patch! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80038 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 11 years ago
10 changed file(s) with 179 addition(s) and 160 deletion(s). Raw diff Collapse all Expand all
8989
9090 class UnaryInstruction : public Instruction {
9191 void *operator new(size_t, unsigned); // Do not implement
92 UnaryInstruction(const UnaryInstruction&); // Do not implement
9392
9493 protected:
9594 UnaryInstruction(const Type *Ty, unsigned iType, Value *V,
314313 /// if (isa(Instr)) { ... }
315314 /// @brief Base class of casting instructions.
316315 class CastInst : public UnaryInstruction {
317 /// @brief Copy constructor
318 CastInst(const CastInst &CI)
319 : UnaryInstruction(CI.getType(), CI.getOpcode(), CI.getOperand(0)) {
320 }
321 /// @brief Do not allow default construction
322 CastInst();
323316 protected:
324317 /// @brief Constructor with insert-before-instruction semantics for subclasses
325318 CastInst(const Type *Ty, unsigned iType, Value *S,
5353 /// extra information (e.g. load is volatile) agree.
5454 bool isIdenticalTo(const Instruction *I) const;
5555
56 /// isIdenticalToWhenDefined - This is like isIdenticalTo, except that it
57 /// ignores the SubclassOptionalData flags, which specify conditions
58 /// under which the instruction's result is undefined.
59 bool isIdenticalToWhenDefined(const Instruction *I) const;
60
5661 /// This function determines if the specified instruction executes the same
5762 /// operation as the current one. This means that the opcodes, type, operand
5863 /// types and any other factors affecting the operation must be the same. This
9898 /// MallocInst - an instruction to allocated memory on the heap
9999 ///
100100 class MallocInst : public AllocationInst {
101 MallocInst(const MallocInst &MI);
102101 public:
103102 explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
104103 const Twine &NameStr = "",
147146 /// AllocaInst - an instruction to allocate memory on the stack
148147 ///
149148 class AllocaInst : public AllocationInst {
150 AllocaInst(const AllocaInst &);
151149 public:
152150 explicit AllocaInst(const Type *Ty,
153151 Value *ArraySize = 0,
233231 /// SubclassData field in Value to store whether or not the load is volatile.
234232 ///
235233 class LoadInst : public UnaryInstruction {
236
237 LoadInst(const LoadInst &LI)
238 : UnaryInstruction(LI.getType(), Load, LI.getOperand(0)) {
239 setVolatile(LI.isVolatile());
240 setAlignment(LI.getAlignment());
241
242 #ifndef NDEBUG
243 AssertOK();
244 #endif
245 }
246234 void AssertOK();
247235 public:
248236 LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore);
307295 ///
308296 class StoreInst : public Instruction {
309297 void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
310
311 StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store,
312 &Op<0>(), 2) {
313 Op<0>() = SI.Op<0>();
314 Op<1>() = SI.Op<1>();
315 setVolatile(SI.isVolatile());
316 setAlignment(SI.getAlignment());
317
318 #ifndef NDEBUG
319 AssertOK();
320 #endif
321 }
322298 void AssertOK();
323299 public:
324300 // allocate space for exactly two operands
11951171 Op<2>() = S2;
11961172 }
11971173
1198 SelectInst(const SelectInst &SI)
1199 : Instruction(SI.getType(), SI.getOpcode(), &Op<0>(), 3) {
1200 init(SI.Op<0>(), SI.Op<1>(), SI.Op<2>());
1201 }
12021174 SelectInst(Value *C, Value *S1, Value *S2, const Twine &NameStr,
12031175 Instruction *InsertBefore)
12041176 : Instruction(S1->getType(), Instruction::Select,
12661238 /// an argument of the specified type given a va_list and increments that list
12671239 ///
12681240 class VAArgInst : public UnaryInstruction {
1269 VAArgInst(const VAArgInst &VAA)
1270 : UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {}
12711241 public:
12721242 VAArgInst(Value *List, const Type *Ty, const Twine &NameStr = "",
12731243 Instruction *InsertBefore = 0)
13001270 /// element from a VectorType value
13011271 ///
13021272 class ExtractElementInst : public Instruction {
1303 ExtractElementInst(const ExtractElementInst &EE) :
1304 Instruction(EE.getType(), ExtractElement, &Op<0>(), 2) {
1305 Op<0>() = EE.Op<0>();
1306 Op<1>() = EE.Op<1>();
1307 }
1308
13091273 ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr = "",
13101274 Instruction *InsertBefore = 0);
13111275 ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr,
13121276 BasicBlock *InsertAtEnd);
13131277 public:
13141278 static ExtractElementInst *Create(const ExtractElementInst &EE) {
1315 return new(EE.getNumOperands()) ExtractElementInst(EE);
1279 return Create(EE.getOperand(0), EE.getOperand(1));
13161280 }
13171281
13181282 static ExtractElementInst *Create(Value *Vec, Value *Idx,
13591323 /// element into a VectorType value
13601324 ///
13611325 class InsertElementInst : public Instruction {
1362 InsertElementInst(const InsertElementInst &IE);
13631326 InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
13641327 const Twine &NameStr = "",
13651328 Instruction *InsertBefore = 0);
13671330 const Twine &NameStr, BasicBlock *InsertAtEnd);
13681331 public:
13691332 static InsertElementInst *Create(const InsertElementInst &IE) {
1370 return new(IE.getNumOperands()) InsertElementInst(IE);
1333 return Create(IE.getOperand(0), IE.getOperand(1), IE.getOperand(2));
13711334 }
13721335 static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
13731336 const Twine &NameStr = "",
14201383 /// input vectors.
14211384 ///
14221385 class ShuffleVectorInst : public Instruction {
1423 ShuffleVectorInst(const ShuffleVectorInst &IE);
14241386 public:
14251387 // allocate space for exactly three operands
14261388 void *operator new(size_t s) {
26572619
26582620 /// @brief This class represents a truncation of integer types.
26592621 class TruncInst : public CastInst {
2660 /// Private copy constructor
2661 TruncInst(const TruncInst &CI)
2662 : CastInst(CI.getType(), Trunc, CI.getOperand(0)) {
2663 }
26642622 public:
26652623 /// @brief Constructor with insert-before-instruction semantics
26662624 TruncInst(
26972655
26982656 /// @brief This class represents zero extension of integer types.
26992657 class ZExtInst : public CastInst {
2700 /// @brief Private copy constructor
2701 ZExtInst(const ZExtInst &CI)
2702 : CastInst(CI.getType(), ZExt, CI.getOperand(0)) {
2703 }
27042658 public:
27052659 /// @brief Constructor with insert-before-instruction semantics
27062660 ZExtInst(
27372691
27382692 /// @brief This class represents a sign extension of integer types.
27392693 class SExtInst : public CastInst {
2740 /// @brief Private copy constructor
2741 SExtInst(const SExtInst &CI)
2742 : CastInst(CI.getType(), SExt, CI.getOperand(0)) {
2743 }
27442694 public:
27452695 /// @brief Constructor with insert-before-instruction semantics
27462696 SExtInst(
27772727
27782728 /// @brief This class represents a truncation of floating point types.
27792729 class FPTruncInst : public CastInst {
2780 FPTruncInst(const FPTruncInst &CI)
2781 : CastInst(CI.getType(), FPTrunc, CI.getOperand(0)) {
2782 }
27832730 public:
27842731 /// @brief Constructor with insert-before-instruction semantics
27852732 FPTruncInst(
28162763
28172764 /// @brief This class represents an extension of floating point types.
28182765 class FPExtInst : public CastInst {
2819 FPExtInst(const FPExtInst &CI)
2820 : CastInst(CI.getType(), FPExt, CI.getOperand(0)) {
2821 }
28222766 public:
28232767 /// @brief Constructor with insert-before-instruction semantics
28242768 FPExtInst(
28552799
28562800 /// @brief This class represents a cast unsigned integer to floating point.
28572801 class UIToFPInst : public CastInst {
2858 UIToFPInst(const UIToFPInst &CI)
2859 : CastInst(CI.getType(), UIToFP, CI.getOperand(0)) {
2860 }
28612802 public:
28622803 /// @brief Constructor with insert-before-instruction semantics
28632804 UIToFPInst(
28942835
28952836 /// @brief This class represents a cast from signed integer to floating point.
28962837 class SIToFPInst : public CastInst {
2897 SIToFPInst(const SIToFPInst &CI)
2898 : CastInst(CI.getType(), SIToFP, CI.getOperand(0)) {
2899 }
29002838 public:
29012839 /// @brief Constructor with insert-before-instruction semantics
29022840 SIToFPInst(
29332871
29342872 /// @brief This class represents a cast from floating point to unsigned integer
29352873 class FPToUIInst : public CastInst {
2936 FPToUIInst(const FPToUIInst &CI)
2937 : CastInst(CI.getType(), FPToUI, CI.getOperand(0)) {
2938 }
29392874 public:
29402875 /// @brief Constructor with insert-before-instruction semantics
29412876 FPToUIInst(
29722907
29732908 /// @brief This class represents a cast from floating point to signed integer.
29742909 class FPToSIInst : public CastInst {
2975 FPToSIInst(const FPToSIInst &CI)
2976 : CastInst(CI.getType(), FPToSI, CI.getOperand(0)) {
2977 }
29782910 public:
29792911 /// @brief Constructor with insert-before-instruction semantics
29802912 FPToSIInst(
30112943
30122944 /// @brief This class represents a cast from an integer to a pointer.
30132945 class IntToPtrInst : public CastInst {
3014 IntToPtrInst(const IntToPtrInst &CI)
3015 : CastInst(CI.getType(), IntToPtr, CI.getOperand(0)) {
3016 }
30172946 public:
30182947 /// @brief Constructor with insert-before-instruction semantics
30192948 IntToPtrInst(
30502979
30512980 /// @brief This class represents a cast from a pointer to an integer
30522981 class PtrToIntInst : public CastInst {
3053 PtrToIntInst(const PtrToIntInst &CI)
3054 : CastInst(CI.getType(), PtrToInt, CI.getOperand(0)) {
3055 }
30562982 public:
30572983 /// @brief Constructor with insert-before-instruction semantics
30582984 PtrToIntInst(
30893015
30903016 /// @brief This class represents a no-op cast from one type to another.
30913017 class BitCastInst : public CastInst {
3092 BitCastInst(const BitCastInst &CI)
3093 : CastInst(CI.getType(), BitCast, CI.getOperand(0)) {
3094 }
30953018 public:
30963019 /// @brief Constructor with insert-before-instruction semantics
30973020 BitCastInst(
239239 return SubclassID;
240240 }
241241
242 /// hasSameSubclassOptionalData - Test whether the optional flags contained
243 /// in this value are equal to the optional flags in the given value.
244 bool hasSameSubclassOptionalData(const Value *V) const {
245 return SubclassOptionalData == V->SubclassOptionalData;
246 }
247
248 /// intersectOptionalDataWith - Clear any optional flags in this value
249 /// that are not also set in the given value.
250 void intersectOptionalDataWith(const Value *V) {
251 SubclassOptionalData &= V->SubclassOptionalData;
252 }
253
242254 // Methods for support type inquiry through isa, cast, and dyn_cast:
243255 static inline bool classof(const Value *) {
244256 return true; // Values are always values.
187187 isEquivalentOperation(const Instruction *I1, const Instruction *I2) {
188188 if (I1->getOpcode() != I2->getOpcode() ||
189189 I1->getNumOperands() != I2->getNumOperands() ||
190 !isEquivalentType(I1->getType(), I2->getType()))
190 !isEquivalentType(I1->getType(), I2->getType()) ||
191 !I1->hasSameSubclassOptionalData(I2))
191192 return false;
192193
193194 // We have two instructions of identical opcode and #operands. Check to see
1181411814 if (A == B) return true;
1181511815
1181611816 // Test if the values come form identical arithmetic instructions.
11817 // This uses isIdenticalToWhenDefined instead of isIdenticalTo because
11818 // its only used to compare two uses within the same basic block, which
11819 // means that they'll always either have the same value or one of them
11820 // will have an undefined value.
1181711821 if (isa(A) ||
1181811822 isa(A) ||
1181911823 isa(A) ||
1182011824 isa(A))
1182111825 if (Instruction *BI = dyn_cast(B))
11822 if (cast(A)->isIdenticalTo(BI))
11826 if (cast(A)->isIdenticalToWhenDefined(BI))
1182311827 return true;
1182411828
1182511829 // Otherwise they may not be equivalent.
503503 // Test if the values are trivially equivalent.
504504 if (A == B) return true;
505505
506 // Test if the values come form identical arithmetic instructions.
506 // Test if the values come from identical arithmetic instructions.
507 // Use isIdenticalToWhenDefined instead of isIdenticalTo because
508 // this function is only used when one address use dominates the
509 // other, which means that they'll always either have the same
510 // value or one of them will have an undefined value.
507511 if (isa(A) || isa(A) ||
508512 isa(A) || isa(A))
509513 if (const Instruction *BI = dyn_cast(B))
510 if (cast(A)->isIdenticalTo(BI))
514 if (cast(A)->isIdenticalToWhenDefined(BI))
511515 return true;
512516
513517 // Otherwise they may not be equivalent.
871871 while (isa(I2))
872872 I2 = BB2_Itr++;
873873 if (I1->getOpcode() != I2->getOpcode() || isa(I1) ||
874 !I1->isIdenticalTo(I2) ||
874 !I1->isIdenticalToWhenDefined(I2) ||
875875 (isa(I1) && !isSafeToHoistInvoke(BB1, BB2, I1, I2)))
876876 return false;
877877
890890 BIParent->getInstList().splice(BI, BB1->getInstList(), I1);
891891 if (!I2->use_empty())
892892 I2->replaceAllUsesWith(I1);
893 I1->intersectOptionalDataWith(I2);
893894 BB2->getInstList().erase(I2);
894895
895896 I1 = BB1_Itr++;
898899 I2 = BB2_Itr++;
899900 while (isa(I2))
900901 I2 = BB2_Itr++;
901 } while (I1->getOpcode() == I2->getOpcode() && I1->isIdenticalTo(I2));
902 } while (I1->getOpcode() == I2->getOpcode() &&
903 I1->isIdenticalToWhenDefined(I2));
902904
903905 return true;
904906
167167 /// identical to the current one. This means that all operands match and any
168168 /// extra information (e.g. load is volatile) agree.
169169 bool Instruction::isIdenticalTo(const Instruction *I) const {
170 return isIdenticalTo(I) &&
171 SubclassOptionalData == I->SubclassOptionalData;
172 }
173
174 /// isIdenticalToWenDefined - This is like isIdenticalTo, except that it
175 /// ignores the SubclassOptionalData flags, which specify conditions
176 /// under which the instruction's result is undefined.
177 bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const {
170178 if (getOpcode() != I->getOpcode() ||
171179 getNumOperands() != I->getNumOperands() ||
172180 getType() != I->getType())
153153 OL[i] = PN.getOperand(i);
154154 OL[i+1] = PN.getOperand(i+1);
155155 }
156 SubclassOptionalData = PN.SubclassOptionalData;
156157 }
157158
158159 PHINode::~PHINode() {
402403 Use *InOL = CI.OperandList;
403404 for (unsigned i = 0, e = CI.getNumOperands(); i != e; ++i)
404405 OL[i] = InOL[i];
406 SubclassOptionalData = CI.SubclassOptionalData;
405407 }
406408
407409 void CallInst::addAttribute(unsigned i, Attributes attr) {
463465 Use *OL = OperandList, *InOL = II.OperandList;
464466 for (unsigned i = 0, e = II.getNumOperands(); i != e; ++i)
465467 OL[i] = InOL[i];
468 SubclassOptionalData = II.SubclassOptionalData;
466469 }
467470
468471 BasicBlock *InvokeInst::getSuccessorV(unsigned idx) const {
507510 RI.getNumOperands()) {
508511 if (RI.getNumOperands())
509512 Op<0>() = RI.Op<0>();
513 SubclassOptionalData = RI.SubclassOptionalData;
510514 }
511515
512516 ReturnInst::ReturnInst(LLVMContext &C, Value *retVal, Instruction *InsertBefore)
662666 Op<-3>() = BI.Op<-3>();
663667 Op<-2>() = BI.Op<-2>();
664668 }
669 SubclassOptionalData = BI.SubclassOptionalData;
665670 }
666671
667672
756761 return getType()->getElementType();
757762 }
758763
759 AllocaInst::AllocaInst(const AllocaInst &AI)
760 : AllocationInst(AI.getType()->getElementType(),
761 (Value*)AI.getOperand(0), Instruction::Alloca,
762 AI.getAlignment()) {
763 }
764
765764 /// isStaticAlloca - Return true if this alloca is in the entry block of the
766765 /// function and is a constant size. If so, the code generator will fold it
767766 /// into the prolog/epilog code, so it is basically free.
772771 // Must be in the entry block.
773772 const BasicBlock *Parent = getParent();
774773 return Parent == &Parent->getParent()->front();
775 }
776
777 MallocInst::MallocInst(const MallocInst &MI)
778 : AllocationInst(MI.getType()->getElementType(),
779 (Value*)MI.getOperand(0), Instruction::Malloc,
780 MI.getAlignment()) {
781774 }
782775
783776 //===----------------------------------------------------------------------===//
10471040 Use *GEPIOL = GEPI.OperandList;
10481041 for (unsigned i = 0, E = NumOperands; i != E; ++i)
10491042 OL[i] = GEPIOL[i];
1043 SubclassOptionalData = GEPI.SubclassOptionalData;
10501044 }
10511045
10521046 GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
12101204 // InsertElementInst Implementation
12111205 //===----------------------------------------------------------------------===//
12121206
1213 InsertElementInst::InsertElementInst(const InsertElementInst &IE)
1214 : Instruction(IE.getType(), InsertElement,
1215 OperandTraits::op_begin(this), 3) {
1216 Op<0>() = IE.Op<0>();
1217 Op<1>() = IE.Op<1>();
1218 Op<2>() = IE.Op<2>();
1219 }
12201207 InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
12211208 const Twine &Name,
12221209 Instruction *InsertBef)
12631250 //===----------------------------------------------------------------------===//
12641251 // ShuffleVectorInst Implementation
12651252 //===----------------------------------------------------------------------===//
1266
1267 ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV)
1268 : Instruction(SV.getType(), ShuffleVector,
1269 OperandTraits::op_begin(this),
1270 OperandTraits::operands(this)) {
1271 Op<0>() = SV.Op<0>();
1272 Op<1>() = SV.Op<1>();
1273 Op<2>() = SV.Op<2>();
1274 }
12751253
12761254 ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
12771255 const Twine &Name,
13631341 Indices(IVI.Indices) {
13641342 Op<0>() = IVI.getOperand(0);
13651343 Op<1>() = IVI.getOperand(1);
1344 SubclassOptionalData = IVI.SubclassOptionalData;
13661345 }
13671346
13681347 InsertValueInst::InsertValueInst(Value *Agg,
14091388 ExtractValueInst::ExtractValueInst(const ExtractValueInst &EVI)
14101389 : UnaryInstruction(EVI.getType(), ExtractValue, EVI.getOperand(0)),
14111390 Indices(EVI.Indices) {
1391 SubclassOptionalData = EVI.SubclassOptionalData;
14121392 }
14131393
14141394 // getIndexedType - Returns the type of the element that would be extracted
27892769 OL[i] = InOL[i];
27902770 OL[i+1] = InOL[i+1];
27912771 }
2772 SubclassOptionalData = SI.SubclassOptionalData;
27922773 }
27932774
27942775 SwitchInst::~SwitchInst() {
28812862 // unit that uses these classes.
28822863
28832864 GetElementPtrInst *GetElementPtrInst::clone(LLVMContext&) const {
2884 return new(getNumOperands()) GetElementPtrInst(*this);
2865 GetElementPtrInst *New = new(getNumOperands()) GetElementPtrInst(*this);
2866 New->SubclassOptionalData = SubclassOptionalData;
2867 return New;
28852868 }
28862869
28872870 BinaryOperator *BinaryOperator::clone(LLVMContext&) const {
2888 return Create(getOpcode(), Op<0>(), Op<1>());
2871 BinaryOperator *New = Create(getOpcode(), Op<0>(), Op<1>());
2872 New->SubclassOptionalData = SubclassOptionalData;
2873 return New;
28892874 }
28902875
28912876 FCmpInst* FCmpInst::clone(LLVMContext &Context) const {
2892 return new FCmpInst(Context, getPredicate(), Op<0>(), Op<1>());
2877 FCmpInst *New = new FCmpInst(Context, getPredicate(), Op<0>(), Op<1>());
2878 New->SubclassOptionalData = SubclassOptionalData;
2879 return New;
28932880 }
28942881 ICmpInst* ICmpInst::clone(LLVMContext &Context) const {
2895 return new ICmpInst(Context, getPredicate(), Op<0>(), Op<1>());
2882 ICmpInst *New = new ICmpInst(Context, getPredicate(), Op<0>(), Op<1>());
2883 New->SubclassOptionalData = SubclassOptionalData;
2884 return New;
28962885 }
28972886
28982887 ExtractValueInst *ExtractValueInst::clone(LLVMContext&) const {
2899 return new ExtractValueInst(*this);
2888 ExtractValueInst *New = new ExtractValueInst(*this);
2889 New->SubclassOptionalData = SubclassOptionalData;
2890 return New;
29002891 }
29012892 InsertValueInst *InsertValueInst::clone(LLVMContext&) const {
2902 return new InsertValueInst(*this);
2893 InsertValueInst *New = new InsertValueInst(*this);
2894 New->SubclassOptionalData = SubclassOptionalData;
2895 return New;
29032896 }
29042897
29052898 MallocInst *MallocInst::clone(LLVMContext&) const {
2906 return new MallocInst(*this);
2899 MallocInst *New = new MallocInst(getAllocatedType(),
2900 (Value*)getOperand(0),
2901 getAlignment());
2902 New->SubclassOptionalData = SubclassOptionalData;
2903 return New;
29072904 }
29082905
29092906 AllocaInst *AllocaInst::clone(LLVMContext&) const {
2910 return new AllocaInst(*this);
2907 AllocaInst *New = new AllocaInst(getAllocatedType(),
2908 (Value*)getOperand(0),
2909 getAlignment());
2910 New->SubclassOptionalData = SubclassOptionalData;
2911 return New;
29112912 }
29122913
29132914 FreeInst *FreeInst::clone(LLVMContext&) const {
2914 return new FreeInst(getOperand(0));
2915 FreeInst *New = new FreeInst(getOperand(0));
2916 New->SubclassOptionalData = SubclassOptionalData;
2917 return New;
29152918 }
29162919
29172920 LoadInst *LoadInst::clone(LLVMContext&) const {
2918 return new LoadInst(*this);
2921 LoadInst *New = new LoadInst(getOperand(0),
2922 Twine(), isVolatile(),
2923 getAlignment());
2924 New->SubclassOptionalData = SubclassOptionalData;
2925 return New;
29192926 }
29202927
29212928 StoreInst *StoreInst::clone(LLVMContext&) const {
2922 return new StoreInst(*this);
2929 StoreInst *New = new StoreInst(getOperand(0), getOperand(1),
2930 isVolatile(), getAlignment());
2931 New->SubclassOptionalData = SubclassOptionalData;
2932 return New;
29232933 }
29242934
29252935 CastInst *TruncInst::clone(LLVMContext&) const {
2926 return new TruncInst(*this);
2936 TruncInst *New = new TruncInst(getOperand(0), getType());
2937 New->SubclassOptionalData = SubclassOptionalData;
2938 return New;
29272939 }
29282940
29292941 CastInst *ZExtInst::clone(LLVMContext&) const {
2930 return new ZExtInst(*this);
2942 ZExtInst *New = new ZExtInst(getOperand(0), getType());
2943 New->SubclassOptionalData = SubclassOptionalData;
2944 return New;
29312945 }
29322946
29332947 CastInst *SExtInst::clone(LLVMContext&) const {
2934 return new SExtInst(*this);
2948 SExtInst *New = new SExtInst(getOperand(0), getType());
2949 New->SubclassOptionalData = SubclassOptionalData;
2950 return New;
29352951 }
29362952
29372953 CastInst *FPTruncInst::clone(LLVMContext&) const {
2938 return new FPTruncInst(*this);
2954 FPTruncInst *New = new FPTruncInst(getOperand(0), getType());
2955 New->SubclassOptionalData = SubclassOptionalData;
2956 return New;
29392957 }
29402958
29412959 CastInst *FPExtInst::clone(LLVMContext&) const {
2942 return new FPExtInst(*this);
2960 FPExtInst *New = new FPExtInst(getOperand(0), getType());
2961 New->SubclassOptionalData = SubclassOptionalData;
2962 return New;
29432963 }
29442964
29452965 CastInst *UIToFPInst::clone(LLVMContext&) const {
2946 return new UIToFPInst(*this);
2966 UIToFPInst *New = new UIToFPInst(getOperand(0), getType());
2967 New->SubclassOptionalData = SubclassOptionalData;
2968 return New;
29472969 }
29482970
29492971 CastInst *SIToFPInst::clone(LLVMContext&) const {
2950 return new SIToFPInst(*this);
2972 SIToFPInst *New = new SIToFPInst(getOperand(0), getType());
2973 New->SubclassOptionalData = SubclassOptionalData;
2974 return New;
29512975 }
29522976
29532977 CastInst *FPToUIInst::clone(LLVMContext&) const {
2954 return new FPToUIInst(*this);
2978 FPToUIInst *New = new FPToUIInst(getOperand(0), getType());
2979 New->SubclassOptionalData = SubclassOptionalData;
2980 return New;
29552981 }
29562982
29572983 CastInst *FPToSIInst::clone(LLVMContext&) const {
2958 return new FPToSIInst(*this);
2984 FPToSIInst *New = new FPToSIInst(getOperand(0), getType());
2985 New->SubclassOptionalData = SubclassOptionalData;
2986 return New;
29592987 }
29602988
29612989 CastInst *PtrToIntInst::clone(LLVMContext&) const {
2962 return new PtrToIntInst(*this);
2990 PtrToIntInst *New = new PtrToIntInst(getOperand(0), getType());
2991 New->SubclassOptionalData = SubclassOptionalData;
2992 return New;
29632993 }
29642994
29652995 CastInst *IntToPtrInst::clone(LLVMContext&) const {
2966 return new IntToPtrInst(*this);
2996 IntToPtrInst *New = new IntToPtrInst(getOperand(0), getType());
2997 New->SubclassOptionalData = SubclassOptionalData;
2998 return New;
29672999 }
29683000
29693001 CastInst *BitCastInst::clone(LLVMContext&) const {
2970 return new BitCastInst(*this);
3002 BitCastInst *New = new BitCastInst(getOperand(0), getType());
3003 New->SubclassOptionalData = SubclassOptionalData;
3004 return New;
29713005 }
29723006
29733007 CallInst *CallInst::clone(LLVMContext&) const {
2974 return new(getNumOperands()) CallInst(*this);
2975 }
2976
2977 SelectInst *SelectInst::clone(LLVMContext&) const {
2978 return new(getNumOperands()) SelectInst(*this);
3008 CallInst *New = new(getNumOperands()) CallInst(*this);
3009 New->SubclassOptionalData = SubclassOptionalData;
3010 return New;
3011 }
3012
3013 SelectInst *SelectInst::clone(LLVMContext&) const {
3014 SelectInst *New = SelectInst::Create(getOperand(0),
3015 getOperand(1),
3016 getOperand(2));
3017 New->SubclassOptionalData = SubclassOptionalData;
3018 return New;
29793019 }
29803020
29813021 VAArgInst *VAArgInst::clone(LLVMContext&) const {
2982 return new VAArgInst(*this);
3022 VAArgInst *New = new VAArgInst(getOperand(0), getType());
3023 New->SubclassOptionalData = SubclassOptionalData;
3024 return New;
29833025 }
29843026
29853027 ExtractElementInst *ExtractElementInst::clone(LLVMContext&) const {
2986 return ExtractElementInst::Create(*this);
3028 ExtractElementInst *New = ExtractElementInst::Create(getOperand(0),
3029 getOperand(1));
3030 New->SubclassOptionalData = SubclassOptionalData;
3031 return New;
29873032 }
29883033
29893034 InsertElementInst *InsertElementInst::clone(LLVMContext&) const {
2990 return InsertElementInst::Create(*this);
3035 InsertElementInst *New = InsertElementInst::Create(getOperand(0),
3036 getOperand(1),
3037 getOperand(2));
3038 New->SubclassOptionalData = SubclassOptionalData;
3039 return New;
29913040 }
29923041
29933042 ShuffleVectorInst *ShuffleVectorInst::clone(LLVMContext&) const {
2994 return new ShuffleVectorInst(*this);
3043 ShuffleVectorInst *New = new ShuffleVectorInst(getOperand(0),
3044 getOperand(1),
3045 getOperand(2));
3046 New->SubclassOptionalData = SubclassOptionalData;
3047 return New;
29953048 }
29963049
29973050 PHINode *PHINode::clone(LLVMContext&) const {
2998 return new PHINode(*this);
3051 PHINode *New = new PHINode(*this);
3052 New->SubclassOptionalData = SubclassOptionalData;
3053 return New;
29993054 }
30003055
30013056 ReturnInst *ReturnInst::clone(LLVMContext&) const {
3002 return new(getNumOperands()) ReturnInst(*this);
3057 ReturnInst *New = new(getNumOperands()) ReturnInst(*this);
3058 New->SubclassOptionalData = SubclassOptionalData;
3059 return New;
30033060 }
30043061
30053062 BranchInst *BranchInst::clone(LLVMContext&) const {
30063063 unsigned Ops(getNumOperands());
3007 return new(Ops, Ops == 1) BranchInst(*this);
3064 BranchInst *New = new(Ops, Ops == 1) BranchInst(*this);
3065 New->SubclassOptionalData = SubclassOptionalData;
3066 return New;
30083067 }
30093068
30103069 SwitchInst *SwitchInst::clone(LLVMContext&) const {
3011 return new SwitchInst(*this);
3070 SwitchInst *New = new SwitchInst(*this);
3071 New->SubclassOptionalData = SubclassOptionalData;
3072 return New;
30123073 }
30133074
30143075 InvokeInst *InvokeInst::clone(LLVMContext&) const {
3015 return new(getNumOperands()) InvokeInst(*this);
3076 InvokeInst *New = new(getNumOperands()) InvokeInst(*this);
3077 New->SubclassOptionalData = SubclassOptionalData;
3078 return New;
30163079 }
30173080
30183081 UnwindInst *UnwindInst::clone(LLVMContext &C) const {
3019 return new UnwindInst(C);
3082 UnwindInst *New = new UnwindInst(C);
3083 New->SubclassOptionalData = SubclassOptionalData;
3084 return New;
30203085 }
30213086
30223087 UnreachableInst *UnreachableInst::clone(LLVMContext &C) const {
3023 return new UnreachableInst(C);
3024 }
3088 UnreachableInst *New = new UnreachableInst(C);
3089 New->SubclassOptionalData = SubclassOptionalData;
3090 return New;
3091 }