diff options
author | Meador Inge <meadori@gmail.com> | 2012-05-28 15:45:43 +0000 |
---|---|---|
committer | Meador Inge <meadori@gmail.com> | 2012-05-28 15:45:43 +0000 |
commit | e99f8be067b6f2c19058d0f6307e96287a94f55d (patch) | |
tree | dae609a68c8a2c71bd0c3569967d7c258d2deba4 /lib | |
parent | f52aea8bc25acfdd406f741d2711ebbf54606c81 (diff) |
PR12696: Attribute bits above 1<<30 are not encoded in bitcode
Attribute bits above 1<<30 are now encoded correctly. Additionally,
the encoding/decoding functionality has been hoisted to helper functions
in Attributes.h in an effort to help the encoding/decoding to stay in
sync with the Attribute bitcode definitions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157581 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 16 | ||||
-rw-r--r-- | lib/Bitcode/Writer/BitcodeWriter.cpp | 13 |
2 files changed, 3 insertions, 26 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 2b98f01e58..0e78dce6af 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -463,20 +463,8 @@ bool BitcodeReader::ParseAttributeBlock() { return Error("Invalid ENTRY record"); for (unsigned i = 0, e = Record.size(); i != e; i += 2) { - // FIXME: remove in LLVM 3.0 - // The alignment is stored as a 16-bit raw value from bits 31--16. - // We shift the bits above 31 down by 11 bits. - - unsigned Alignment = (Record[i+1] & (0xffffull << 16)) >> 16; - if (Alignment && !isPowerOf2_32(Alignment)) - return Error("Alignment is not a power of two."); - - Attributes ReconstitutedAttr(Record[i+1] & 0xffff); - if (Alignment) - ReconstitutedAttr |= Attribute::constructAlignmentFromInt(Alignment); - ReconstitutedAttr |= - Attributes((Record[i+1] & (0xffffull << 32)) >> 11); - + Attributes ReconstitutedAttr = + Attribute::decodeLLVMAttributesForBitcode(Record[i+1]); Record[i+1] = ReconstitutedAttr.Raw(); } diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index c68086655f..d454964290 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -177,18 +177,7 @@ static void WriteAttributeTable(const ValueEnumerator &VE, for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) { const AttributeWithIndex &PAWI = A.getSlot(i); Record.push_back(PAWI.Index); - - // FIXME: remove in LLVM 3.0 - // Store the alignment in the bitcode as a 16-bit raw value instead of a - // 5-bit log2 encoded value. Shift the bits above the alignment up by - // 11 bits. - uint64_t FauxAttr = PAWI.Attrs.Raw() & 0xffff; - if (PAWI.Attrs & Attribute::Alignment) - FauxAttr |= (1ull<<16)<< - (((PAWI.Attrs & Attribute::Alignment).Raw()-1) >> 16); - FauxAttr |= (PAWI.Attrs.Raw() & (0x3FFull << 21)) << 11; - - Record.push_back(FauxAttr); + Record.push_back(Attribute::encodeLLVMAttributesForBitcode(PAWI.Attrs)); } Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record); |