[llvm-commits] [llvm] r48672 - in /llvm/branches/ggreif/use-diet: include/llvm/Constants.h include/llvm/InstrTypes.h include/llvm/Instructions.h include/llvm/Support/LLVMBuilder.h include/llvm/User.h lib/VMCore/AutoUpgrade.cpp lib/VMCore/BasicBlock.cpp lib/VMCore/Constants.cpp lib/VMCore/Core.cpp lib/VMCore/Function.cpp lib/VMCore/Instructions.cpp lib/VMCore/Module.cpp

Gabor Greif ggreif at gmail.com
Fri Mar 21 18:13:33 PDT 2008


Author: ggreif
Date: Fri Mar 21 20:13:32 2008
New Revision: 48672

URL: http://llvm.org/viewvc/llvm-project?rev=48672&view=rev
Log:
First changes for wave1, placement 'operator new' introduced where appropriate. libLLVMCore.a builds, but there are many new FIXMEs. Help and feedback welcome.

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/Constants.h
    llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h
    llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
    llvm/branches/ggreif/use-diet/include/llvm/Support/LLVMBuilder.h
    llvm/branches/ggreif/use-diet/include/llvm/User.h
    llvm/branches/ggreif/use-diet/lib/VMCore/AutoUpgrade.cpp
    llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp
    llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp
    llvm/branches/ggreif/use-diet/lib/VMCore/Core.cpp
    llvm/branches/ggreif/use-diet/lib/VMCore/Function.cpp
    llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp
    llvm/branches/ggreif/use-diet/lib/VMCore/Module.cpp

