Start using the new function cloning header
[oota-llvm.git] / lib / VMCore / iMemory.cpp
index 1738d6e6a2f6050aef35943a8ec18b8b8b888d2b..dacb8fe2a23f9ac757d6cf5de71ade6384a2f4c1 100644 (file)
@@ -10,8 +10,7 @@
 
 AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, 
                                const std::string &Name, Instruction *InsertBef)
-  : Instruction(Ty, iTy, Name, InsertBef) {
-  assert(isa<PointerType>(Ty) && "Can't allocate a non pointer type!");
+  : Instruction(PointerType::get(Ty), iTy, Name, InsertBef) {
 
   // ArraySize defaults to 1.
   if (!ArraySize) ArraySize = ConstantUInt::get(Type::UIntTy, 1);
@@ -31,6 +30,16 @@ const Type *AllocationInst::getAllocatedType() const {
   return getType()->getElementType();
 }
 
+AllocaInst::AllocaInst(const AllocaInst &AI)
+  : AllocationInst(AI.getType()->getElementType(), (Value*)AI.getOperand(0),
+                   Instruction::Alloca) {
+}
+
+MallocInst::MallocInst(const MallocInst &MI)
+  : AllocationInst(MI.getType()->getElementType(), (Value*)MI.getOperand(0),
+                   Instruction::Malloc) {
+}
+
 //===----------------------------------------------------------------------===//
 //                             FreeInst Implementation
 //===----------------------------------------------------------------------===//