diff options
author | David Blaikie <dblaikie@gmail.com> | 2015-04-27 19:58:56 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2015-04-27 19:58:56 +0000 |
commit | 1a848da518991408d9a3b10fd03dcd63e8185918 (patch) | |
tree | 1a8388d007fd816d45e554835e319a8bf4c4b449 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | fe723b9a6d8100fddc31a07c11cc756ebb2bb3cb (diff) | |
download | llvm-1a848da518991408d9a3b10fd03dcd63e8185918.zip llvm-1a848da518991408d9a3b10fd03dcd63e8185918.tar.gz llvm-1a848da518991408d9a3b10fd03dcd63e8185918.tar.bz2 |
[opaque pointer type] encode the pointee type of global variables
Use a few extra bits in the const field (after widening it from a fixed
single bit) to stash the address space which is no longer provided by
the type (and an extra bit in there to specify that we're using that new
encoding).
llvm-svn: 235911
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index b8baabd..840b75e 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -590,7 +590,7 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE, unsigned MaxGlobalType = 0; for (const GlobalValue &GV : M->globals()) { MaxAlignment = std::max(MaxAlignment, GV.getAlignment()); - MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getType())); + MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType())); if (GV.hasSection()) { // Give section names unique ID's. unsigned &Entry = SectionMap[GV.getSection()]; @@ -631,10 +631,12 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE, Abbv->Add(BitCodeAbbrevOp(bitc::MODULE_CODE_GLOBALVAR)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(MaxGlobalType+1))); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constant. - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Initializer. - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // Linkage. - if (MaxAlignment == 0) // Alignment. + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddrSpace << 2 + //| explicitType << 1 + //| constant + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Initializer. + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // Linkage. + if (MaxAlignment == 0) // Alignment. Abbv->Add(BitCodeAbbrevOp(0)); else { unsigned MaxEncAlignment = Log2_32(MaxAlignment)+1; @@ -659,8 +661,8 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE, // linkage, alignment, section, visibility, threadlocal, // unnamed_addr, externally_initialized, dllstorageclass, // comdat] - Vals.push_back(VE.getTypeID(GV.getType())); - Vals.push_back(GV.isConstant()); + Vals.push_back(VE.getTypeID(GV.getValueType())); + Vals.push_back(GV.getType()->getAddressSpace() << 2 | 2 | GV.isConstant()); Vals.push_back(GV.isDeclaration() ? 0 : (VE.getValueID(GV.getInitializer()) + 1)); Vals.push_back(getEncodedLinkage(GV)); |