Modified: llvm/branches/ggreif/use-diet/include/llvm/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Constants.h?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Constants.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Constants.h Fri Mar 21 20:13:32 2008
@@ -43,10 +43,16 @@
 /// @brief Class for constant integers.
 class ConstantInt : public Constant {
   static ConstantInt *TheTrueVal, *TheFalseVal;
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   ConstantInt(const ConstantInt &);      // DO NOT IMPLEMENT
   ConstantInt(const IntegerType *Ty, const APInt& V);
   APInt Val;
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
+
   /// Return the constant as an APInt value reference. This allows clients to
   /// obtain a copy of the value, with all its precision in tact.
   /// @brief Return the constant's value.
@@ -215,10 +221,16 @@
 ///
 class ConstantFP : public Constant {
   APFloat Val;
+  void *operator new(size_t, unsigned);// DO NOT IMPLEMENT
   ConstantFP(const ConstantFP &);      // DO NOT IMPLEMENT
 protected:
   ConstantFP(const Type *Ty, const APFloat& V);
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
+
   /// get() - Static factory methods - Return objects of the specified value
   static ConstantFP *get(const Type *Ty, const APFloat& V);
 
@@ -262,11 +274,17 @@
 ///
 class ConstantAggregateZero : public Constant {
   friend struct ConstantCreator<ConstantAggregateZero, Type, char>;
+  void *operator new(size_t, unsigned);                      // DO NOT IMPLEMENT
   ConstantAggregateZero(const ConstantAggregateZero &);      // DO NOT IMPLEMENT
 protected:
   explicit ConstantAggregateZero(const Type *Ty)
     : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {}
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
+
   /// get() - static factory method for creating a null aggregate.  It is
   /// illegal to call this method with a non-aggregate type.
   static Constant *get(const Type *Ty);
@@ -457,6 +475,7 @@
 ///
 class ConstantPointerNull : public Constant {
   friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
+  void *operator new(size_t, unsigned);                  // DO NOT IMPLEMENT
   ConstantPointerNull(const ConstantPointerNull &);      // DO NOT IMPLEMENT
 protected:
   explicit ConstantPointerNull(const PointerType *T)
@@ -464,6 +483,10 @@
                Value::ConstantPointerNullVal, 0, 0) {}
 
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
 
   /// get() - Static factory methods - Return objects of the specified value
   static ConstantPointerNull *get(const PointerType *T);
@@ -706,10 +729,16 @@
 ///
 class UndefValue : public Constant {
   friend struct ConstantCreator<UndefValue, Type, char>;
+  void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
   UndefValue(const UndefValue &);      // DO NOT IMPLEMENT
 protected:
   explicit UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
+
   /// get() - Static factory methods - Return an 'undef' object of the specified
   /// type.
   ///

Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Fri Mar 21 20:13:32 2008
@@ -83,6 +83,7 @@
 //===----------------------------------------------------------------------===//
 
 class UnaryInstruction : public Instruction {
+  void *operator new(size_t, unsigned); // Do not implement
   Use Op;
   
   // avoiding warning: 'this' : used in base member initializer list
@@ -95,6 +96,11 @@
     : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this_()) {
   }
 public:
+  // allocate space for exactly one operand
+  void *operator new(size_t s) {
+    return User::operator new(s, 1);
+  }
+
   // Out of line virtual method, so the vtable, etc has a home.
   ~UnaryInstruction();
 
@@ -129,6 +135,7 @@
 //===----------------------------------------------------------------------===//
 
 class BinaryOperator : public Instruction {
+  void *operator new(size_t, unsigned); // Do not implement
   Use Ops[2];
 protected:
   void init(BinaryOps iType);
@@ -137,6 +144,10 @@
   BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
                  const std::string &Name, BasicBlock *InsertAtEnd);
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
 
   /// Transparently provide more efficient getOperand methods.
   Value *getOperand(unsigned i) const {
@@ -489,6 +500,7 @@
 /// This class is the base class for the comparison instructions. 
 /// @brief Abstract base class of comparison instructions.
 class CmpInst: public Instruction {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   CmpInst(); // do not implement
 protected:
   CmpInst(Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS,
@@ -500,6 +512,10 @@
   Use Ops[2]; // CmpInst instructions always have 2 operands, optimize
 
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
   /// Construct a compare instruction, given the opcode, the predicate and 
   /// the two operands.  Optionally (if InstBefore is specified) insert the 
   /// instruction into a BasicBlock right before the specified instruction.  

Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Fri Mar 21 20:13:32 2008
@@ -46,7 +46,7 @@
   AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
                  const std::string &Name, BasicBlock *InsertAtEnd);
 public:
-  // Out of line virtual method, so the vtable, etc has a home.
+  // Out of line virtual method, so the vtable, etc. has a home.
   virtual ~AllocationInst();
 
   /// isArrayAllocation - Return true if there is an allocation size parameter
@@ -291,6 +291,7 @@
 /// StoreInst - an instruction for storing to memory
 ///
 class StoreInst : public Instruction {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[2];
   
   StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, Ops, 2) {
@@ -305,6 +306,10 @@
   }
   void AssertOK();
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
   StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
   StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
   StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
@@ -1269,11 +1274,16 @@
 // scientist's overactive imagination.
 //
 class PHINode : public Instruction {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   /// ReservedSpace - The number of operands actually allocated.  NumOperands is
   /// the number actually in use.
   unsigned ReservedSpace;
   PHINode(const PHINode &PN);
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
   explicit PHINode(const Type *Ty, const std::string &Name = "",
                    Instruction *InsertBefore = 0)
     : Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore),
@@ -1860,7 +1870,12 @@
 /// until an invoke instruction is found.
 ///
 class UnwindInst : public TerminatorInst {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
   explicit UnwindInst(Instruction *InsertBefore = 0);
   explicit UnwindInst(BasicBlock *InsertAtEnd);
 
@@ -1892,7 +1907,12 @@
 /// end of the block cannot be reached.
 ///
 class UnreachableInst : public TerminatorInst {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
 public:
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
   explicit UnreachableInst(Instruction *InsertBefore = 0);
   explicit UnreachableInst(BasicBlock *InsertAtEnd);
 
@@ -2392,7 +2412,8 @@
 /// GetResultInst - This instruction extracts individual result value from
 /// aggregate value, where aggregate value is returned by CallInst.
 ///
-class GetResultInst : public Instruction {
+class GetResultInst : public /*FIXME: Unary*/Instruction {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Aggr;
   unsigned Idx;
   GetResultInst(const GetResultInst &GRI) :
@@ -2402,6 +2423,10 @@
   }
 
 public:
+  // allocate space for exactly one operand
+  void *operator new(size_t s) {
+    return User::operator new(s, 1);
+  }
   explicit GetResultInst(Value *Aggr, unsigned index,
                          const std::string &Name = "",
                          Instruction *InsertBefore = 0);

Modified: llvm/branches/ggreif/use-diet/include/llvm/Support/LLVMBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Support/LLVMBuilder.h?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Support/LLVMBuilder.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Support/LLVMBuilder.h Fri Mar 21 20:13:32 2008
@@ -87,32 +87,33 @@
 
   /// CreateRetVoid - Create a 'ret void' instruction.
   ReturnInst *CreateRetVoid() {
-    return Insert(new ReturnInst());
+    return Insert(new(0) ReturnInst());
   }
 
   /// @verbatim 
   /// CreateRet - Create a 'ret <val>' instruction. 
   /// @endverbatim
   ReturnInst *CreateRet(Value *V) {
-    return Insert(new ReturnInst(V));
+    return Insert(new(1) ReturnInst(V));
   }
   
   /// CreateBr - Create an unconditional 'br label X' instruction.
   BranchInst *CreateBr(BasicBlock *Dest) {
-    return Insert(new BranchInst(Dest));
+    return Insert(new(1) BranchInst(Dest));
   }
 
   /// CreateCondBr - Create a conditional 'br Cond, TrueDest, FalseDest'
   /// instruction.
   BranchInst *CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False) {
-    return Insert(new BranchInst(True, False, Cond));
+    return Insert(new(2) BranchInst(True, False, Cond));
   }
   
   /// CreateSwitch - Create a switch instruction with the specified value,
   /// default dest, and with a hint for the number of cases that will be added
   /// (for efficient allocation).
   SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10) {
-    return Insert(new SwitchInst(V, Dest, NumCases));
+    unsigned FIXME;
+    return Insert(new(FIXME) SwitchInst(V, Dest, NumCases));
   }
   
   /// CreateInvoke - Create an invoke instruction.
@@ -120,8 +121,9 @@
   InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, 
                            BasicBlock *UnwindDest, InputIterator ArgBegin, 
                            InputIterator ArgEnd, const char *Name = "") {
-    return(Insert(new InvokeInst(Callee, NormalDest, UnwindDest,
-                                 ArgBegin, ArgEnd, Name)));
+    unsigned FIXME;
+    return Insert(new(FIXME) InvokeInst(Callee, NormalDest, UnwindDest,
+                                 ArgBegin, ArgEnd, Name));
   }
   
   UnwindInst *CreateUnwind() {
@@ -221,10 +223,11 @@
   template<typename InputIterator>
   GetElementPtrInst *CreateGEP(Value *Ptr, InputIterator IdxBegin, 
                                InputIterator IdxEnd, const char *Name = "") {
-    return(Insert(new GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Name)));
+    unsigned FIXME(1 + (IdxEnd - IdxBegin));
+    return(Insert(new(FIXME) GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Name)));
   }
   GetElementPtrInst *CreateGEP(Value *Ptr, Value *Idx, const char *Name = "") {
-    return Insert(new GetElementPtrInst(Ptr, Idx, Name));
+    return Insert(new(2) GetElementPtrInst(Ptr, Idx, Name));
   }
   GetElementPtrInst *CreateStructGEP(Value *Ptr, unsigned Idx, 
                                      const char *Name = "") {
@@ -232,7 +235,8 @@
       ConstantInt::get(llvm::Type::Int32Ty, 0),
       ConstantInt::get(llvm::Type::Int32Ty, Idx)
     };
-    return Insert(new GetElementPtrInst(Ptr, Idxs, Idxs+2, Name));
+    unsigned FIXME(3);
+    return Insert(new(FIXME) GetElementPtrInst(Ptr, Idxs, Idxs+2, Name));
   }
   
   //===--------------------------------------------------------------------===//
@@ -388,21 +392,22 @@
   }
 
   CallInst *CreateCall(Value *Callee, const char *Name = "") {
-    return Insert(new CallInst(Callee, Name));
+    return Insert(new(1) CallInst(Callee, Name));
   }
   CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") {
-    return Insert(new CallInst(Callee, Arg, Name));
+    return Insert(new(2) CallInst(Callee, Arg, Name));
   }
 
   template<typename InputIterator>
   CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, 
                        InputIterator ArgEnd, const char *Name = "") {
-    return(Insert(new CallInst(Callee, ArgBegin, ArgEnd, Name)));
+    unsigned FIXME(1 + (ArgEnd - ArgBegin));
+    return Insert(new(FIXME) CallInst(Callee, ArgBegin, ArgEnd, Name));
   }
   
   SelectInst *CreateSelect(Value *C, Value *True, Value *False,
                            const char *Name = "") {
-    return Insert(new SelectInst(C, True, False, Name));
+    return Insert(new(3) SelectInst(C, True, False, Name));
   }
   
   VAArgInst *CreateVAArg(Value *List, const Type *Ty, const char *Name = "") {
@@ -411,17 +416,17 @@
   
   ExtractElementInst *CreateExtractElement(Value *Vec, Value *Idx,
                                            const char *Name = "") {
-    return Insert(new ExtractElementInst(Vec, Idx, Name));
+    return Insert(new(2) ExtractElementInst(Vec, Idx, Name));
   }
   
   InsertElementInst *CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx,
                                          const char *Name = "") {
-    return Insert(new InsertElementInst(Vec, NewElt, Idx, Name));
+    return Insert(new(3) InsertElementInst(Vec, NewElt, Idx, Name));
   }
   
   ShuffleVectorInst *CreateShuffleVector(Value *V1, Value *V2, Value *Mask,
                                          const char *Name = "") {
-    return Insert(new ShuffleVectorInst(V1, V2, Mask, Name));
+    return Insert(new(3) ShuffleVectorInst(V1, V2, Mask, Name));
   }
 };
 

Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/User.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/User.h Fri Mar 21 20:13:32 2008
@@ -25,6 +25,7 @@
 
 class User : public Value {
   User(const User &);             // Do not implement
+  void *operator new(size_t);     // Do not implement
 protected:
   /// OperandList - This is a pointer to the array of Users for this operand.
   /// For nodes of fixed arity (e.g. a binary operator) this array will live
@@ -39,6 +40,9 @@
   unsigned NumOperands;
 
 public:
+  void *operator new(size_t s, unsigned) {
+    return ::operator new(s);
+  }
   User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
     : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {}
 

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/AutoUpgrade.cpp?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/AutoUpgrade.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/AutoUpgrade.cpp Fri Mar 21 20:13:32 2008
@@ -199,8 +199,11 @@
       Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
       Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3));
       Value *Mask = ConstantVector::get(Idxs);
