diff options
author | Nikita Popov <npopov@redhat.com> | 2022-03-11 16:06:02 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-03-11 16:08:38 +0100 |
commit | b190108693066d94181014018fbc96624453dbe2 (patch) | |
tree | f5849b31125d1ffbed2196e497c24c782c2862a5 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | e61a1a9849aa432f1467b2a9ab45e81a5438437b (diff) | |
download | llvm-b190108693066d94181014018fbc96624453dbe2.zip llvm-b190108693066d94181014018fbc96624453dbe2.tar.gz llvm-b190108693066d94181014018fbc96624453dbe2.tar.bz2 |
[Bitcode] Encode alloca address space
Since D101045, allocas are no longer required to be part of the
default alloca address space. There may be allocas in multiple
different address spaces. However, the bitcode reader would
simply assume the default alloca address space, resulting in
either an error or incorrect IR.
Add an optional record for allocas which encodes the address
space.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 6dd2fdb..f6f0c92 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -5294,7 +5294,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) { } case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align] - if (Record.size() != 4) + if (Record.size() != 4 && Record.size() != 5) return error("Invalid record"); using APV = AllocaPackedValues; const uint64_t Rec = Record[3]; @@ -5321,9 +5321,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) { if (!Ty || !Size) return error("Invalid record"); - // FIXME: Make this an optional field. const DataLayout &DL = TheModule->getDataLayout(); - unsigned AS = DL.getAllocaAddrSpace(); + unsigned AS = Record.size() == 5 ? Record[4] : DL.getAllocaAddrSpace(); SmallPtrSet<Type *, 4> Visited; if (!Align && !Ty->isSized(&Visited)) |