aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/iMemory.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/VMCore/iMemory.cpp b/lib/VMCore/iMemory.cpp
index 7280998a17..cf80909d8b 100644
--- a/lib/VMCore/iMemory.cpp
+++ b/lib/VMCore/iMemory.cpp
@@ -12,6 +12,21 @@ static inline const Type *checkType(const Type *Ty) {
return Ty;
}
+AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
+ const std::string &Name = "")
+ : Instruction(Ty, iTy, Name) {
+ assert(Ty->isPointerType() && "Can't allocate a non pointer type!");
+
+ // ArraySize defaults to 1.
+ if (!ArraySize) ArraySize = ConstantUInt::get(Type::UIntTy, 1);
+
+ Operands.reserve(1);
+ assert(ArraySize->getType() == Type::UIntTy &&
+ "Malloc/Allocation array size != UIntTy!");
+
+ Operands.push_back(Use(ArraySize, this));
+}
+
bool AllocationInst::isArrayAllocation() const {
return getNumOperands() == 1 &&
getOperand(0) != ConstantUInt::get(Type::UIntTy, 1);