forked from OSchip/llvm-project
Use an AttrBuilder to generate the correct AttributeSet.
We no longer accept an encoded integer as representing all of the attributes. Convert this via the AttrBuilder class into an AttributeSet with the correct representation (an AttributeSetImpl that holds a list of Attribute objects). llvm-svn: 173750
This commit is contained in:
parent
9a629abf3d
commit
60011b8e27
|
@ -461,11 +461,12 @@ Attribute typeIncompatible(Type *Ty);
|
||||||
/// is a breaking change to bitcode compatibility.
|
/// is a breaking change to bitcode compatibility.
|
||||||
uint64_t encodeLLVMAttributesForBitcode(AttributeSet Attrs, unsigned Index);
|
uint64_t encodeLLVMAttributesForBitcode(AttributeSet Attrs, unsigned Index);
|
||||||
|
|
||||||
/// \brief This returns an attribute bitset containing the LLVM attributes that
|
/// \brief This fills an AttrBuilder object with the LLVM attributes that have
|
||||||
/// have been decoded from the given integer. This function must stay in sync
|
/// been decoded from the given integer. This function must stay in sync with
|
||||||
/// with 'encodeLLVMAttributesForBitcode'.
|
/// 'encodeLLVMAttributesForBitcode'.
|
||||||
Attribute decodeLLVMAttributesForBitcode(LLVMContext &C,
|
/// N.B. This should be used only by the bitcode reader!
|
||||||
uint64_t EncodedAttrs);
|
void decodeLLVMAttributesForBitcode(LLVMContext &C, AttrBuilder &B,
|
||||||
|
uint64_t EncodedAttrs);
|
||||||
|
|
||||||
} // end AttributeFuncs namespace
|
} // end AttributeFuncs namespace
|
||||||
|
|
||||||
|
|
|
@ -464,15 +464,10 @@ bool BitcodeReader::ParseAttributeBlock() {
|
||||||
return Error("Invalid ENTRY record");
|
return Error("Invalid ENTRY record");
|
||||||
|
|
||||||
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
||||||
Attribute ReconstitutedAttr =
|
AttrBuilder B;
|
||||||
AttributeFuncs::decodeLLVMAttributesForBitcode(Context, Record[i+1]);
|
AttributeFuncs::decodeLLVMAttributesForBitcode(Context, B,
|
||||||
Record[i+1] = ReconstitutedAttr.Raw();
|
Record[i+1]);
|
||||||
}
|
Attrs.push_back(AttributeSet::get(Context, Record[i], B));
|
||||||
|
|
||||||
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
|
||||||
AttrBuilder B(Record[i+1]);
|
|
||||||
if (B.hasAttributes())
|
|
||||||
Attrs.push_back(AttributeSet::get(Context, Record[i], B));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MAttributes.push_back(AttributeSet::get(Context, Attrs));
|
MAttributes.push_back(AttributeSet::get(Context, Attrs));
|
||||||
|
|
|
@ -377,9 +377,9 @@ uint64_t AttributeSetImpl::Raw(uint64_t Index) const {
|
||||||
// AttributeSet Construction and Mutation Methods
|
// AttributeSet Construction and Mutation Methods
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
AttributeSet AttributeSet::getImpl(LLVMContext &C,
|
AttributeSet
|
||||||
ArrayRef<std::pair<unsigned,
|
AttributeSet::getImpl(LLVMContext &C,
|
||||||
AttributeSetNode*> > Attrs) {
|
ArrayRef<std::pair<unsigned, AttributeSetNode*> > Attrs) {
|
||||||
LLVMContextImpl *pImpl = C.pImpl;
|
LLVMContextImpl *pImpl = C.pImpl;
|
||||||
FoldingSetNodeID ID;
|
FoldingSetNodeID ID;
|
||||||
AttributeSetImpl::Profile(ID, Attrs);
|
AttributeSetImpl::Profile(ID, Attrs);
|
||||||
|
@ -855,6 +855,8 @@ bool AttrBuilder::operator==(const AttrBuilder &B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
|
AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
|
||||||
|
if (!Val) return *this;
|
||||||
|
|
||||||
for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
|
for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
|
||||||
I = Attribute::AttrKind(I + 1)) {
|
I = Attribute::AttrKind(I + 1)) {
|
||||||
if (uint64_t A = (Val & AttributeImpl::getAttrMask(I))) {
|
if (uint64_t A = (Val & AttributeImpl::getAttrMask(I))) {
|
||||||
|
@ -914,6 +916,7 @@ Attribute AttributeFuncs::typeIncompatible(Type *Ty) {
|
||||||
/// \brief This returns an integer containing an encoding of all the LLVM
|
/// \brief This returns an integer containing an encoding of all the LLVM
|
||||||
/// attributes found in the given attribute bitset. Any change to this encoding
|
/// attributes found in the given attribute bitset. Any change to this encoding
|
||||||
/// is a breaking change to bitcode compatibility.
|
/// is a breaking change to bitcode compatibility.
|
||||||
|
/// N.B. This should be used only by the bitcode reader!
|
||||||
uint64_t AttributeFuncs::encodeLLVMAttributesForBitcode(AttributeSet Attrs,
|
uint64_t AttributeFuncs::encodeLLVMAttributesForBitcode(AttributeSet Attrs,
|
||||||
unsigned Index) {
|
unsigned Index) {
|
||||||
// FIXME: It doesn't make sense to store the alignment information as an
|
// FIXME: It doesn't make sense to store the alignment information as an
|
||||||
|
@ -932,21 +935,22 @@ uint64_t AttributeFuncs::encodeLLVMAttributesForBitcode(AttributeSet Attrs,
|
||||||
return EncodedAttrs;
|
return EncodedAttrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief This returns an attribute bitset containing the LLVM attributes that
|
/// \brief This fills an AttrBuilder object with the LLVM attributes that have
|
||||||
/// have been decoded from the given integer. This function must stay in sync
|
/// been decoded from the given integer. This function must stay in sync with
|
||||||
/// with 'encodeLLVMAttributesForBitcode'.
|
/// 'encodeLLVMAttributesForBitcode'.
|
||||||
Attribute AttributeFuncs::decodeLLVMAttributesForBitcode(LLVMContext &C,
|
/// N.B. This should be used only by the bitcode reader!
|
||||||
uint64_t EncodedAttrs){
|
void AttributeFuncs::decodeLLVMAttributesForBitcode(LLVMContext &C,
|
||||||
|
AttrBuilder &B,
|
||||||
|
uint64_t EncodedAttrs) {
|
||||||
// The alignment is stored as a 16-bit raw value from bits 31--16. We shift
|
// The alignment is stored as a 16-bit raw value from bits 31--16. We shift
|
||||||
// the bits above 31 down by 11 bits.
|
// the bits above 31 down by 11 bits.
|
||||||
unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
|
unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
|
||||||
assert((!Alignment || isPowerOf2_32(Alignment)) &&
|
assert((!Alignment || isPowerOf2_32(Alignment)) &&
|
||||||
"Alignment must be a power of two.");
|
"Alignment must be a power of two.");
|
||||||
|
|
||||||
AttrBuilder B(EncodedAttrs & 0xffff);
|
B.addRawValue(EncodedAttrs & 0xffff);
|
||||||
if (Alignment)
|
if (Alignment)
|
||||||
B.addAlignmentAttr(Alignment);
|
B.addAlignmentAttr(Alignment);
|
||||||
B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
|
B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
|
||||||
return Attribute::get(C, B);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue