aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Reader/Reader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-11-05 22:08:14 +0000
committerChris Lattner <sabre@nondot.org>2005-11-05 22:08:14 +0000
commit42ba6b4b8841487dc4ec0f6020f336c3a2cf0699 (patch)
treed98320769e7944f814f4c21e8f04dea10a8f6343 /lib/Bytecode/Reader/Reader.cpp
parent4e240c25e34e8a032ab23e09981069d77939a2d8 (diff)
Write/read allocation instruction alignment info to .bc files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24203 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/Reader.cpp')
-rw-r--r--lib/Bytecode/Reader/Reader.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index daf7577cf0..917727098e 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -902,27 +902,33 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
if (CallingConv) cast<InvokeInst>(Result)->setCallingConv(CallingConv);
break;
}
- case Instruction::Malloc:
- if (Oprnds.size() > 2)
+ case Instruction::Malloc: {
+ unsigned Align = 0;
+ if (Oprnds.size() == 2)
+ Align = (1 << Oprnds[1]) >> 1;
+ else if (Oprnds.size() > 2)
error("Invalid malloc instruction!");
if (!isa<PointerType>(InstTy))
error("Invalid malloc instruction!");
Result = new MallocInst(cast<PointerType>(InstTy)->getElementType(),
- Oprnds.size() ? getValue(Type::UIntTyID,
- Oprnds[0]) : 0);
+ getValue(Type::UIntTyID, Oprnds[0]), Align);
break;
+ }
- case Instruction::Alloca:
- if (Oprnds.size() > 2)
+ case Instruction::Alloca: {
+ unsigned Align = 0;
+ if (Oprnds.size() == 2)
+ Align = (1 << Oprnds[1]) >> 1;
+ else if (Oprnds.size() > 2)
error("Invalid alloca instruction!");
if (!isa<PointerType>(InstTy))
error("Invalid alloca instruction!");
Result = new AllocaInst(cast<PointerType>(InstTy)->getElementType(),
- Oprnds.size() ? getValue(Type::UIntTyID,
- Oprnds[0]) :0);
+ getValue(Type::UIntTyID, Oprnds[0]), Align);
break;
+ }
case Instruction::Free:
if (!isa<PointerType>(InstTy))
error("Invalid free instruction!");