summaryrefslogtreecommitdiff
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-12 08:13:50 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-12 08:13:50 +0000
commit48fbcfe6b959df628a6455e00ac8d94fa6ade87a (patch)
treeb125ec2996eb832ece56dfb9cbd68aad3f5e6bfe /lib/Bitcode
parent105ea3d49d4a458af8779ae7f144f00d19c4168f (diff)
downloadllvm-48fbcfe6b959df628a6455e00ac8d94fa6ade87a.tar.gz
llvm-48fbcfe6b959df628a6455e00ac8d94fa6ade87a.tar.bz2
llvm-48fbcfe6b959df628a6455e00ac8d94fa6ade87a.tar.xz
Have the bitcode writer and reader handle the new attribute references.
The bitcode writer emits a reference to the attribute group that the object at the given index refers to. The bitcode reader is modified to read this in and map it back to the attribute group. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174952 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp8
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp36
2 files changed, 11 insertions, 33 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 476c68a6c0..f34884391a 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -494,6 +494,14 @@ bool BitcodeReader::ParseAttributeBlock() {
Attrs.clear();
break;
}
+ case bitc::PARAMATTR_CODE_ENTRY: { // ENTRY: [attrgrp0, attrgrp1, ...]
+ for (unsigned i = 0, e = Record.size(); i != e; ++i)
+ Attrs.push_back(MAttributeGroups[Record[i]]);
+
+ MAttributes.push_back(AttributeSet::get(Context, Attrs));
+ Attrs.clear();
+ break;
+ }
}
}
}
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index 84f67ad05c..1b73f23e8f 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -209,30 +209,6 @@ static void WriteAttributeGroupTable(const ValueEnumerator &VE,
Stream.ExitBlock();
}
-/// \brief This returns an integer containing an encoding of all the LLVM
-/// attributes found in the given attribute bitset. Any change to this encoding
-/// is a breaking change to bitcode compatibility.
-/// N.B. This should be used only by the bitcode writer!
-static uint64_t encodeLLVMAttributesForBitcode(AttributeSet Attrs,
- unsigned Index) {
- // FIXME: Remove in 4.0!
-
- // FIXME: It doesn't make sense to store the alignment information as an
- // expanded out value, we should store it as a log2 value. However, we can't
- // just change that here without breaking bitcode compatibility. If this ever
- // becomes a problem in practice, we should introduce new tag numbers in the
- // bitcode file and have those tags use a more efficiently encoded alignment
- // field.
-
- // 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 EncodedAttrs = Attrs.Raw(Index) & 0xffff;
- if (Attrs.hasAttribute(Index, Attribute::Alignment))
- EncodedAttrs |= Attrs.getParamAlignment(Index) << 16;
- EncodedAttrs |= (Attrs.Raw(Index) & (0xfffffULL << 21)) << 11;
- return EncodedAttrs;
-}
-
static void WriteAttributeTable(const ValueEnumerator &VE,
BitstreamWriter &Stream) {
const std::vector<AttributeSet> &Attrs = VE.getAttributes();
@@ -240,19 +216,13 @@ static void WriteAttributeTable(const ValueEnumerator &VE,
Stream.EnterSubblock(bitc::PARAMATTR_BLOCK_ID, 3);
- // FIXME: Remove this! It no longer works with the current attributes classes.
-
SmallVector<uint64_t, 64> Record;
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
const AttributeSet &A = Attrs[i];
- for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) {
- unsigned Index = A.getSlotIndex(i);
- Record.push_back(Index);
- Record.push_back(encodeLLVMAttributesForBitcode(A.getSlotAttributes(i),
- Index));
- }
+ for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i)
+ Record.push_back(VE.getAttributeGroupID(A.getSlotAttributes(i)));
- Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY_OLD, Record);
+ Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
Record.clear();
}