[llvm-commits] CVS: llvm/lib/VMCore/iMemory.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Sep 13 17:30:07 PDT 2002
Changes in directory llvm/lib/VMCore:
iMemory.cpp updated: 1.27 -> 1.28
---
Log message:
Change the MallocInst & AllocaInst ctors to take the allocated type, not the
pointer type returned.
---
Diffs of the changes:
Index: llvm/lib/VMCore/iMemory.cpp
diff -u llvm/lib/VMCore/iMemory.cpp:1.27 llvm/lib/VMCore/iMemory.cpp:1.28
--- llvm/lib/VMCore/iMemory.cpp:1.27 Tue Sep 10 19:22:39 2002
+++ llvm/lib/VMCore/iMemory.cpp Fri Sep 13 17:28:30 2002
@@ -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);
@@ -29,6 +28,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) {
}
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list