[llvm] r174250 - Use the AttributeSet's iterators.
Bill Wendling
isanbard at gmail.com
Fri Feb 1 16:42:07 PST 2013
Author: void
Date: Fri Feb 1 18:42:06 2013
New Revision: 174250
URL: http://llvm.org/viewvc/llvm-project?rev=174250&view=rev
Log:
Use the AttributeSet's iterators.
Use the AttributeSet's iterators in AttrBuilder::hasAttributes() when
determining of the intersection of the AttrBuilder and AttributeSet is non-null.
Modified:
llvm/trunk/lib/IR/AttributeImpl.h
llvm/trunk/lib/IR/Attributes.cpp
Modified: llvm/trunk/lib/IR/AttributeImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AttributeImpl.h?rev=174250&r1=174249&r2=174250&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AttributeImpl.h (original)
+++ llvm/trunk/lib/IR/AttributeImpl.h Fri Feb 1 18:42:06 2013
@@ -153,7 +153,6 @@ public:
/// \p Slot is an index into the AttrNodes list, not the index of the return /
/// parameter/ function which the attributes apply to.
AttributeSet getSlotAttributes(unsigned Slot) const {
- // FIXME: This needs to use AttrNodes instead.
return AttributeSet::get(Context, AttrNodes[Slot]);
}
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=174250&r1=174249&r2=174250&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Fri Feb 1 18:42:06 2013
@@ -42,9 +42,7 @@ Attribute Attribute::get(LLVMContext &Co
if (!PA) {
// If we didn't find any existing attributes of the same shape then create a
// new one and insert it.
- PA = (!Val) ?
- new AttributeImpl(Context, Kind) :
- new AttributeImpl(Context, Kind, Val);
+ PA = new AttributeImpl(Context, Kind, Val);
pImpl->AttrsSet.InsertNode(PA, InsertPoint);
}
@@ -884,7 +882,27 @@ bool AttrBuilder::hasAttributes() const
}
bool AttrBuilder::hasAttributes(AttributeSet A, uint64_t Index) const {
- return Raw() & A.Raw(Index);
+ unsigned Idx = ~0U;
+ for (unsigned I = 0, E = A.getNumSlots(); I != E; ++I)
+ if (A.getSlotIndex(I) == Index) {
+ Idx = I;
+ break;
+ }
+
+ assert(Idx != ~0U && "Couldn't find the index!");
+
+ for (AttributeSet::iterator I = A.begin(Idx), E = A.end(Idx);
+ I != E; ++I) {
+ Attribute Attr = *I;
+ // FIXME: Support StringRefs.
+ Attribute::AttrKind Kind = Attribute::AttrKind(
+ cast<ConstantInt>(Attr.getAttributeKind())->getZExtValue());
+
+ if (Attrs.count(Kind))
+ return true;
+ }
+
+ return false;
}
bool AttrBuilder::hasAlignmentAttr() const {
More information about the llvm-commits
mailing list