-      ShuffleVectorInst *SI = new ShuffleVectorInst(ZeroV, CI->getOperand(1),
-                                                    Mask, "upgraded", CI);
+      unsigned FIXME;
+      ShuffleVectorInst *SI = new(FIXME) ShuffleVectorInst(ZeroV,
+                                                           CI->getOperand(1),
+                                                           Mask, "upgraded",
+                                                           CI);
 
       // Handle any uses of the old CallInst.
       if (!CI->use_empty())
@@ -216,7 +219,7 @@
     return;
   }
 
-  switch(NewFn->getIntrinsicID()) {
+  switch (NewFn->getIntrinsicID()) {
   default:  assert(0 && "Unknown function for CallInst upgrade.");
   case Intrinsic::x86_mmx_psll_d:
   case Intrinsic::x86_mmx_psll_q:
@@ -237,7 +240,8 @@
     Operands[1] = BC;
     
     //  Construct a new CallInst
-    CallInst *NewCI = new CallInst(NewFn, Operands, Operands+2, 
+    unsigned FIXME;
+    CallInst *NewCI = new(FIXME) CallInst(NewFn, Operands, Operands+2, 
                                    "upgraded."+CI->getName(), CI);
     NewCI->setTailCall(CI->isTailCall());
     NewCI->setCallingConv(CI->getCallingConv());
@@ -254,14 +258,15 @@
   }        
   case Intrinsic::ctlz:
   case Intrinsic::ctpop:
-  case Intrinsic::cttz:
+  case Intrinsic::cttz: {
     //  Build a small vector of the 1..(N-1) operands, which are the 
     //  parameters.
     SmallVector<Value*, 8> Operands(CI->op_begin()+1, CI->op_end());
 
     //  Construct a new CallInst
-    CallInst *NewCI = new CallInst(NewFn, Operands.begin(), Operands.end(), 
-                                   "upgraded."+CI->getName(), CI);
+    unsigned FIXME;
+    CallInst *NewCI = new(FIXME) CallInst(NewFn, Operands.begin(), Operands.end(), 
+                                          "upgraded."+CI->getName(), CI);
     NewCI->setTailCall(CI->isTailCall());
     NewCI->setCallingConv(CI->getCallingConv());
 
@@ -287,7 +292,8 @@
 
     //  Clean up the old call now that it has been completely upgraded.
     CI->eraseFromParent();
-    break;
+  }
+  break;
   }
 }
 

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp Fri Mar 21 20:13:32 2008
@@ -58,7 +58,7 @@
 }
 
 Instruction *ilist_traits<Instruction>::createSentinel() {
-  return new DummyInst();
+  return new(0) DummyInst();
 }
 iplist<Instruction> &ilist_traits<Instruction>::getList(BasicBlock *BB) {
   return BB->getInstList();
@@ -71,7 +71,7 @@
 
 BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
                        BasicBlock *InsertBefore, BasicBlock *Dest)
