diff options
| author | Dan Gohman <gohman@apple.com> | 2010-05-28 01:38:28 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-05-28 01:38:28 +0000 |
| commit | f7bf15c3da2886b9acb16c617de5c34d9becfe58 (patch) | |
| tree | 2a4c3cda184cb381c9fe70da3489f7c0a7315694 /lib/Bitcode/Reader | |
| parent | 02cab3c57755b1c9c0f4da6344b8102230608ee8 (diff) | |
| download | external_llvm-f7bf15c3da2886b9acb16c617de5c34d9becfe58.zip external_llvm-f7bf15c3da2886b9acb16c617de5c34d9becfe58.tar.gz external_llvm-f7bf15c3da2886b9acb16c617de5c34d9becfe58.tar.bz2 | |
Bitcode support for allocas with arbitrary array size types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104915 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader')
| -rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 69adead..a252da2 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2178,13 +2178,18 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { InstructionList.push_back(I); break; } - case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, op, align] - if (Record.size() < 3) + case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align] + // For backward compatibility, tolerate a lack of an opty, and use i32. + // LLVM 3.0: Remove this. + if (Record.size() < 3 || Record.size() > 4) return Error("Invalid ALLOCA record"); + unsigned OpNum = 0; const PointerType *Ty = - dyn_cast_or_null<PointerType>(getTypeByID(Record[0])); - Value *Size = getFnValueByID(Record[1], Type::getInt32Ty(Context)); - unsigned Align = Record[2]; + dyn_cast_or_null<PointerType>(getTypeByID(Record[OpNum++])); + const Type *OpTy = Record.size() == 4 ? getTypeByID(Record[OpNum++]) : + Type::getInt32Ty(Context); + Value *Size = getFnValueByID(Record[OpNum++], OpTy); + unsigned Align = Record[OpNum++]; if (!Ty || !Size) return Error("Invalid ALLOCA record"); I = new AllocaInst(Ty->getElementType(), Size, (1 << Align) >> 1); InstructionList.push_back(I); |
