diff options
Diffstat (limited to 'lib/VMCore/iMemory.cpp')
-rw-r--r-- | lib/VMCore/iMemory.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/VMCore/iMemory.cpp b/lib/VMCore/iMemory.cpp index 1738d6e..dacb8fe 100644 --- a/lib/VMCore/iMemory.cpp +++ b/lib/VMCore/iMemory.cpp @@ -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 //===----------------------------------------------------------------------===// |