-  : User(Type::LabelTy, Value::BasicBlockVal, &unwindDest, 0), Parent(0) {
+  : User(Type::LabelTy, Value::BasicBlockVal, &unwindDest, 0/*FIXME*/), Parent(0) {
 
   // Make sure that we get added to a function
   LeakDetector::addGarbageObject(this);
@@ -283,14 +283,14 @@
   assert(I != InstList.end() &&
          "Trying to get me to create degenerate basic block!");
 
-  BasicBlock *New = new BasicBlock(BBName, getParent(), getNext());
+  BasicBlock *New = new(0) BasicBlock(BBName, getParent(), getNext());
 
   // Move all of the specified instructions from the original basic block into
   // the new basic block.
   New->getInstList().splice(New->end(), this->getInstList(), I, end());
 
   // Add a branch instruction to the newly formed basic block.
-  new BranchInst(New, this);
+  new(1) BranchInst(New, this);
 
   // Now we must loop through all of the successors of the New block (which
   // _were_ the successors of the 'this' block), and update any PHI nodes in

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp Fri Mar 21 20:13:32 2008
@@ -410,8 +410,13 @@
 /// UnaryConstantExpr - This class is private to Constants.cpp, and is used
 /// behind the scenes to implement unary constant exprs.
 class VISIBILITY_HIDDEN UnaryConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Op;
 public:
+  // allocate space for exactly one operand
+  void *operator new(size_t s) {
+    return User::operator new(s, 1);
+  }
   UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty)
     : ConstantExpr(Ty, Opcode, &Op, 1), Op(C, this) {}
 };
