aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-03-11 16:06:02 +0100
committerNikita Popov <npopov@redhat.com>2022-03-11 16:08:38 +0100
commitb190108693066d94181014018fbc96624453dbe2 (patch)
treef5849b31125d1ffbed2196e497c24c782c2862a5 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parente61a1a9849aa432f1467b2a9ab45e81a5438437b (diff)
downloadllvm-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/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index c847118..ec10994 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -3072,6 +3072,10 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
Bitfield::set<APV::ExplicitType>(Record, true);
Bitfield::set<APV::SwiftError>(Record, AI.isSwiftError());
Vals.push_back(Record);
+
+ unsigned AS = AI.getAddressSpace();
+ if (AS != M.getDataLayout().getAllocaAddrSpace())
+ Vals.push_back(AS);
break;
}