1 //===-- Attributes.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 AttributesList class and Attribute utilities.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Attributes.h"
15 #include "LLVMContextImpl.h"
16 #include "llvm/Type.h"
17 #include "llvm/ADT/StringExtras.h"
18 #include "llvm/ADT/FoldingSet.h"
19 #include "llvm/Support/Atomic.h"
20 #include "llvm/Support/Mutex.h"
21 #include "llvm/Support/Debug.h"
22 #include "llvm/Support/ManagedStatic.h"
23 #include "llvm/Support/raw_ostream.h"
26 //===----------------------------------------------------------------------===//
27 // Attributes Implementation
28 //===----------------------------------------------------------------------===//
30 Attributes::Attributes(uint64_t Val) : Attrs(Val) {}
32 Attributes::Attributes(Attribute::AttrConst Val) : Attrs(Val.v) {}
34 Attributes::Attributes(AttributesImpl *A) : Attrs(A->Bits) {}
36 Attributes::Attributes(const Attributes &A) : Attrs(A.Attrs) {}
38 // FIXME: This is temporary until we have implemented the uniquified version of
40 Attributes Attributes::get(Attributes::Builder &B) {
41 return Attributes(B.Bits);
44 Attributes Attributes::get(LLVMContext &Context, Attributes::Builder &B) {
45 // If there are no attributes, return an empty Attributes class.
49 // Otherwise, build a key to look up the existing attributes.
50 LLVMContextImpl *pImpl = Context.pImpl;
52 ID.AddInteger(B.Bits);
55 AttributesImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
58 // If we didn't find any existing attributes of the same shape then create a
59 // new one and insert it.
60 PA = new AttributesImpl(B.Bits);
61 pImpl->AttrsSet.InsertNode(PA, InsertPoint);
64 // Return the AttributesList that we found or created.
65 return Attributes(PA);
68 bool Attributes::hasAttributes(const Attributes &A) const {
69 return Attrs.hasAttributes(A);
72 bool Attributes::hasAttribute(AttrVal Val) const {
73 return Attrs.hasAttribute(Val);
76 /// This returns the alignment field of an attribute as a byte alignment value.
77 unsigned Attributes::getAlignment() const {
78 if (!hasAttribute(Attributes::Alignment))
80 return 1U << ((Attrs.getAlignment() >> 16) - 1);
83 /// This returns the stack alignment field of an attribute as a byte alignment
85 unsigned Attributes::getStackAlignment() const {
86 if (!hasAttribute(Attributes::StackAlignment))
88 return 1U << ((Attrs.getStackAlignment() >> 26) - 1);
91 bool Attributes::isEmptyOrSingleton() const {
92 return Attrs.isEmptyOrSingleton();
95 Attributes Attributes::operator | (const Attributes &A) const {
96 return Attributes(Raw() | A.Raw());
98 Attributes Attributes::operator & (const Attributes &A) const {
99 return Attributes(Raw() & A.Raw());
101 Attributes Attributes::operator ^ (const Attributes &A) const {
102 return Attributes(Raw() ^ A.Raw());
104 Attributes &Attributes::operator |= (const Attributes &A) {
105 Attrs.Bits |= A.Raw();
108 Attributes &Attributes::operator &= (const Attributes &A) {
109 Attrs.Bits &= A.Raw();
112 Attributes Attributes::operator ~ () const {
113 return Attributes(~Raw());
116 uint64_t Attributes::Raw() const {
120 Attributes Attributes::typeIncompatible(Type *Ty) {
121 Attributes::Builder Incompatible;
123 if (!Ty->isIntegerTy()) {
124 // Attributes that only apply to integers.
125 Incompatible.addSExtAttr();
126 Incompatible.addZExtAttr();
129 if (!Ty->isPointerTy()) {
130 // Attributes that only apply to pointers.
131 Incompatible.addByValAttr();
132 Incompatible.addNestAttr();
133 Incompatible.addNoAliasAttr();
134 Incompatible.addNoCaptureAttr();
135 Incompatible.addStructRetAttr();
138 return Attributes(Incompatible.Bits); // FIXME: Use Attributes::get().
141 std::string Attributes::getAsString() const {
143 if (hasAttribute(Attributes::ZExt))
144 Result += "zeroext ";
145 if (hasAttribute(Attributes::SExt))
146 Result += "signext ";
147 if (hasAttribute(Attributes::NoReturn))
148 Result += "noreturn ";
149 if (hasAttribute(Attributes::NoUnwind))
150 Result += "nounwind ";
151 if (hasAttribute(Attributes::UWTable))
152 Result += "uwtable ";
153 if (hasAttribute(Attributes::ReturnsTwice))
154 Result += "returns_twice ";
155 if (hasAttribute(Attributes::InReg))
157 if (hasAttribute(Attributes::NoAlias))
158 Result += "noalias ";
159 if (hasAttribute(Attributes::NoCapture))
160 Result += "nocapture ";
161 if (hasAttribute(Attributes::StructRet))
163 if (hasAttribute(Attributes::ByVal))
165 if (hasAttribute(Attributes::Nest))
167 if (hasAttribute(Attributes::ReadNone))
168 Result += "readnone ";
169 if (hasAttribute(Attributes::ReadOnly))
170 Result += "readonly ";
171 if (hasAttribute(Attributes::OptimizeForSize))
172 Result += "optsize ";
173 if (hasAttribute(Attributes::NoInline))
174 Result += "noinline ";
175 if (hasAttribute(Attributes::InlineHint))
176 Result += "inlinehint ";
177 if (hasAttribute(Attributes::AlwaysInline))
178 Result += "alwaysinline ";
179 if (hasAttribute(Attributes::StackProtect))
181 if (hasAttribute(Attributes::StackProtectReq))
183 if (hasAttribute(Attributes::NoRedZone))
184 Result += "noredzone ";
185 if (hasAttribute(Attributes::NoImplicitFloat))
186 Result += "noimplicitfloat ";
187 if (hasAttribute(Attributes::Naked))
189 if (hasAttribute(Attributes::NonLazyBind))
190 Result += "nonlazybind ";
191 if (hasAttribute(Attributes::AddressSafety))
192 Result += "address_safety ";
193 if (hasAttribute(Attributes::StackAlignment)) {
194 Result += "alignstack(";
195 Result += utostr(getStackAlignment());
198 if (hasAttribute(Attributes::Alignment)) {
200 Result += utostr(getAlignment());
203 // Trim the trailing space.
204 assert(!Result.empty() && "Unknown attribute!");
205 Result.erase(Result.end()-1);
209 //===----------------------------------------------------------------------===//
210 // Attributes::Builder Implementation
211 //===----------------------------------------------------------------------===//
213 void Attributes::Builder::addAddressSafetyAttr() {
214 Bits |= Attribute::AddressSafety_i;
216 void Attributes::Builder::addAlwaysInlineAttr() {
217 Bits |= Attribute::AlwaysInline_i;
219 void Attributes::Builder::addByValAttr() {
220 Bits |= Attribute::ByVal_i;
222 void Attributes::Builder::addInlineHintAttr() {
223 Bits |= Attribute::InlineHint_i;
225 void Attributes::Builder::addInRegAttr() {
226 Bits |= Attribute::InReg_i;
228 void Attributes::Builder::addNakedAttr() {
229 Bits |= Attribute::Naked_i;
231 void Attributes::Builder::addNestAttr() {
232 Bits |= Attribute::Nest_i;
234 void Attributes::Builder::addNoAliasAttr() {
235 Bits |= Attribute::NoAlias_i;
237 void Attributes::Builder::addNoCaptureAttr() {
238 Bits |= Attribute::NoCapture_i;
240 void Attributes::Builder::addNoImplicitFloatAttr() {
241 Bits |= Attribute::NoImplicitFloat_i;
243 void Attributes::Builder::addNoInlineAttr() {
244 Bits |= Attribute::NoInline_i;
246 void Attributes::Builder::addNonLazyBindAttr() {
247 Bits |= Attribute::NonLazyBind_i;
249 void Attributes::Builder::addNoRedZoneAttr() {
250 Bits |= Attribute::NoRedZone_i;
252 void Attributes::Builder::addNoReturnAttr() {
253 Bits |= Attribute::NoReturn_i;
255 void Attributes::Builder::addNoUnwindAttr() {
256 Bits |= Attribute::NoUnwind_i;
258 void Attributes::Builder::addOptimizeForSizeAttr() {
259 Bits |= Attribute::OptimizeForSize_i;
261 void Attributes::Builder::addReadNoneAttr() {
262 Bits |= Attribute::ReadNone_i;
264 void Attributes::Builder::addReadOnlyAttr() {
265 Bits |= Attribute::ReadOnly_i;
267 void Attributes::Builder::addReturnsTwiceAttr() {
268 Bits |= Attribute::ReturnsTwice_i;
270 void Attributes::Builder::addSExtAttr() {
271 Bits |= Attribute::SExt_i;
273 void Attributes::Builder::addStackProtectAttr() {
274 Bits |= Attribute::StackProtect_i;
276 void Attributes::Builder::addStackProtectReqAttr() {
277 Bits |= Attribute::StackProtectReq_i;
279 void Attributes::Builder::addStructRetAttr() {
280 Bits |= Attribute::StructRet_i;
282 void Attributes::Builder::addUWTableAttr() {
283 Bits |= Attribute::UWTable_i;
285 void Attributes::Builder::addZExtAttr() {
286 Bits |= Attribute::ZExt_i;
289 void Attributes::Builder::addAlignmentAttr(unsigned Align) {
290 if (Align == 0) return;
291 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
292 assert(Align <= 0x40000000 && "Alignment too large.");
293 Bits |= (Log2_32(Align) + 1) << 16;
295 void Attributes::Builder::addStackAlignmentAttr(unsigned Align) {
296 // Default alignment, allow the target to define how to align it.
297 if (Align == 0) return;
298 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
299 assert(Align <= 0x100 && "Alignment too large.");
300 Bits |= (Log2_32(Align) + 1) << 26;
303 void Attributes::Builder::removeAttributes(const Attributes &A) {
307 void Attributes::Builder::removeAddressSafetyAttr() {
308 Bits &= ~Attribute::AddressSafety_i;
310 void Attributes::Builder::removeAlwaysInlineAttr() {
311 Bits &= ~Attribute::AlwaysInline_i;
313 void Attributes::Builder::removeByValAttr() {
314 Bits &= ~Attribute::ByVal_i;
316 void Attributes::Builder::removeInlineHintAttr() {
317 Bits &= ~Attribute::InlineHint_i;
319 void Attributes::Builder::removeInRegAttr() {
320 Bits &= ~Attribute::InReg_i;
322 void Attributes::Builder::removeNakedAttr() {
323 Bits &= ~Attribute::Naked_i;
325 void Attributes::Builder::removeNestAttr() {
326 Bits &= ~Attribute::Nest_i;
328 void Attributes::Builder::removeNoAliasAttr() {
329 Bits &= ~Attribute::NoAlias_i;
331 void Attributes::Builder::removeNoCaptureAttr() {
332 Bits &= ~Attribute::NoCapture_i;
334 void Attributes::Builder::removeNoImplicitFloatAttr() {
335 Bits &= ~Attribute::NoImplicitFloat_i;
337 void Attributes::Builder::removeNoInlineAttr() {
338 Bits &= ~Attribute::NoInline_i;
340 void Attributes::Builder::removeNonLazyBindAttr() {
341 Bits &= ~Attribute::NonLazyBind_i;
343 void Attributes::Builder::removeNoRedZoneAttr() {
344 Bits &= ~Attribute::NoRedZone_i;
346 void Attributes::Builder::removeNoReturnAttr() {
347 Bits &= ~Attribute::NoReturn_i;
349 void Attributes::Builder::removeNoUnwindAttr() {
350 Bits &= ~Attribute::NoUnwind_i;
352 void Attributes::Builder::removeOptimizeForSizeAttr() {
353 Bits &= ~Attribute::OptimizeForSize_i;
355 void Attributes::Builder::removeReadNoneAttr() {
356 Bits &= ~Attribute::ReadNone_i;
358 void Attributes::Builder::removeReadOnlyAttr() {
359 Bits &= ~Attribute::ReadOnly_i;
361 void Attributes::Builder::removeReturnsTwiceAttr() {
362 Bits &= ~Attribute::ReturnsTwice_i;
364 void Attributes::Builder::removeSExtAttr() {
365 Bits &= ~Attribute::SExt_i;
367 void Attributes::Builder::removeStackProtectAttr() {
368 Bits &= ~Attribute::StackProtect_i;
370 void Attributes::Builder::removeStackProtectReqAttr() {
371 Bits &= ~Attribute::StackProtectReq_i;
373 void Attributes::Builder::removeStructRetAttr() {
374 Bits &= ~Attribute::StructRet_i;
376 void Attributes::Builder::removeUWTableAttr() {
377 Bits &= ~Attribute::UWTable_i;
379 void Attributes::Builder::removeZExtAttr() {
380 Bits &= ~Attribute::ZExt_i;
383 void Attributes::Builder::removeAlignmentAttr() {
384 Bits &= ~Attribute::Alignment_i;
386 void Attributes::Builder::removeStackAlignmentAttr() {
387 Bits &= ~Attribute::StackAlignment_i;
390 bool Attributes::Builder::hasAttributes() const {
393 bool Attributes::Builder::hasAttributes(const Attributes &A) const {
394 return Bits & A.Raw();
396 bool Attributes::Builder::hasAlignmentAttr() const {
397 return Bits & Attribute::Alignment_i;
400 uint64_t Attributes::Builder::getAlignment() const {
401 if (!hasAlignmentAttr())
403 return 1U << (((Bits & Attribute::Alignment_i) >> 16) - 1);
406 //===----------------------------------------------------------------------===//
407 // AttributeImpl Definition
408 //===----------------------------------------------------------------------===//
410 uint64_t AttributesImpl::getAttrMask(uint64_t Val) const {
412 case Attributes::None: return 0;
413 case Attributes::ZExt: return 1 << 0;
414 case Attributes::SExt: return 1 << 1;
415 case Attributes::NoReturn: return 1 << 2;
416 case Attributes::InReg: return 1 << 3;
417 case Attributes::StructRet: return 1 << 4;
418 case Attributes::NoUnwind: return 1 << 5;
419 case Attributes::NoAlias: return 1 << 6;
420 case Attributes::ByVal: return 1 << 7;
421 case Attributes::Nest: return 1 << 8;
422 case Attributes::ReadNone: return 1 << 9;
423 case Attributes::ReadOnly: return 1 << 10;
424 case Attributes::NoInline: return 1 << 11;
425 case Attributes::AlwaysInline: return 1 << 12;
426 case Attributes::OptimizeForSize: return 1 << 13;
427 case Attributes::StackProtect: return 1 << 14;
428 case Attributes::StackProtectReq: return 1 << 15;
429 case Attributes::Alignment: return 31 << 16;
430 case Attributes::NoCapture: return 1 << 21;
431 case Attributes::NoRedZone: return 1 << 22;
432 case Attributes::NoImplicitFloat: return 1 << 23;
433 case Attributes::Naked: return 1 << 24;
434 case Attributes::InlineHint: return 1 << 25;
435 case Attributes::StackAlignment: return 7 << 26;
436 case Attributes::ReturnsTwice: return 1 << 29;
437 case Attributes::UWTable: return 1 << 30;
438 case Attributes::NonLazyBind: return 1U << 31;
439 case Attributes::AddressSafety: return 1ULL << 32;
441 llvm_unreachable("Unsupported attribute type");
444 bool AttributesImpl::hasAttribute(uint64_t A) const {
445 return (Bits & getAttrMask(A)) != 0;
448 bool AttributesImpl::hasAttributes() const {
452 bool AttributesImpl::hasAttributes(const Attributes &A) const {
453 return Bits & A.Raw(); // FIXME: Raw() won't work here in the future.
456 uint64_t AttributesImpl::getAlignment() const {
457 return Bits & Attribute::Alignment_i;
460 uint64_t AttributesImpl::getStackAlignment() const {
461 return Bits & Attribute::StackAlignment_i;
464 bool AttributesImpl::isEmptyOrSingleton() const {
465 return (Bits & (Bits - 1)) == 0;
468 //===----------------------------------------------------------------------===//
469 // AttributeListImpl Definition
470 //===----------------------------------------------------------------------===//
473 class AttributeListImpl;
476 static ManagedStatic<FoldingSet<AttributeListImpl> > AttributesLists;
479 static ManagedStatic<sys::SmartMutex<true> > ALMutex;
481 class AttributeListImpl : public FoldingSetNode {
482 sys::cas_flag RefCount;
484 // AttributesList is uniqued, these should not be publicly available.
485 void operator=(const AttributeListImpl &) LLVM_DELETED_FUNCTION;
486 AttributeListImpl(const AttributeListImpl &) LLVM_DELETED_FUNCTION;
487 ~AttributeListImpl(); // Private implementation
489 SmallVector<AttributeWithIndex, 4> Attrs;
491 AttributeListImpl(ArrayRef<AttributeWithIndex> attrs)
492 : Attrs(attrs.begin(), attrs.end()) {
497 sys::SmartScopedLock<true> Lock(*ALMutex);
501 sys::SmartScopedLock<true> Lock(*ALMutex);
502 if (!AttributesLists.isConstructed())
504 sys::cas_flag new_val = --RefCount;
509 void Profile(FoldingSetNodeID &ID) const {
512 static void Profile(FoldingSetNodeID &ID, ArrayRef<AttributeWithIndex> Attrs){
513 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
514 ID.AddInteger(Attrs[i].Attrs.Raw());
515 ID.AddInteger(Attrs[i].Index);
521 AttributeListImpl::~AttributeListImpl() {
522 // NOTE: Lock must be acquired by caller.
523 AttributesLists->RemoveNode(this);
527 AttrListPtr AttrListPtr::get(ArrayRef<AttributeWithIndex> Attrs) {
528 // If there are no attributes then return a null AttributesList pointer.
530 return AttrListPtr();
533 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
534 assert(Attrs[i].Attrs.hasAttributes() &&
535 "Pointless attribute!");
536 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
537 "Misordered AttributesList!");
541 // Otherwise, build a key to look up the existing attributes.
543 AttributeListImpl::Profile(ID, Attrs);
546 sys::SmartScopedLock<true> Lock(*ALMutex);
548 AttributeListImpl *PAL =
549 AttributesLists->FindNodeOrInsertPos(ID, InsertPos);
551 // If we didn't find any existing attributes of the same shape then
552 // create a new one and insert it.
554 PAL = new AttributeListImpl(Attrs);
555 AttributesLists->InsertNode(PAL, InsertPos);
558 // Return the AttributesList that we found or created.
559 return AttrListPtr(PAL);
563 //===----------------------------------------------------------------------===//
564 // AttrListPtr Method Implementations
565 //===----------------------------------------------------------------------===//
567 AttrListPtr::AttrListPtr(AttributeListImpl *LI) : AttrList(LI) {
568 if (LI) LI->AddRef();
571 AttrListPtr::AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) {
572 if (AttrList) AttrList->AddRef();
575 const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) {
576 sys::SmartScopedLock<true> Lock(*ALMutex);
577 if (AttrList == RHS.AttrList) return *this;
578 if (AttrList) AttrList->DropRef();
579 AttrList = RHS.AttrList;
580 if (AttrList) AttrList->AddRef();
584 AttrListPtr::~AttrListPtr() {
585 if (AttrList) AttrList->DropRef();
588 /// getNumSlots - Return the number of slots used in this attribute list.
589 /// This is the number of arguments that have an attribute set on them
590 /// (including the function itself).
591 unsigned AttrListPtr::getNumSlots() const {
592 return AttrList ? AttrList->Attrs.size() : 0;
595 /// getSlot - Return the AttributeWithIndex at the specified slot. This
596 /// holds a number plus a set of attributes.
597 const AttributeWithIndex &AttrListPtr::getSlot(unsigned Slot) const {
598 assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!");
599 return AttrList->Attrs[Slot];
603 /// getAttributes - The attributes for the specified index are
604 /// returned. Attributes for the result are denoted with Idx = 0.
605 /// Function notes are denoted with idx = ~0.
606 Attributes AttrListPtr::getAttributes(unsigned Idx) const {
607 if (AttrList == 0) return Attributes();
609 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
610 for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
611 if (Attrs[i].Index == Idx)
612 return Attrs[i].Attrs;
617 /// hasAttrSomewhere - Return true if the specified attribute is set for at
618 /// least one parameter or for the return value.
619 bool AttrListPtr::hasAttrSomewhere(Attributes Attr) const {
620 if (AttrList == 0) return false;
622 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
623 for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
624 if (Attrs[i].Attrs.hasAttributes(Attr))
629 unsigned AttrListPtr::getNumAttrs() const {
630 return AttrList ? AttrList->Attrs.size() : 0;
633 Attributes &AttrListPtr::getAttributesAtIndex(unsigned i) const {
634 assert(AttrList && "Trying to get an attribute from an empty list!");
635 assert(i < AttrList->Attrs.size() && "Index out of range!");
636 return AttrList->Attrs[i].Attrs;
639 AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
640 Attributes OldAttrs = getAttributes(Idx);
642 // FIXME it is not obvious how this should work for alignment.
643 // For now, say we can't change a known alignment.
644 unsigned OldAlign = OldAttrs.getAlignment();
645 unsigned NewAlign = Attrs.getAlignment();
646 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
647 "Attempt to change alignment!");
650 Attributes NewAttrs = OldAttrs | Attrs;
651 if (NewAttrs == OldAttrs)
654 SmallVector<AttributeWithIndex, 8> NewAttrList;
656 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
658 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
659 unsigned i = 0, e = OldAttrList.size();
660 // Copy attributes for arguments before this one.
661 for (; i != e && OldAttrList[i].Index < Idx; ++i)
662 NewAttrList.push_back(OldAttrList[i]);
664 // If there are attributes already at this index, merge them in.
665 if (i != e && OldAttrList[i].Index == Idx) {
666 Attrs |= OldAttrList[i].Attrs;
670 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
672 // Copy attributes for arguments after this one.
673 NewAttrList.insert(NewAttrList.end(),
674 OldAttrList.begin()+i, OldAttrList.end());
677 return get(NewAttrList);
680 AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
682 // FIXME it is not obvious how this should work for alignment.
683 // For now, say we can't pass in alignment, which no current use does.
684 assert(!Attrs.hasAttribute(Attributes::Alignment) &&
685 "Attempt to exclude alignment!");
687 if (AttrList == 0) return AttrListPtr();
689 Attributes OldAttrs = getAttributes(Idx);
690 Attributes NewAttrs = OldAttrs & ~Attrs;
691 if (NewAttrs == OldAttrs)
694 SmallVector<AttributeWithIndex, 8> NewAttrList;
695 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
696 unsigned i = 0, e = OldAttrList.size();
698 // Copy attributes for arguments before this one.
699 for (; i != e && OldAttrList[i].Index < Idx; ++i)
700 NewAttrList.push_back(OldAttrList[i]);
702 // If there are attributes already at this index, merge them in.
703 assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
704 Attrs = OldAttrList[i].Attrs & ~Attrs;
706 if (Attrs) // If any attributes left for this parameter, add them.
707 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
709 // Copy attributes for arguments after this one.
710 NewAttrList.insert(NewAttrList.end(),
711 OldAttrList.begin()+i, OldAttrList.end());
713 return get(NewAttrList);
716 void AttrListPtr::dump() const {
718 for (unsigned i = 0; i < getNumSlots(); ++i) {
719 const AttributeWithIndex &PAWI = getSlot(i);
720 dbgs() << "{" << PAWI.Index << "," << PAWI.Attrs << "} ";