@@ -419,8 +424,13 @@
 /// BinaryConstantExpr - This class is private to Constants.cpp, and is used
 /// behind the scenes to implement binary constant exprs.
 class VISIBILITY_HIDDEN BinaryConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[2];
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
   BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2)
     : ConstantExpr(C1->getType(), Opcode, Ops, 2) {
     Ops[0].init(C1, this);
@@ -431,8 +441,13 @@
 /// SelectConstantExpr - This class is private to Constants.cpp, and is used
 /// behind the scenes to implement select constant exprs.
 class VISIBILITY_HIDDEN SelectConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[3];
 public:
+  // allocate space for exactly three operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 3);
+  }
   SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3)
     : ConstantExpr(C2->getType(), Instruction::Select, Ops, 3) {
     Ops[0].init(C1, this);
@@ -445,8 +460,13 @@
 /// Constants.cpp, and is used behind the scenes to implement
 /// extractelement constant exprs.
 class VISIBILITY_HIDDEN ExtractElementConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[2];
 public:
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
   ExtractElementConstantExpr(Constant *C1, Constant *C2)
     : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(), 
                    Instruction::ExtractElement, Ops, 2) {
@@ -459,8 +479,13 @@
 /// Constants.cpp, and is used behind the scenes to implement
 /// insertelement constant exprs.
 class VISIBILITY_HIDDEN InsertElementConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[3];
 public:
+  // allocate space for exactly three operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 3);
+  }
   InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
     : ConstantExpr(C1->getType(), Instruction::InsertElement, 
                    Ops, 3) {
@@ -474,8 +499,13 @@
 /// Constants.cpp, and is used behind the scenes to implement
 /// shufflevector constant exprs.
 class VISIBILITY_HIDDEN ShuffleVectorConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   Use Ops[3];
 public:
+  // allocate space for exactly three operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 3);
+  }
   ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3)
   : ConstantExpr(C1->getType(), Instruction::ShuffleVector, 
                  Ops, 3) {
@@ -505,6 +535,11 @@
 // behind the scenes to implement ICmp and FCmp constant expressions. This is
 // needed in order to store the predicate value for these instructions.
 struct VISIBILITY_HIDDEN CompareConstantExpr : public ConstantExpr {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
+  // allocate space for exactly two operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 2);
+  }
   unsigned short predicate;
   Use Ops[2];
   CompareConstantExpr(Instruction::OtherOps opc, unsigned short pred, 
@@ -771,7 +806,8 @@
   template<class ConstantClass, class TypeClass, class ValType>
   struct VISIBILITY_HIDDEN ConstantCreator {
     static ConstantClass *create(const TypeClass *Ty, const ValType &V) {
-      return new ConstantClass(Ty, V);
+      unsigned FIXME; // = traits<ValType>::uses(V)
+      return new(FIXME) ConstantClass(Ty, V);
     }
   };
 
@@ -1004,7 +1040,7 @@
   template<class ValType>
   struct ConstantCreator<ConstantAggregateZero, Type, ValType> {
     static ConstantAggregateZero *create(const Type *Ty, const ValType &V){
-      return new ConstantAggregateZero(Ty);
+      return new(0) ConstantAggregateZero(Ty);
     }
   };
 
@@ -1433,7 +1469,7 @@
                                              V.operands[2]);
       if (V.opcode == Instruction::GetElementPtr) {
         std::vector<Constant*> IdxList(V.operands.begin()+1, V.operands.end());
-        return new GetElementPtrConstantExpr(V.operands[0], IdxList, Ty);
+        return new(IdxList.size()) GetElementPtrConstantExpr(V.operands[0], IdxList, Ty);
       }
 
       // The compare instructions are weird. We have to encode the predicate

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Core.cpp?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Core.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Core.cpp Fri Mar 21 20:13:32 2008
@@ -592,7 +592,8 @@
 /*--.. Operations on global variables ......................................--*/
 
 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name) {
-  return wrap(new GlobalVariable(unwrap(Ty), false,
+  unsigned FIXME(0);
+  return wrap(new(FIXME) GlobalVariable(unwrap(Ty), false,
                                  GlobalValue::ExternalLinkage, 0, Name,
                                  unwrap(M)));
 }
@@ -670,7 +671,8 @@
 
 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
                              LLVMTypeRef FunctionTy) {
-  return wrap(new Function(unwrap<FunctionType>(FunctionTy),
+  unsigned FIXME(0);
+  return wrap(new(FIXME) Function(unwrap<FunctionType>(FunctionTy),
                            GlobalValue::ExternalLinkage, Name, unwrap(M)));
 }
 
@@ -832,14 +834,16 @@
 }
 
 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef FnRef, const char *Name) {
-  return wrap(new BasicBlock(Name, unwrap<Function>(FnRef)));
+  unsigned FIXME(0/*1?*/);
+  return wrap(new(FIXME) BasicBlock(Name, unwrap<Function>(FnRef)));
 }
 
 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBBRef,
                                        const char *Name) {
   BasicBlock *InsertBeforeBB = unwrap(InsertBeforeBBRef);
-  return wrap(new BasicBlock(Name, InsertBeforeBB->getParent(),
-                             InsertBeforeBB));
+  unsigned FIXME(0/*1?*/);
+  return wrap(new(FIXME) BasicBlock(Name, InsertBeforeBB->getParent(),
+                                InsertBeforeBB));
 }
 
 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BBRef) {

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Function.cpp?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Function.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Function.cpp Fri Mar 21 20:13:32 2008
@@ -24,7 +24,8 @@
 using namespace llvm;
 
 BasicBlock *ilist_traits<BasicBlock>::createSentinel() {
-  BasicBlock *Ret = new BasicBlock();
+  unsigned FIXME(0);
+  BasicBlock *Ret = new(FIXME) BasicBlock();
   // This should not be garbage monitored.
   LeakDetector::removeGarbageObject(Ret);
   return Ret;

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Fri Mar 21 20:13:32 2008
@@ -2704,7 +2704,7 @@
 // unit that uses these classes.
 
 GetElementPtrInst *GetElementPtrInst::clone() const {
-  return new GetElementPtrInst(*this);
+  return new(getNumOperands()) GetElementPtrInst(*this);
 }
 
 BinaryOperator *BinaryOperator::clone() const {
@@ -2735,24 +2735,24 @@
 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 { return new CallInst(*this); }
-SelectInst *SelectInst::clone()   const { return new SelectInst(*this); }
+CallInst   *CallInst::clone()     const { return new(getNumOperands()) CallInst(*this); }
+SelectInst *SelectInst::clone()   const { return new(getNumOperands()) SelectInst(*this); }
 VAArgInst  *VAArgInst::clone()    const { return new VAArgInst(*this); }
 
 ExtractElementInst *ExtractElementInst::clone() const {
-  return new ExtractElementInst(*this);
+  return new(getNumOperands()) ExtractElementInst(*this);
 }
 InsertElementInst *InsertElementInst::clone() const {
-  return new InsertElementInst(*this);
+  return new(getNumOperands()) InsertElementInst(*this);
 }
 ShuffleVectorInst *ShuffleVectorInst::clone() const {
-  return new ShuffleVectorInst(*this);
+  return new(getNumOperands()) ShuffleVectorInst(*this);
 }
 PHINode    *PHINode::clone()    const { return new PHINode(*this); }
-ReturnInst *ReturnInst::clone() const { return new ReturnInst(*this); }
-BranchInst *BranchInst::clone() const { return new BranchInst(*this); }
-SwitchInst *SwitchInst::clone() const { return new SwitchInst(*this); }
-InvokeInst *InvokeInst::clone() const { return new InvokeInst(*this); }
+ReturnInst *ReturnInst::clone() const { return new(getNumOperands()) ReturnInst(*this); }
+BranchInst *BranchInst::clone() const { return new(getNumOperands()) BranchInst(*this); }
+SwitchInst *SwitchInst::clone() const { return new(getNumOperands()) SwitchInst(*this); }
+InvokeInst *InvokeInst::clone() const { return new(getNumOperands()) InvokeInst(*this); }
 UnwindInst *UnwindInst::clone() const { return new UnwindInst(); }
 UnreachableInst *UnreachableInst::clone() const { return new UnreachableInst();}
 GetResultInst *GetResultInst::clone() const { return new GetResultInst(*this); }

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Module.cpp?rev=48672&r1=48671&r2=48672&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Module.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Module.cpp Fri Mar 21 20:13:32 2008
@@ -32,20 +32,23 @@
 Function *ilist_traits<Function>::createSentinel() {
   FunctionType *FTy =
     FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false);
-  Function *Ret = new Function(FTy, GlobalValue::ExternalLinkage);
+  unsigned FIXME(0);
+  Function *Ret = new(FIXME) Function(FTy, GlobalValue::ExternalLinkage);
   // This should not be garbage monitored.
   LeakDetector::removeGarbageObject(Ret);
   return Ret;
 }
 GlobalVariable *ilist_traits<GlobalVariable>::createSentinel() {
-  GlobalVariable *Ret = new GlobalVariable(Type::Int32Ty, false,
+  unsigned FIXME(0);
+  GlobalVariable *Ret = new(FIXME) GlobalVariable(Type::Int32Ty, false,
                                            GlobalValue::ExternalLinkage);
   // This should not be garbage monitored.
   LeakDetector::removeGarbageObject(Ret);
   return Ret;
 }
 GlobalAlias *ilist_traits<GlobalAlias>::createSentinel() {
-  GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty,
+  unsigned FIXME(0);
+  GlobalAlias *Ret = new(FIXME) GlobalAlias(Type::Int32Ty,
                                      GlobalValue::ExternalLinkage);
   // This should not be garbage monitored.
   LeakDetector::removeGarbageObject(Ret);
@@ -149,7 +152,8 @@
   GlobalValue *F = dyn_cast_or_null<GlobalValue>(SymTab.lookup(Name));
   if (F == 0) {
     // Nope, add it
-    Function *New = new Function(Ty, GlobalVariable::ExternalLinkage, Name);
+    unsigned FIXME(0);
+    Function *New = new(FIXME) Function(Ty, GlobalVariable::ExternalLinkage, Name);
     FunctionList.push_back(New);
     return New;                    // Return the new prototype.
   }





More information about the llvm-commits mailing list