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 // FIXME: Don't look up ConstantInts here.
49 ID.AddPointer(ConstantInt::get(Type::getInt64Ty(Context), B.getBitMask()));
52 AttributeImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
55 // If we didn't find any existing attributes of the same shape then create a
56 // new one and insert it.
57 PA = new AttributeImpl(Context, B.getBitMask());
58 pImpl->AttrsSet.InsertNode(PA, InsertPoint);
61 // Return the AttributesList that we found or created.
65 bool Attribute::hasAttribute(AttrKind Val) const {
66 return pImpl && pImpl->hasAttribute(Val);
69 bool Attribute::hasAttributes() const {
70 return pImpl && pImpl->hasAttributes();
73 /// This returns the alignment field of an attribute as a byte alignment value.
74 unsigned Attribute::getAlignment() const {
75 if (!hasAttribute(Attribute::Alignment))
77 return 1U << ((pImpl->getAlignment() >> 16) - 1);
80 void Attribute::setAlignment(unsigned Align) {
81 assert(hasAttribute(Attribute::Alignment) &&
82 "Trying to set the alignment on a non-alignment attribute!");
83 pImpl->setAlignment(Align);
86 /// This returns the stack alignment field of an attribute as a byte alignment
88 unsigned Attribute::getStackAlignment() const {
89 if (!hasAttribute(Attribute::StackAlignment))
91 return 1U << ((pImpl->getStackAlignment() >> 26) - 1);
94 void Attribute::setStackAlignment(unsigned Align) {
95 assert(hasAttribute(Attribute::StackAlignment) &&
96 "Trying to set the stack alignment on a non-alignment attribute!");
97 pImpl->setStackAlignment(Align);
100 bool Attribute::operator==(AttrKind K) const {
101 return pImpl && *pImpl == K;
103 bool Attribute::operator!=(AttrKind K) const {
104 return !(*this == K);
107 uint64_t Attribute::getBitMask() const {
108 return pImpl ? pImpl->getBitMask() : 0;
111 Attribute Attribute::typeIncompatible(Type *Ty) {
112 AttrBuilder Incompatible;
114 if (!Ty->isIntegerTy())
115 // Attribute that only apply to integers.
116 Incompatible.addAttribute(Attribute::SExt)
117 .addAttribute(Attribute::ZExt);
119 if (!Ty->isPointerTy())
120 // Attribute that only apply to pointers.
121 Incompatible.addAttribute(Attribute::ByVal)
122 .addAttribute(Attribute::Nest)
123 .addAttribute(Attribute::NoAlias)
124 .addAttribute(Attribute::NoCapture)
125 .addAttribute(Attribute::StructRet);
127 return Attribute::get(Ty->getContext(), Incompatible);
130 /// encodeLLVMAttributesForBitcode - This returns an integer containing an
131 /// encoding of all the LLVM attributes found in the given attribute bitset.
132 /// Any change to this encoding is a breaking change to bitcode compatibility.
133 uint64_t Attribute::encodeLLVMAttributesForBitcode(Attribute Attrs) {
134 // FIXME: It doesn't make sense to store the alignment information as an
135 // expanded out value, we should store it as a log2 value. However, we can't
136 // just change that here without breaking bitcode compatibility. If this ever
137 // becomes a problem in practice, we should introduce new tag numbers in the
138 // bitcode file and have those tags use a more efficiently encoded alignment
141 // Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit
142 // log2 encoded value. Shift the bits above the alignment up by 11 bits.
143 uint64_t EncodedAttrs = Attrs.getBitMask() & 0xffff;
144 if (Attrs.hasAttribute(Attribute::Alignment))
145 EncodedAttrs |= Attrs.getAlignment() << 16;
146 EncodedAttrs |= (Attrs.getBitMask() & (0xffffULL << 21)) << 11;
150 /// decodeLLVMAttributesForBitcode - This returns an attribute bitset containing
151 /// the LLVM attributes that have been decoded from the given integer. This
152 /// function must stay in sync with 'encodeLLVMAttributesForBitcode'.
153 Attribute Attribute::decodeLLVMAttributesForBitcode(LLVMContext &C,
154 uint64_t EncodedAttrs) {
155 // The alignment is stored as a 16-bit raw value from bits 31--16. We shift
156 // the bits above 31 down by 11 bits.
157 unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
158 assert((!Alignment || isPowerOf2_32(Alignment)) &&
159 "Alignment must be a power of two.");
161 AttrBuilder B(EncodedAttrs & 0xffff);
163 B.addAlignmentAttr(Alignment);
164 B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
165 return Attribute::get(C, B);
168 std::string Attribute::getAsString() const {
170 if (hasAttribute(Attribute::ZExt))
171 Result += "zeroext ";
172 if (hasAttribute(Attribute::SExt))
173 Result += "signext ";
174 if (hasAttribute(Attribute::NoReturn))
175 Result += "noreturn ";
176 if (hasAttribute(Attribute::NoUnwind))
177 Result += "nounwind ";
178 if (hasAttribute(Attribute::UWTable))
179 Result += "uwtable ";
180 if (hasAttribute(Attribute::ReturnsTwice))
181 Result += "returns_twice ";
182 if (hasAttribute(Attribute::InReg))
184 if (hasAttribute(Attribute::NoAlias))
185 Result += "noalias ";
186 if (hasAttribute(Attribute::NoCapture))
187 Result += "nocapture ";
188 if (hasAttribute(Attribute::StructRet))
190 if (hasAttribute(Attribute::ByVal))
192 if (hasAttribute(Attribute::Nest))
194 if (hasAttribute(Attribute::ReadNone))
195 Result += "readnone ";
196 if (hasAttribute(Attribute::ReadOnly))
197 Result += "readonly ";
198 if (hasAttribute(Attribute::OptimizeForSize))
199 Result += "optsize ";
200 if (hasAttribute(Attribute::NoInline))
201 Result += "noinline ";
202 if (hasAttribute(Attribute::InlineHint))
203 Result += "inlinehint ";
204 if (hasAttribute(Attribute::AlwaysInline))
205 Result += "alwaysinline ";
206 if (hasAttribute(Attribute::StackProtect))
208 if (hasAttribute(Attribute::StackProtectReq))
210 if (hasAttribute(Attribute::NoRedZone))
211 Result += "noredzone ";
212 if (hasAttribute(Attribute::NoImplicitFloat))
213 Result += "noimplicitfloat ";
214 if (hasAttribute(Attribute::Naked))
216 if (hasAttribute(Attribute::NonLazyBind))
217 Result += "nonlazybind ";
218 if (hasAttribute(Attribute::AddressSafety))
219 Result += "address_safety ";
220 if (hasAttribute(Attribute::MinSize))
221 Result += "minsize ";
222 if (hasAttribute(Attribute::StackAlignment)) {
223 Result += "alignstack(";
224 Result += utostr(getStackAlignment());
227 if (hasAttribute(Attribute::Alignment)) {
229 Result += utostr(getAlignment());
232 if (hasAttribute(Attribute::NoDuplicate))
233 Result += "noduplicate ";
234 // Trim the trailing space.
235 assert(!Result.empty() && "Unknown attribute!");
236 Result.erase(Result.end()-1);
240 //===----------------------------------------------------------------------===//
241 // AttrBuilder Method Implementations
242 //===----------------------------------------------------------------------===//
244 void AttrBuilder::clear() {
246 Alignment = StackAlignment = 0;
249 AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val) {
254 AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
256 if (Val == Attribute::Alignment)
258 else if (Val == Attribute::StackAlignment)
264 AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) {
265 if (Align == 0) return *this;
267 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
268 assert(Align <= 0x40000000 && "Alignment too large.");
270 Attrs.insert(Attribute::Alignment);
275 AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align) {
276 // Default alignment, allow the target to define how to align it.
277 if (Align == 0) return *this;
279 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
280 assert(Align <= 0x100 && "Alignment too large.");
282 Attrs.insert(Attribute::StackAlignment);
283 StackAlignment = Align;
287 AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
288 for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
289 I = Attribute::AttrKind(I + 1)) {
290 if (uint64_t A = (Val & AttributeImpl::getAttrMask(I))) {
293 if (I == Attribute::Alignment)
294 Alignment = 1ULL << ((A >> 16) - 1);
295 else if (I == Attribute::StackAlignment)
296 StackAlignment = 1ULL << ((A >> 26)-1);
303 AttrBuilder &AttrBuilder::addAttributes(const Attribute &A) {
304 uint64_t Mask = A.getBitMask();
306 for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
307 I = Attribute::AttrKind(I + 1)) {
308 if (uint64_t A = (Mask & AttributeImpl::getAttrMask(I))) {
311 if (I == Attribute::Alignment)
312 Alignment = 1ULL << ((A >> 16) - 1);
313 else if (I == Attribute::StackAlignment)
314 StackAlignment = 1ULL << ((A >> 26)-1);
321 AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){
322 uint64_t Mask = A.getBitMask();
324 for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
325 I = Attribute::AttrKind(I + 1)) {
326 if (Mask & AttributeImpl::getAttrMask(I)) {
329 if (I == Attribute::Alignment)
331 else if (I == Attribute::StackAlignment)
339 bool AttrBuilder::contains(Attribute::AttrKind A) const {
340 return Attrs.count(A);
343 bool AttrBuilder::hasAttributes() const {
344 return !Attrs.empty();
347 bool AttrBuilder::hasAttributes(const Attribute &A) const {
348 return getBitMask() & A.getBitMask();
351 bool AttrBuilder::hasAlignmentAttr() const {
352 return Alignment != 0;
355 uint64_t AttrBuilder::getBitMask() const {
358 for (DenseSet<Attribute::AttrKind>::const_iterator I = Attrs.begin(),
359 E = Attrs.end(); I != E; ++I) {
360 Attribute::AttrKind Kind = *I;
362 if (Kind == Attribute::Alignment)
363 Mask |= (Log2_32(Alignment) + 1) << 16;
364 else if (Kind == Attribute::StackAlignment)
365 Mask |= (Log2_32(StackAlignment) + 1) << 26;
367 Mask |= AttributeImpl::getAttrMask(Kind);
373 bool AttrBuilder::operator==(const AttrBuilder &B) {
374 SmallVector<Attribute::AttrKind, 8> This(Attrs.begin(), Attrs.end());
375 SmallVector<Attribute::AttrKind, 8> That(B.Attrs.begin(), B.Attrs.end());
379 //===----------------------------------------------------------------------===//
380 // AttributeImpl Definition
381 //===----------------------------------------------------------------------===//
383 AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data)
385 Data = ConstantInt::get(Type::getInt64Ty(C), data);
387 AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data)
389 Data = ConstantInt::get(Type::getInt64Ty(C), data);
391 AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data,
392 ArrayRef<Constant*> values)
394 Data = ConstantInt::get(Type::getInt64Ty(C), data);
395 Vals.reserve(values.size());
396 Vals.append(values.begin(), values.end());
398 AttributeImpl::AttributeImpl(LLVMContext &C, StringRef data)
400 Data = ConstantDataArray::getString(C, data);
403 bool AttributeImpl::operator==(Attribute::AttrKind Kind) const {
404 if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))
405 return CI->getZExtValue() == Kind;
408 bool AttributeImpl::operator!=(Attribute::AttrKind Kind) const {
409 return !(*this == Kind);
412 bool AttributeImpl::operator==(StringRef Kind) const {
413 if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data))
415 return CDA->getAsString() == Kind;
418 bool AttributeImpl::operator!=(StringRef Kind) const {
419 return !(*this == Kind);
422 uint64_t AttributeImpl::getBitMask() const {
423 // FIXME: Remove this.
424 return cast<ConstantInt>(Data)->getZExtValue();
427 uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {
429 case Attribute::EndAttrKinds:
430 case Attribute::AttrKindEmptyKey:
431 case Attribute::AttrKindTombstoneKey:
432 llvm_unreachable("Synthetic enumerators which should never get here");
434 case Attribute::None: return 0;
435 case Attribute::ZExt: return 1 << 0;
436 case Attribute::SExt: return 1 << 1;
437 case Attribute::NoReturn: return 1 << 2;
438 case Attribute::InReg: return 1 << 3;
439 case Attribute::StructRet: return 1 << 4;
440 case Attribute::NoUnwind: return 1 << 5;
441 case Attribute::NoAlias: return 1 << 6;
442 case Attribute::ByVal: return 1 << 7;
443 case Attribute::Nest: return 1 << 8;
444 case Attribute::ReadNone: return 1 << 9;
445 case Attribute::ReadOnly: return 1 << 10;
446 case Attribute::NoInline: return 1 << 11;
447 case Attribute::AlwaysInline: return 1 << 12;
448 case Attribute::OptimizeForSize: return 1 << 13;
449 case Attribute::StackProtect: return 1 << 14;
450 case Attribute::StackProtectReq: return 1 << 15;
451 case Attribute::Alignment: return 31 << 16;
452 case Attribute::NoCapture: return 1 << 21;
453 case Attribute::NoRedZone: return 1 << 22;
454 case Attribute::NoImplicitFloat: return 1 << 23;
455 case Attribute::Naked: return 1 << 24;
456 case Attribute::InlineHint: return 1 << 25;
457 case Attribute::StackAlignment: return 7 << 26;
458 case Attribute::ReturnsTwice: return 1 << 29;
459 case Attribute::UWTable: return 1 << 30;
460 case Attribute::NonLazyBind: return 1U << 31;
461 case Attribute::AddressSafety: return 1ULL << 32;
462 case Attribute::MinSize: return 1ULL << 33;
463 case Attribute::NoDuplicate: return 1ULL << 34;
465 llvm_unreachable("Unsupported attribute type");
468 bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
469 return (getBitMask() & getAttrMask(A)) != 0;
472 bool AttributeImpl::hasAttributes() const {
473 return getBitMask() != 0;
476 uint64_t AttributeImpl::getAlignment() const {
477 return getBitMask() & getAttrMask(Attribute::Alignment);
480 void AttributeImpl::setAlignment(unsigned Align) {
481 Vals.push_back(ConstantInt::get(Type::getInt64Ty(Context), Align));
484 uint64_t AttributeImpl::getStackAlignment() const {
485 return getBitMask() & getAttrMask(Attribute::StackAlignment);
488 void AttributeImpl::setStackAlignment(unsigned Align) {
489 Vals.push_back(ConstantInt::get(Type::getInt64Ty(Context), Align));
492 //===----------------------------------------------------------------------===//
493 // AttributeSetImpl Definition
494 //===----------------------------------------------------------------------===//
496 AttributeSet AttributeSet::get(LLVMContext &C,
497 ArrayRef<AttributeWithIndex> Attrs) {
498 // If there are no attributes then return a null AttributesList pointer.
500 return AttributeSet();
503 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
504 assert(Attrs[i].Attrs.hasAttributes() &&
505 "Pointless attribute!");
506 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
507 "Misordered AttributesList!");
511 // Otherwise, build a key to look up the existing attributes.
512 LLVMContextImpl *pImpl = C.pImpl;
514 AttributeSetImpl::Profile(ID, Attrs);
517 AttributeSetImpl *PA = pImpl->AttrsLists.FindNodeOrInsertPos(ID, InsertPoint);
519 // If we didn't find any existing attributes of the same shape then
520 // create a new one and insert it.
522 PA = new AttributeSetImpl(C, Attrs);
523 pImpl->AttrsLists.InsertNode(PA, InsertPoint);
526 // Return the AttributesList that we found or created.
527 return AttributeSet(PA);
530 AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx, AttrBuilder &B) {
531 SmallVector<AttributeWithIndex, 8> Attrs;
532 for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I) {
533 Attribute::AttrKind Kind = *I;
534 Attribute A = Attribute::get(C, Kind);
536 if (Kind == Attribute::Alignment)
537 A.setAlignment(B.getAlignment());
538 else if (Kind == Attribute::StackAlignment)
539 A.setStackAlignment(B.getStackAlignment());
541 Attrs.push_back(AttributeWithIndex::get(Idx, A));
544 return get(C, Attrs);
547 //===----------------------------------------------------------------------===//
548 // AttributeSet Method Implementations
549 //===----------------------------------------------------------------------===//
551 const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) {
552 AttrList = RHS.AttrList;
556 /// getNumSlots - Return the number of slots used in this attribute list.
557 /// This is the number of arguments that have an attribute set on them
558 /// (including the function itself).
559 unsigned AttributeSet::getNumSlots() const {
560 return AttrList ? AttrList->getNumAttributes() : 0;
563 /// getSlot - Return the AttributeWithIndex at the specified slot. This
564 /// holds a number plus a set of attributes.
565 const AttributeWithIndex &AttributeSet::getSlot(unsigned Slot) const {
566 assert(AttrList && Slot < AttrList->getNumAttributes() &&
567 "Slot # out of range!");
568 return AttrList->getAttributes()[Slot];
571 bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{
572 return getAttributes(Index).hasAttribute(Kind);
575 bool AttributeSet::hasAttributes(unsigned Index) const {
576 return getAttributes(Index).hasAttributes();
579 std::string AttributeSet::getAsString(unsigned Index) const {
580 return getAttributes(Index).getAsString();
583 unsigned AttributeSet::getStackAlignment(unsigned Index) const {
584 return getAttributes(Index).getStackAlignment();
587 uint64_t AttributeSet::getBitMask(unsigned Index) const {
588 // FIXME: Remove this.
589 return getAttributes(Index).getBitMask();
592 /// getAttributes - The attributes for the specified index are returned.
593 /// Attributes for the result are denoted with Idx = 0. Function attributes are
594 /// denoted with Idx = ~0.
595 Attribute AttributeSet::getAttributes(unsigned Idx) const {
596 if (AttrList == 0) return Attribute();
598 ArrayRef<AttributeWithIndex> Attrs = AttrList->getAttributes();
599 for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
600 if (Attrs[i].Index == Idx)
601 return Attrs[i].Attrs;
606 /// hasAttrSomewhere - Return true if the specified attribute is set for at
607 /// least one parameter or for the return value.
608 bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
609 if (AttrList == 0) return false;
611 ArrayRef<AttributeWithIndex> Attrs = AttrList->getAttributes();
612 for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
613 if (Attrs[i].Attrs.hasAttribute(Attr))
619 AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
620 Attribute Attrs) const {
621 Attribute OldAttrs = getAttributes(Idx);
623 // FIXME it is not obvious how this should work for alignment.
624 // For now, say we can't change a known alignment.
625 unsigned OldAlign = OldAttrs.getAlignment();
626 unsigned NewAlign = Attrs.getAlignment();
627 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
628 "Attempt to change alignment!");
631 AttrBuilder NewAttrs =
632 AttrBuilder(OldAttrs).addAttributes(Attrs);
633 if (NewAttrs == AttrBuilder(OldAttrs))
636 SmallVector<AttributeWithIndex, 8> NewAttrList;
638 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
640 ArrayRef<AttributeWithIndex> OldAttrList = AttrList->getAttributes();
641 unsigned i = 0, e = OldAttrList.size();
642 // Copy attributes for arguments before this one.
643 for (; i != e && OldAttrList[i].Index < Idx; ++i)
644 NewAttrList.push_back(OldAttrList[i]);
646 // If there are attributes already at this index, merge them in.
647 if (i != e && OldAttrList[i].Index == Idx) {
649 Attribute::get(C, AttrBuilder(Attrs).
650 addAttributes(OldAttrList[i].Attrs));
654 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
656 // Copy attributes for arguments after this one.
657 NewAttrList.insert(NewAttrList.end(),
658 OldAttrList.begin()+i, OldAttrList.end());
661 return get(C, NewAttrList);
664 AttributeSet AttributeSet::removeAttr(LLVMContext &C, unsigned Idx,
665 Attribute Attrs) const {
667 // FIXME it is not obvious how this should work for alignment.
668 // For now, say we can't pass in alignment, which no current use does.
669 assert(!Attrs.hasAttribute(Attribute::Alignment) &&
670 "Attempt to exclude alignment!");
672 if (AttrList == 0) return AttributeSet();
674 Attribute OldAttrs = getAttributes(Idx);
675 AttrBuilder NewAttrs =
676 AttrBuilder(OldAttrs).removeAttributes(Attrs);
677 if (NewAttrs == AttrBuilder(OldAttrs))
680 SmallVector<AttributeWithIndex, 8> NewAttrList;
681 ArrayRef<AttributeWithIndex> OldAttrList = AttrList->getAttributes();
682 unsigned i = 0, e = OldAttrList.size();
684 // Copy attributes for arguments before this one.
685 for (; i != e && OldAttrList[i].Index < Idx; ++i)
686 NewAttrList.push_back(OldAttrList[i]);
688 // If there are attributes already at this index, merge them in.
689 assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
690 Attrs = Attribute::get(C, AttrBuilder(OldAttrList[i].Attrs).
691 removeAttributes(Attrs));
693 if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
694 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
696 // Copy attributes for arguments after this one.
697 NewAttrList.insert(NewAttrList.end(),
698 OldAttrList.begin()+i, OldAttrList.end());
700 return get(C, NewAttrList);
703 void AttributeSet::dump() const {
705 for (unsigned i = 0; i < getNumSlots(); ++i) {
706 const AttributeWithIndex &PAWI = getSlot(i);
707 dbgs() << "{ " << PAWI.Index << ", " << PAWI.Attrs.getAsString() << " } ";