diff --git a/llvm/include/llvm/Analysis/MemorySSA.h b/llvm/include/llvm/Analysis/MemorySSA.h --- a/llvm/include/llvm/Analysis/MemorySSA.h +++ b/llvm/include/llvm/Analysis/MemorySSA.h @@ -330,6 +330,7 @@ // allocate space for exactly one operand void *operator new(size_t s) { return User::operator new(s, 1); } + void operator delete(void *ptr) { User::operator delete(ptr, 1); } static bool classof(const Value *MA) { return MA->getValueID() == MemoryUseVal; @@ -390,6 +391,7 @@ // allocate space for exactly two operands void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { User::operator delete(ptr, 2); } static bool classof(const Value *MA) { return MA->getValueID() == MemoryDefVal; @@ -487,6 +489,8 @@ void *operator new(size_t s) { return User::operator new(s); } public: + void operator delete(void *ptr) { User::operator delete(ptr); } + /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(MemoryAccess); diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -61,6 +61,8 @@ void *operator new(size_t s) { return User::operator new(s, 0); } public: + void operator delete(void *ptr) { User::operator delete(ptr, 0); } + ConstantData(const ConstantData &) = delete; /// Methods to support type inquiry through isa, cast, and dyn_cast. @@ -855,6 +857,8 @@ Value *handleOperandChangeImpl(Value *From, Value *To); public: + void operator delete(void *ptr) { User::operator delete(ptr, 2); } + /// Return a BlockAddress for the specified function and basic block. static BlockAddress *get(Function *F, BasicBlock *BB); @@ -899,6 +903,8 @@ Value *handleOperandChangeImpl(Value *From, Value *To); public: + void operator delete(void *ptr) { User::operator delete(ptr, 1); } + /// Return a DSOLocalEquivalent for the specified global value. static DSOLocalEquivalent *get(GlobalValue *GV); diff --git a/llvm/include/llvm/IR/GlobalIndirectSymbol.h b/llvm/include/llvm/IR/GlobalIndirectSymbol.h --- a/llvm/include/llvm/IR/GlobalIndirectSymbol.h +++ b/llvm/include/llvm/IR/GlobalIndirectSymbol.h @@ -35,9 +35,8 @@ GlobalIndirectSymbol &operator=(const GlobalIndirectSymbol &) = delete; // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 1); - } + void *operator new(size_t s) { return User::operator new(s, 1); } + void operator delete(void *ptr) { User::operator delete(ptr, 1); } /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -68,9 +68,8 @@ public: // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 1); - } + void *operator new(size_t s) { return User::operator new(s, 1); } + void operator delete(void *ptr) { User::operator delete(ptr, 1); } /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -203,9 +202,8 @@ public: // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } + void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { User::operator delete(ptr, 2); } /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -769,9 +767,8 @@ public: // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } + void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { User::operator delete(ptr, 2); } /// Construct a compare instruction, given the opcode, the predicate and /// the two operands. Optionally (if InstBefore is specified) insert the diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -332,9 +332,8 @@ AtomicOrdering Order, SyncScope::ID SSID, BasicBlock *InsertAtEnd); // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } + void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { User::operator delete(ptr, 2); } /// Return true if this is a store to a volatile memory location. bool isVolatile() const { return getSubclassData(); } @@ -462,9 +461,8 @@ BasicBlock *InsertAtEnd); // allocate space for exactly zero operands - void *operator new(size_t s) { - return User::operator new(s, 0); - } + void *operator new(size_t s) { return User::operator new(s, 0); } + void operator delete(void *ptr) { User::operator delete(ptr, 0); } /// Returns the ordering constraint of this fence instruction. AtomicOrdering getOrdering() const { @@ -546,9 +544,8 @@ BasicBlock *InsertAtEnd); // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } + void *operator new(size_t s) { return User::operator new(s, 3); } + void operator delete(void *ptr) { User::operator delete(ptr, 3); } using VolatileField = BoolBitfieldElementT<0>; using WeakField = BoolBitfieldElementT; @@ -777,9 +774,8 @@ BasicBlock *InsertAtEnd); // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } + void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { User::operator delete(ptr, 2); } using VolatileField = BoolBitfieldElementT<0>; using AtomicOrderingField = @@ -2020,6 +2016,7 @@ const Twine &NameStr, BasicBlock *InsertAtEnd); void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { return User::operator delete(ptr, 2); } /// Swap the operands and adjust the mask to preserve the semantics /// of the instruction. @@ -2476,9 +2473,8 @@ public: // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } + void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { User::operator delete(ptr, 2); } static InsertValueInst *Create(Value *Agg, Value *Val, ArrayRef Idxs, @@ -2854,9 +2850,7 @@ const Twine &NameStr, BasicBlock *InsertAtEnd); // Allocate space for exactly zero operands. - void *operator new(size_t s) { - return User::operator new(s); - } + void *operator new(size_t s) { return User::operator new(s); } void growOperands(unsigned Size); void init(unsigned NumReservedValues, const Twine &NameStr); @@ -2868,6 +2862,8 @@ LandingPadInst *cloneImpl() const; public: + void operator delete(void *ptr) { User::operator delete(ptr); } + /// Constructors - NumReservedClauses is a hint for the number of incoming /// clauses that this landingpad will have (use 0 if you really have no idea). static LandingPadInst *Create(Type *RetTy, unsigned NumReservedClauses, @@ -3186,9 +3182,7 @@ BasicBlock *InsertAtEnd); // allocate space for exactly zero operands - void *operator new(size_t s) { - return User::operator new(s); - } + void *operator new(size_t s) { return User::operator new(s); } void init(Value *Value, BasicBlock *Default, unsigned NumReserved); void growOperands(); @@ -3200,6 +3194,8 @@ SwitchInst *cloneImpl() const; public: + void operator delete(void *ptr) { User::operator delete(ptr); } + // -2 static const unsigned DefaultPseudoIndex = static_cast(~0L-1); @@ -3584,9 +3580,7 @@ IndirectBrInst(Value *Address, unsigned NumDests, BasicBlock *InsertAtEnd); // allocate space for exactly zero operands - void *operator new(size_t s) { - return User::operator new(s); - } + void *operator new(size_t s) { return User::operator new(s); } void init(Value *Address, unsigned NumDests); void growOperands(); @@ -3598,6 +3592,8 @@ IndirectBrInst *cloneImpl() const; public: + void operator delete(void *ptr) { User::operator delete(ptr); } + /// Iterator type that casts an operand to a basic block. /// /// This only makes sense because the successors are stored as adjacent @@ -4247,6 +4243,8 @@ CatchSwitchInst *cloneImpl() const; public: + void operator delete(void *ptr) { return User::operator delete(ptr); } + static CatchSwitchInst *Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr = "", @@ -4675,9 +4673,8 @@ explicit UnreachableInst(LLVMContext &C, BasicBlock *InsertAtEnd); // allocate space for exactly zero operands - void *operator new(size_t s) { - return User::operator new(s, 0); - } + void *operator new(size_t s) { return User::operator new(s, 0); } + void operator delete(void *ptr) { User::operator delete(ptr, 0); } unsigned getNumSuccessors() const { return 0; } diff --git a/llvm/lib/IR/ConstantsContext.h b/llvm/lib/IR/ConstantsContext.h --- a/llvm/lib/IR/ConstantsContext.h +++ b/llvm/lib/IR/ConstantsContext.h @@ -51,9 +51,8 @@ } // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 1); - } + void *operator new(size_t s) { return User::operator new(s, 1); } + void operator delete(void *ptr) { User::operator delete(ptr, 1); } DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -79,9 +78,8 @@ } // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } + void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { User::operator delete(ptr, 2); } /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -106,9 +104,8 @@ } // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } + void *operator new(size_t s) { return User::operator new(s, 3); } + void operator delete(void *ptr) { User::operator delete(ptr, 3); } /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -134,9 +131,8 @@ } // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } + void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { User::operator delete(ptr, 2); } /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -163,9 +159,8 @@ } // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } + void *operator new(size_t s) { return User::operator new(s, 3); } + void operator delete(void *ptr) { User::operator delete(ptr, 3); } /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -201,6 +196,7 @@ Constant *ShuffleMaskForBitcode; void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { return User::operator delete(ptr, 2); } /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -226,9 +222,8 @@ } // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 1); - } + void *operator new(size_t s) { return User::operator new(s, 1); } + void operator delete(void *ptr) { User::operator delete(ptr, 1); } /// Indices - These identify which value to extract. const SmallVector Indices; @@ -258,9 +253,8 @@ } // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 2); - } + void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *ptr) { User::operator delete(ptr, 2); } /// Indices - These identify the position for the insertion. const SmallVector Indices; @@ -323,9 +317,8 @@ } // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } + void *operator new(size_t s) { return User::operator new(s, 2); } + void operator delete(void *expr) { return User::operator delete(expr, 2); } /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);