1 //===-- Attribute.cpp - Implement AttributesList -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the Attribute, AttributeImpl, AttrBuilder,
11 // AttributeSetImpl, and AttributeSet classes.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/IR/Attributes.h"
16 #include "AttributeImpl.h"
17 #include "LLVMContextImpl.h"
18 #include "llvm/ADT/FoldingSet.h"
19 #include "llvm/ADT/StringExtras.h"
20 #include "llvm/IR/Type.h"
21 #include "llvm/Support/Atomic.h"
22 #include "llvm/Support/Debug.h"
23 #include "llvm/Support/ManagedStatic.h"
24 #include "llvm/Support/Mutex.h"
25 #include "llvm/Support/raw_ostream.h"
28 //===----------------------------------------------------------------------===//
29 // Attribute Implementation
30 //===----------------------------------------------------------------------===//
32 Attribute Attribute::get(LLVMContext &Context, ArrayRef<AttrKind> Vals) {
34 for (ArrayRef<AttrKind>::iterator I = Vals.begin(), E = Vals.end();
37 return Attribute::get(Context, B);
40 Attribute Attribute::get(LLVMContext &Context, AttrBuilder &B) {
41 // If there are no attributes, return an empty Attribute class.
42 if (!B.hasAttributes())
45 // Otherwise, build a key to look up the existing attributes.
46 LLVMContextImpl *pImpl = Context.pImpl;
48 ID.AddInteger(B.getBitMask());
51 AttributeImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
54 // If we didn't find any existing attributes of the same shape then create a
55 // new one and insert it.
56 PA = new AttributeImpl(Context, B.getBitMask());
57 pImpl->AttrsSet.InsertNode(PA, InsertPoint);
60 // Return the AttributesList that we found or created.
64 bool Attribute::hasAttribute(AttrKind Val) const {
65 return pImpl && pImpl->hasAttribute(Val);
68 bool Attribute::hasAttributes() const {
69 return pImpl && pImpl->hasAttributes();
72 /// This returns the alignment field of an attribute as a byte alignment value.
73 unsigned Attribute::getAlignment() const {
74 if (!hasAttribute(Attribute::Alignment))
76 return 1U << ((pImpl->getAlignment() >> 16) - 1);
79 void Attribute::setAlignment(unsigned Align) {
80 assert(hasAttribute(Attribute::Alignment) &&
81 "Trying to set the alignment on a non-alignment attribute!");
82 pImpl->setAlignment(Align);
85 /// This returns the stack alignment field of an attribute as a byte alignment
87 unsigned Attribute::getStackAlignment() const {
88 if (!hasAttribute(Attribute::StackAlignment))
90 return 1U << ((pImpl->getStackAlignment() >> 26) - 1);
93 void Attribute::setStackAlignment(unsigned Align) {
94 assert(hasAttribute(Attribute::StackAlignment) &&
95 "Trying to set the stack alignment on a non-alignment attribute!");
96 pImpl->setStackAlignment(Align);
99 bool Attribute::operator==(AttrKind K) const {
100 return pImpl && *pImpl == K;
102 bool Attribute::operator!=(AttrKind K) const {
103 return !(*this == K);
106 uint64_t Attribute::getBitMask() const {
107 return pImpl ? pImpl->getBitMask() : 0;
110 Attribute Attribute::typeIncompatible(Type *Ty) {
111 AttrBuilder Incompatible;
113 if (!Ty->isIntegerTy())
114 // Attribute that only apply to integers.
115 Incompatible.addAttribute(Attribute::SExt)
116 .addAttribute(Attribute::ZExt);
118 if (!Ty->isPointerTy())
119 // Attribute that only apply to pointers.
120 Incompatible.addAttribute(Attribute::ByVal)
121 .addAttribute(Attribute::Nest)
122 .addAttribute(Attribute::NoAlias)
123 .addAttribute(Attribute::NoCapture)
124 .addAttribute(Attribute::StructRet);
126 return Attribute::get(Ty->getContext(), Incompatible);
129 /// encodeLLVMAttributesForBitcode - This returns an integer containing an
130 /// encoding of all the LLVM attributes found in the given attribute bitset.
131 /// Any change to this encoding is a breaking change to bitcode compatibility.
132 uint64_t Attribute::encodeLLVMAttributesForBitcode(Attribute Attrs) {
133 // FIXME: It doesn't make sense to store the alignment information as an
134 // expanded out value, we should store it as a log2 value. However, we can't
135 // just change that here without breaking bitcode compatibility. If this ever
136 // becomes a problem in practice, we should introduce new tag numbers in the
137 // bitcode file and have those tags use a more efficiently encoded alignment
140 // Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit
141 // log2 encoded value. Shift the bits above the alignment up by 11 bits.
142 uint64_t EncodedAttrs = Attrs.getBitMask() & 0xffff;
143 if (Attrs.hasAttribute(Attribute::Alignment))
144 EncodedAttrs |= Attrs.getAlignment() << 16;
145 EncodedAttrs |= (Attrs.getBitMask() & (0xffffULL << 21)) << 11;
149 /// decodeLLVMAttributesForBitcode - This returns an attribute bitset containing
150 /// the LLVM attributes that have been decoded from the given integer. This
151 /// function must stay in sync with 'encodeLLVMAttributesForBitcode'.
152 Attribute Attribute::decodeLLVMAttributesForBitcode(LLVMContext &C,
153 uint64_t EncodedAttrs) {
154 // The alignment is stored as a 16-bit raw value from bits 31--16. We shift
155 // the bits above 31 down by 11 bits.
156 unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
157 assert((!Alignment || isPowerOf2_32(Alignment)) &&
158 "Alignment must be a power of two.");
160 AttrBuilder B(EncodedAttrs & 0xffff);
162 B.addAlignmentAttr(Alignment);
163 B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
164 return Attribute::get(C, B);
167 std::string Attribute::getAsString() const {
169 if (hasAttribute(Attribute::ZExt))
170 Result += "zeroext ";
171 if (hasAttribute(Attribute::SExt))
172 Result += "signext ";
173 if (hasAttribute(Attribute::NoReturn))
174 Result += "noreturn ";
175 if (hasAttribute(Attribute::NoUnwind))
176 Result += "nounwind ";
177 if (hasAttribute(Attribute::UWTable))
178 Result += "uwtable ";
179 if (hasAttribute(Attribute::ReturnsTwice))
180 Result += "returns_twice ";
181 if (hasAttribute(Attribute::InReg))
183 if (hasAttribute(Attribute::NoAlias))
184 Result += "noalias ";
185 if (hasAttribute(Attribute::NoCapture))
186 Result += "nocapture ";
187 if (hasAttribute(Attribute::StructRet))
189 if (hasAttribute(Attribute::ByVal))
191 if (hasAttribute(Attribute::Nest))
193 if (hasAttribute(Attribute::ReadNone))
194 Result += "readnone ";
195 if (hasAttribute(Attribute::ReadOnly))
196 Result += "readonly ";
197 if (hasAttribute(Attribute::OptimizeForSize))
198 Result += "optsize ";
199 if (hasAttribute(Attribute::NoInline))
200 Result += "noinline ";
201 if (hasAttribute(Attribute::InlineHint))
202 Result += "inlinehint ";
203 if (hasAttribute(Attribute::AlwaysInline))
204 Result += "alwaysinline ";
205 if (hasAttribute(Attribute::StackProtect))
207 if (hasAttribute(Attribute::StackProtectReq))
209 if (hasAttribute(Attribute::NoRedZone))
210 Result += "noredzone ";
211 if (hasAttribute(Attribute::NoImplicitFloat))
212 Result += "noimplicitfloat ";
213 if (hasAttribute(Attribute::Naked))
215 if (hasAttribute(Attribute::NonLazyBind))
216 Result += "nonlazybind ";
217 if (hasAttribute(Attribute::AddressSafety))
218 Result += "address_safety ";
219 if (hasAttribute(Attribute::MinSize))
220 Result += "minsize ";
221 if (hasAttribute(Attribute::StackAlignment)) {
222 Result += "alignstack(";
223 Result += utostr(getStackAlignment());
226 if (hasAttribute(Attribute::Alignment)) {
228 Result += utostr(getAlignment());
231 if (hasAttribute(Attribute::NoDuplicate))
232 Result += "noduplicate ";
233 // Trim the trailing space.
234 assert(!Result.empty() && "Unknown attribute!");
235 Result.erase(Result.end()-1);
239 //===----------------------------------------------------------------------===//
240 // AttrBuilder Method Implementations
241 //===----------------------------------------------------------------------===//
243 void AttrBuilder::clear() {
245 Alignment = StackAlignment = 0;
248 AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val) {
253 AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
255 if (Val == Attribute::Alignment)
257 else if (Val == Attribute::StackAlignment)
263 AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) {
264 if (Align == 0) return *this;
266 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
267 assert(Align <= 0x40000000 && "Alignment too large.");
269 Attrs.insert(Attribute::Alignment);
274 AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align) {
275 // Default alignment, allow the target to define how to align it.
276 if (Align == 0) return *this;
278 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
279 assert(Align <= 0x100 && "Alignment too large.");
281 Attrs.insert(Attribute::StackAlignment);
282 StackAlignment = Align;
286 AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
287 for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
288 I = Attribute::AttrKind(I + 1)) {
289 if (uint64_t A = (Val & AttributeImpl::getAttrMask(I))) {
292 if (I == Attribute::Alignment)
293 Alignment = 1ULL << ((A >> 16) - 1);
294 else if (I == Attribute::StackAlignment)
295 StackAlignment = 1ULL << ((A >> 26)-1);
302 AttrBuilder &AttrBuilder::addAttributes(const Attribute &A) {
303 uint64_t Mask = A.getBitMask();
305 for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
306 I = Attribute::AttrKind(I + 1)) {
307 if (uint64_t A = (Mask & AttributeImpl::getAttrMask(I))) {
310 if (I == Attribute::Alignment)
311 Alignment = 1ULL << ((A >> 16) - 1);
312 else if (I == Attribute::StackAlignment)
313 StackAlignment = 1ULL << ((A >> 26)-1);
320 AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){
321 uint64_t Mask = A.getBitMask();
323 for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
324 I = Attribute::AttrKind(I + 1)) {
325 if (Mask & AttributeImpl::getAttrMask(I)) {
328 if (I == Attribute::Alignment)
330 else if (I == Attribute::StackAlignment)
338 bool AttrBuilder::contains(Attribute::AttrKind A) const {
339 return Attrs.count(A);
342 bool AttrBuilder::hasAttributes() const {
343 return !Attrs.empty();
346 bool AttrBuilder::hasAttributes(const Attribute &A) const {
347 return getBitMask() & A.getBitMask();
350 bool AttrBuilder::hasAlignmentAttr() const {
351 return Alignment != 0;
354 uint64_t AttrBuilder::getBitMask() const {
357 for (DenseSet<Attribute::AttrKind>::const_iterator I = Attrs.begin(),
358 E = Attrs.end(); I != E; ++I) {
359 Attribute::AttrKind Kind = *I;
361 if (Kind == Attribute::Alignment)
362 Mask |= (Log2_32(Alignment) + 1) << 16;
363 else if (Kind == Attribute::StackAlignment)
364 Mask |= (Log2_32(StackAlignment) + 1) << 26;
366 Mask |= AttributeImpl::getAttrMask(Kind);
372 bool AttrBuilder::operator==(const AttrBuilder &B) {
373 SmallVector<Attribute::AttrKind, 8> This(Attrs.begin(), Attrs.end());
374 SmallVector<Attribute::AttrKind, 8> That(B.Attrs.begin(), B.Attrs.end());
378 //===----------------------------------------------------------------------===//
379 // AttributeImpl Definition
380 //===----------------------------------------------------------------------===//
382 AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data)
384 Data = ConstantInt::get(Type::getInt64Ty(C), data);
386 AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data)
388 Data = ConstantInt::get(Type::getInt64Ty(C), data);
390 AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data,
391 ArrayRef<Constant*> values)
393 Data = ConstantInt::get(Type::getInt64Ty(C), data);
394 Vals.reserve(values.size());
395 Vals.append(values.begin(), values.end());
397 AttributeImpl::AttributeImpl(LLVMContext &C, StringRef data)
399 Data = ConstantDataArray::getString(C, data);
402 bool AttributeImpl::operator==(Attribute::AttrKind Kind) const {
403 if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))
404 return CI->getZExtValue() == Kind;
407 bool AttributeImpl::operator!=(Attribute::AttrKind Kind) const {
408 return !(*this == Kind);
411 bool AttributeImpl::operator==(StringRef Kind) const {
412 if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data))
414 return CDA->getAsString() == Kind;
417 bool AttributeImpl::operator!=(StringRef Kind) const {
418 return !(*this == Kind);
421 uint64_t AttributeImpl::getBitMask() const {
422 // FIXME: Remove this.
423 return cast<ConstantInt>(Data)->getZExtValue();
426 uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {
428 case Attribute::EndAttrKinds: break;
429 case Attribute::None: return 0;
430 case Attribute::ZExt: return 1 << 0;
431 case Attribute::SExt: return 1 << 1;
432 case Attribute::NoReturn: return 1 << 2;
433 case Attribute::InReg: return 1 << 3;
434 case Attribute::StructRet: return 1 << 4;
435 case Attribute::NoUnwind: return 1 << 5;
436 case Attribute::NoAlias: return 1 << 6;
437 case Attribute::ByVal: return 1 << 7;
438 case Attribute::Nest: return 1 << 8;
439 case Attribute::ReadNone: return 1 << 9;
440 case Attribute::ReadOnly: return 1 << 10;
441 case Attribute::NoInline: return 1 << 11;
442 case Attribute::AlwaysInline: return 1 << 12;
443 case Attribute::OptimizeForSize: return 1 << 13;
444 case Attribute::StackProtect: return 1 << 14;
445 case Attribute::StackProtectReq: return 1 << 15;
446 case Attribute::Alignment: return 31 << 16;
447 case Attribute::NoCapture: return 1 << 21;
448 case Attribute::NoRedZone: return 1 << 22;
449 case Attribute::NoImplicitFloat: return 1 << 23;
450 case Attribute::Naked: return 1 << 24;
451 case Attribute::InlineHint: return 1 << 25;
452 case Attribute::StackAlignment: return 7 << 26;
453 case Attribute::ReturnsTwice: return 1 << 29;
454 case Attribute::UWTable: return 1 << 30;
455 case Attribute::NonLazyBind: return 1U << 31;
456 case Attribute::AddressSafety: return 1ULL << 32;
457 case Attribute::MinSize: return 1ULL << 33;
458 case Attribute::NoDuplicate: return 1ULL << 34;
460 llvm_unreachable("Unsupported attribute type");
463 bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
464 return (getBitMask() & getAttrMask(A)) != 0;
467 bool AttributeImpl::hasAttributes() const {
468 return getBitMask() != 0;
471 uint64_t AttributeImpl::getAlignment() const {
472 return getBitMask() & getAttrMask(Attribute::Alignment);
475 void AttributeImpl::setAlignment(unsigned Align) {
476 Vals.push_back(ConstantInt::get(Type::getInt64Ty(Context), Align));
479 uint64_t AttributeImpl::getStackAlignment() const {
480 return getBitMask() & getAttrMask(Attribute::StackAlignment);
483 void AttributeImpl::setStackAlignment(unsigned Align) {
484 Vals.push_back(ConstantInt::get(Type::getInt64Ty(Context), Align));
487 //===----------------------------------------------------------------------===//
488 // AttributeSetImpl Definition
489 //===----------------------------------------------------------------------===//
491 AttributeSet AttributeSet::get(LLVMContext &C,
492 ArrayRef<AttributeWithIndex> Attrs) {
493 // If there are no attributes then return a null AttributesList pointer.
495 return AttributeSet();
498 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
499 assert(Attrs[i].Attrs.hasAttributes() &&
500 "Pointless attribute!");
501 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
502 "Misordered AttributesList!");
506 // Otherwise, build a key to look up the existing attributes.
507 LLVMContextImpl *pImpl = C.pImpl;
509 AttributeSetImpl::Profile(ID, Attrs);
512 AttributeSetImpl *PA = pImpl->AttrsLists.FindNodeOrInsertPos(ID, InsertPoint);
514 // If we didn't find any existing attributes of the same shape then
515 // create a new one and insert it.
517 PA = new AttributeSetImpl(C, Attrs);
518 pImpl->AttrsLists.InsertNode(PA, InsertPoint);
521 // Return the AttributesList that we found or created.
522 return AttributeSet(PA);
525 AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx, AttrBuilder &B) {
526 SmallVector<AttributeWithIndex, 8> Attrs;
527 for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I) {
528 Attribute::AttrKind Kind = *I;
529 Attribute A = Attribute::get(C, Kind);
531 if (Kind == Attribute::Alignment)
532 A.setAlignment(B.getAlignment());
533 else if (Kind == Attribute::StackAlignment)
534 A.setStackAlignment(B.getStackAlignment());
536 Attrs.push_back(AttributeWithIndex::get(Idx, A));
539 return get(C, Attrs);
542 //===----------------------------------------------------------------------===//
543 // AttributeSet Method Implementations
544 //===----------------------------------------------------------------------===//
546 const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) {
547 AttrList = RHS.AttrList;
551 /// getNumSlots - Return the number of slots used in this attribute list.
552 /// This is the number of arguments that have an attribute set on them
553 /// (including the function itself).
554 unsigned AttributeSet::getNumSlots() const {
555 return AttrList ? AttrList->getNumAttributes() : 0;
558 /// getSlot - Return the AttributeWithIndex at the specified slot. This
559 /// holds a number plus a set of attributes.
560 const AttributeWithIndex &AttributeSet::getSlot(unsigned Slot) const {
561 assert(AttrList && Slot < AttrList->getNumAttributes() &&
562 "Slot # out of range!");
563 return AttrList->getAttributes()[Slot];
566 bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{
567 return getAttributes(Index).hasAttribute(Kind);
570 bool AttributeSet::hasAttributes(unsigned Index) const {
571 return getAttributes(Index).hasAttributes();
574 std::string AttributeSet::getAsString(unsigned Index) const {
575 return getAttributes(Index).getAsString();
578 unsigned AttributeSet::getStackAlignment(unsigned Index) const {
579 return getAttributes(Index).getStackAlignment();
582 uint64_t AttributeSet::getBitMask(unsigned Index) const {
583 // FIXME: Remove this.
584 return getAttributes(Index).getBitMask();
587 /// getAttributes - The attributes for the specified index are returned.
588 /// Attributes for the result are denoted with Idx = 0. Function attributes are
589 /// denoted with Idx = ~0.
590 Attribute AttributeSet::getAttributes(unsigned Idx) const {
591 if (AttrList == 0) return Attribute();
593 ArrayRef<AttributeWithIndex> Attrs = AttrList->getAttributes();
594 for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
595 if (Attrs[i].Index == Idx)
596 return Attrs[i].Attrs;
601 /// hasAttrSomewhere - Return true if the specified attribute is set for at
602 /// least one parameter or for the return value.
603 bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
604 if (AttrList == 0) return false;
606 ArrayRef<AttributeWithIndex> Attrs = AttrList->getAttributes();
607 for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
608 if (Attrs[i].Attrs.hasAttribute(Attr))
614 AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
615 Attribute Attrs) const {
616 Attribute OldAttrs = getAttributes(Idx);
618 // FIXME it is not obvious how this should work for alignment.
619 // For now, say we can't change a known alignment.
620 unsigned OldAlign = OldAttrs.getAlignment();
621 unsigned NewAlign = Attrs.getAlignment();
622 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
623 "Attempt to change alignment!");
626 AttrBuilder NewAttrs =
627 AttrBuilder(OldAttrs).addAttributes(Attrs);
628 if (NewAttrs == AttrBuilder(OldAttrs))
631 SmallVector<AttributeWithIndex, 8> NewAttrList;
633 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
635 ArrayRef<AttributeWithIndex> OldAttrList = AttrList->getAttributes();
636 unsigned i = 0, e = OldAttrList.size();
637 // Copy attributes for arguments before this one.
638 for (; i != e && OldAttrList[i].Index < Idx; ++i)
639 NewAttrList.push_back(OldAttrList[i]);
641 // If there are attributes already at this index, merge them in.
642 if (i != e && OldAttrList[i].Index == Idx) {
644 Attribute::get(C, AttrBuilder(Attrs).
645 addAttributes(OldAttrList[i].Attrs));
649 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
651 // Copy attributes for arguments after this one.
652 NewAttrList.insert(NewAttrList.end(),
653 OldAttrList.begin()+i, OldAttrList.end());
656 return get(C, NewAttrList);
659 AttributeSet AttributeSet::removeAttr(LLVMContext &C, unsigned Idx,
660 Attribute Attrs) const {
662 // FIXME it is not obvious how this should work for alignment.
663 // For now, say we can't pass in alignment, which no current use does.
664 assert(!Attrs.hasAttribute(Attribute::Alignment) &&
665 "Attempt to exclude alignment!");
667 if (AttrList == 0) return AttributeSet();
669 Attribute OldAttrs = getAttributes(Idx);
670 AttrBuilder NewAttrs =
671 AttrBuilder(OldAttrs).removeAttributes(Attrs);
672 if (NewAttrs == AttrBuilder(OldAttrs))
675 SmallVector<AttributeWithIndex, 8> NewAttrList;
676 ArrayRef<AttributeWithIndex> OldAttrList = AttrList->getAttributes();
677 unsigned i = 0, e = OldAttrList.size();
679 // Copy attributes for arguments before this one.
680 for (; i != e && OldAttrList[i].Index < Idx; ++i)
681 NewAttrList.push_back(OldAttrList[i]);
683 // If there are attributes already at this index, merge them in.
684 assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
685 Attrs = Attribute::get(C, AttrBuilder(OldAttrList[i].Attrs).
686 removeAttributes(Attrs));
688 if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
689 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
691 // Copy attributes for arguments after this one.
692 NewAttrList.insert(NewAttrList.end(),
693 OldAttrList.begin()+i, OldAttrList.end());
695 return get(C, NewAttrList);
698 void AttributeSet::dump() const {
700 for (unsigned i = 0; i < getNumSlots(); ++i) {
701 const AttributeWithIndex &PAWI = getSlot(i);
702 dbgs() << "{ " << PAWI.Index << ", " << PAWI.Attrs.getAsString() << " } ";