[llvm] r174123 - Use iterators instead of relying upon a bitmask of attributes to remove attributes from an AttrBuilder.
Bill Wendling
isanbard at gmail.com
Thu Jan 31 16:13:50 PST 2013
Author: void
Date: Thu Jan 31 18:13:50 2013
New Revision: 174123
URL: http://llvm.org/viewvc/llvm-project?rev=174123&view=rev
Log:
Use iterators instead of relying upon a bitmask of attributes to remove attributes from an AttrBuilder.
Modified:
llvm/trunk/lib/IR/Attributes.cpp
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=174123&r1=174122&r2=174123&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Thu Jan 31 18:13:50 2013
@@ -749,7 +749,7 @@ AttributeSet::iterator AttributeSet::beg
AttributeSet::iterator AttributeSet::end(unsigned Idx) {
if (!pImpl)
return ArrayRef<Attribute>().end();
- return pImpl->begin(Idx);
+ return pImpl->end(Idx);
}
//===----------------------------------------------------------------------===//
@@ -852,18 +852,24 @@ AttrBuilder &AttrBuilder::removeAttribut
}
AttrBuilder &AttrBuilder::removeAttributes(AttributeSet A, uint64_t Index) {
- uint64_t Mask = A.Raw(Index);
+ unsigned Idx = ~0U;
+ for (unsigned I = 0, E = A.getNumSlots(); I != E; ++I)
+ if (A.getSlotIndex(I) == Index) {
+ Idx = I;
+ break;
+ }
- for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
- I = Attribute::AttrKind(I + 1)) {
- if (Mask & AttributeImpl::getAttrMask(I)) {
- Attrs.erase(I);
+ assert(Idx != ~0U && "Couldn't find index in AttributeSet!");
- if (I == Attribute::Alignment)
- Alignment = 0;
- else if (I == Attribute::StackAlignment)
- StackAlignment = 0;
- }
+ for (AttributeSet::iterator I = A.begin(Idx), E = A.end(Idx); I != E; ++I) {
+ ConstantInt *CI = cast<ConstantInt>(I->getAttributeKind());
+ Attribute::AttrKind Kind = Attribute::AttrKind(CI->getZExtValue());
+ Attrs.erase(Kind);
+
+ if (Kind == Attribute::Alignment)
+ Alignment = 0;
+ else if (Kind == Attribute::StackAlignment)
+ StackAlignment = 0;
}
return *this;
More information about the llvm-commits
mailing list