diff options
author | David Blaikie <dblaikie@gmail.com> | 2015-04-28 16:51:01 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2015-04-28 16:51:01 +0000 |
commit | bdb4910202adab8c538e06102dd65b79dbb84e41 (patch) | |
tree | 77acfe704be28db462e43068422c9d2746caacda /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | ba55804ea3f90e5fdac900d0bc5bdf61dd6ad877 (diff) | |
download | bcm5719-llvm-bdb4910202adab8c538e06102dd65b79dbb84e41.tar.gz bcm5719-llvm-bdb4910202adab8c538e06102dd65b79dbb84e41.zip |
[opaque pointer type] Encode the allocated type of an alloca rather than its pointer result type.
llvm-svn: 235998
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index cc554a91bea..35e98c01760 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -4022,21 +4022,28 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) { case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align] if (Record.size() != 4) return Error("Invalid record"); - PointerType *Ty = - dyn_cast_or_null<PointerType>(getTypeByID(Record[0])); - Type *OpTy = getTypeByID(Record[1]); - Value *Size = getFnValueByID(Record[2], OpTy); uint64_t AlignRecord = Record[3]; const uint64_t InAllocaMask = uint64_t(1) << 5; + const uint64_t ExplicitTypeMask = uint64_t(1) << 6; + const uint64_t FlagMask = InAllocaMask | ExplicitTypeMask; bool InAlloca = AlignRecord & InAllocaMask; + Type *Ty = getTypeByID(Record[0]); + if ((AlignRecord & ExplicitTypeMask) == 0) { + auto *PTy = dyn_cast_or_null<PointerType>(Ty); + if (!PTy) + return Error("Old-style alloca with a non-pointer type"); + Ty = PTy->getElementType(); + } + Type *OpTy = getTypeByID(Record[1]); + Value *Size = getFnValueByID(Record[2], OpTy); unsigned Align; if (std::error_code EC = - parseAlignmentValue(AlignRecord & ~InAllocaMask, Align)) { + parseAlignmentValue(AlignRecord & ~FlagMask, Align)) { return EC; } if (!Ty || !Size) return Error("Invalid record"); - AllocaInst *AI = new AllocaInst(Ty->getElementType(), Size, Align); + AllocaInst *AI = new AllocaInst(Ty, Size, Align); AI->setUsedWithInAlloca(InAlloca); I = AI; InstructionList.push_back(I); |