diff options
author | Dan Gohman <gohman@apple.com> | 2008-03-24 16:55:58 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-03-24 16:55:58 +0000 |
commit | aa583d75b11f5911683594ef9d423b28ed770967 (patch) | |
tree | dc67eb72aba6be238fe87199ba3d2782ba6ac3c4 /llvm/lib/VMCore/Instructions.cpp | |
parent | d8ea040c310540e14ba9064f68744f79ef122cc0 (diff) | |
download | bcm5719-llvm-aa583d75b11f5911683594ef9d423b28ed770967.tar.gz bcm5719-llvm-aa583d75b11f5911683594ef9d423b28ed770967.zip |
Shrink the size of AllocationInst by using its SubclassData
field to store the alignment value instead of haing a
separate field.
llvm-svn: 48727
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index df5a2fc0cfc..33ab1c66eb7 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -677,8 +677,8 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align, const std::string &Name, Instruction *InsertBefore) : UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(ArraySize), - InsertBefore), Alignment(Align) { - assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); + InsertBefore) { + setAlignment(Align); assert(Ty != Type::VoidTy && "Cannot allocate void!"); setName(Name); } @@ -687,8 +687,8 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align, const std::string &Name, BasicBlock *InsertAtEnd) : UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(ArraySize), - InsertAtEnd), Alignment(Align) { - assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); + InsertAtEnd) { + setAlignment(Align); assert(Ty != Type::VoidTy && "Cannot allocate void!"); setName(Name); } @@ -697,6 +697,12 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, AllocationInst::~AllocationInst() { } +void AllocationInst::setAlignment(unsigned Align) { + assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); + SubclassData = Log2_32(Align) + 1; + assert(getAlignment() == Align && "Alignment representation error!"); +} + bool AllocationInst::isArrayAllocation() const { if (ConstantInt *CI = dyn_cast<ConstantInt>(getOperand(0))) return CI->getZExtValue() != 1; |