blob: 6fa597e9587cc3381800f51aafde23dbf290e4d0 [file] [log] [blame]
Devang Patel4c758ea2008-09-25 21:00:45 +00001//===-- Attributes.cpp - Implement AttributesList -------------------------===//
Chris Lattner3e13b8c2008-01-02 23:42:30 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Devang Patel4c758ea2008-09-25 21:00:45 +000010// This file implements the AttributesList class and Attribute utilities.
Chris Lattner3e13b8c2008-01-02 23:42:30 +000011//
12//===----------------------------------------------------------------------===//
13
Devang Patelba3fa6c2008-09-23 23:03:40 +000014#include "llvm/Attributes.h"
Chris Lattner8a923e72008-03-12 17:45:29 +000015#include "llvm/Type.h"
Dan Gohmanfc429612008-03-10 23:55:07 +000016#include "llvm/ADT/StringExtras.h"
Chris Lattner8a923e72008-03-12 17:45:29 +000017#include "llvm/ADT/FoldingSet.h"
Owen Andersonc1a3a472009-08-20 19:03:20 +000018#include "llvm/System/Atomic.h"
Owen Andersond91e6b02009-08-17 17:10:58 +000019#include "llvm/System/Mutex.h"
David Greenef7014732010-01-05 01:29:58 +000020#include "llvm/Support/Debug.h"
Chris Lattner3e13b8c2008-01-02 23:42:30 +000021#include "llvm/Support/ManagedStatic.h"
Benjamin Kramer1a25d732009-08-23 11:37:21 +000022#include "llvm/Support/raw_ostream.h"
Chris Lattner3e13b8c2008-01-02 23:42:30 +000023using namespace llvm;
24
Chris Lattner8a923e72008-03-12 17:45:29 +000025//===----------------------------------------------------------------------===//
Devang Patel4c758ea2008-09-25 21:00:45 +000026// Attribute Function Definitions
Chris Lattner8a923e72008-03-12 17:45:29 +000027//===----------------------------------------------------------------------===//
Chris Lattnerd0e1f102008-01-03 00:10:22 +000028
Devang Patel4c758ea2008-09-25 21:00:45 +000029std::string Attribute::getAsString(Attributes Attrs) {
Chris Lattner3e13b8c2008-01-02 23:42:30 +000030 std::string Result;
Devang Patel4c758ea2008-09-25 21:00:45 +000031 if (Attrs & Attribute::ZExt)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000032 Result += "zeroext ";
Devang Patel4c758ea2008-09-25 21:00:45 +000033 if (Attrs & Attribute::SExt)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000034 Result += "signext ";
Devang Patel4c758ea2008-09-25 21:00:45 +000035 if (Attrs & Attribute::NoReturn)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000036 Result += "noreturn ";
Devang Patel4c758ea2008-09-25 21:00:45 +000037 if (Attrs & Attribute::NoUnwind)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000038 Result += "nounwind ";
Devang Patel4c758ea2008-09-25 21:00:45 +000039 if (Attrs & Attribute::InReg)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000040 Result += "inreg ";
Devang Patel4c758ea2008-09-25 21:00:45 +000041 if (Attrs & Attribute::NoAlias)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000042 Result += "noalias ";
Nick Lewycky8d69f482008-12-19 09:38:31 +000043 if (Attrs & Attribute::NoCapture)
44 Result += "nocapture ";
Devang Patel4c758ea2008-09-25 21:00:45 +000045 if (Attrs & Attribute::StructRet)
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +000046 Result += "sret ";
Devang Patel4c758ea2008-09-25 21:00:45 +000047 if (Attrs & Attribute::ByVal)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000048 Result += "byval ";
Devang Patel4c758ea2008-09-25 21:00:45 +000049 if (Attrs & Attribute::Nest)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000050 Result += "nest ";
Devang Patel4c758ea2008-09-25 21:00:45 +000051 if (Attrs & Attribute::ReadNone)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000052 Result += "readnone ";
Devang Patel4c758ea2008-09-25 21:00:45 +000053 if (Attrs & Attribute::ReadOnly)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000054 Result += "readonly ";
Devang Patela05633e2008-09-26 22:53:05 +000055 if (Attrs & Attribute::OptimizeForSize)
56 Result += "optsize ";
57 if (Attrs & Attribute::NoInline)
58 Result += "noinline ";
Jakob Stoklund Olesen74bb06c2010-02-06 01:16:28 +000059 if (Attrs & Attribute::InlineHint)
60 Result += "inlinehint ";
Devang Patela05633e2008-09-26 22:53:05 +000061 if (Attrs & Attribute::AlwaysInline)
62 Result += "alwaysinline ";
Bill Wendlingccb67a3d2008-11-13 01:02:14 +000063 if (Attrs & Attribute::StackProtect)
64 Result += "ssp ";
65 if (Attrs & Attribute::StackProtectReq)
66 Result += "sspreq ";
Devang Patel72a4d2f2009-06-04 22:05:33 +000067 if (Attrs & Attribute::NoRedZone)
68 Result += "noredzone ";
Devang Pateld1c7d342009-06-05 21:57:13 +000069 if (Attrs & Attribute::NoImplicitFloat)
70 Result += "noimplicitfloat ";
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +000071 if (Attrs & Attribute::Naked)
72 Result += "naked ";
Charles Davisbe5557e2010-02-12 00:31:15 +000073 if (Attrs & Attribute::StackAlignment) {
74 Result += "alignstack(";
75 Result += utostr(Attribute::getStackAlignmentFromAttrs(Attrs));
76 Result += ") ";
77 }
Devang Patel4c758ea2008-09-25 21:00:45 +000078 if (Attrs & Attribute::Alignment) {
Dale Johannesen11a555e2008-02-19 23:51:49 +000079 Result += "align ";
Nick Lewycky93787d12009-01-11 17:02:06 +000080 Result += utostr(Attribute::getAlignmentFromAttrs(Attrs));
Dale Johannesen11a555e2008-02-19 23:51:49 +000081 Result += " ";
82 }
Dan Gohman1a70bcc2008-08-05 15:51:44 +000083 // Trim the trailing space.
Nick Lewycky8d69f482008-12-19 09:38:31 +000084 assert(!Result.empty() && "Unknown attribute!");
Dan Gohman1a70bcc2008-08-05 15:51:44 +000085 Result.erase(Result.end()-1);
Chris Lattner3e13b8c2008-01-02 23:42:30 +000086 return Result;
87}
88
Devang Patel4c758ea2008-09-25 21:00:45 +000089Attributes Attribute::typeIncompatible(const Type *Ty) {
Devang Patelba3fa6c2008-09-23 23:03:40 +000090 Attributes Incompatible = None;
Chris Lattner8a923e72008-03-12 17:45:29 +000091
92 if (!Ty->isInteger())
93 // Attributes that only apply to integers.
94 Incompatible |= SExt | ZExt;
95
96 if (!isa<PointerType>(Ty))
97 // Attributes that only apply to pointers.
Nick Lewycky8d69f482008-12-19 09:38:31 +000098 Incompatible |= ByVal | Nest | NoAlias | StructRet | NoCapture;
Chris Lattner8a923e72008-03-12 17:45:29 +000099
100 return Incompatible;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000101}
102
Chris Lattner8a923e72008-03-12 17:45:29 +0000103//===----------------------------------------------------------------------===//
Devang Patel00095052008-09-24 00:29:49 +0000104// AttributeListImpl Definition
Chris Lattner8a923e72008-03-12 17:45:29 +0000105//===----------------------------------------------------------------------===//
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000106
Chris Lattner8a923e72008-03-12 17:45:29 +0000107namespace llvm {
Devang Patel00095052008-09-24 00:29:49 +0000108class AttributeListImpl : public FoldingSetNode {
Owen Andersonc1a3a472009-08-20 19:03:20 +0000109 sys::cas_flag RefCount;
Chris Lattner8a923e72008-03-12 17:45:29 +0000110
Devang Patel4c758ea2008-09-25 21:00:45 +0000111 // AttributesList is uniqued, these should not be publicly available.
Devang Patel00095052008-09-24 00:29:49 +0000112 void operator=(const AttributeListImpl &); // Do not implement
113 AttributeListImpl(const AttributeListImpl &); // Do not implement
114 ~AttributeListImpl(); // Private implementation
Chris Lattner8a923e72008-03-12 17:45:29 +0000115public:
Devang Patel4c758ea2008-09-25 21:00:45 +0000116 SmallVector<AttributeWithIndex, 4> Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000117
Devang Patel4c758ea2008-09-25 21:00:45 +0000118 AttributeListImpl(const AttributeWithIndex *Attr, unsigned NumAttrs)
Chris Lattner8a923e72008-03-12 17:45:29 +0000119 : Attrs(Attr, Attr+NumAttrs) {
120 RefCount = 0;
121 }
122
Owen Andersonc1a3a472009-08-20 19:03:20 +0000123 void AddRef() { sys::AtomicIncrement(&RefCount); }
124 void DropRef() {
125 sys::cas_flag old = sys::AtomicDecrement(&RefCount);
126 if (old == 0) delete this;
127 }
Chris Lattner8a923e72008-03-12 17:45:29 +0000128
129 void Profile(FoldingSetNodeID &ID) const {
Jay Foad7d0479f2009-05-21 09:52:38 +0000130 Profile(ID, Attrs.data(), Attrs.size());
Chris Lattner8a923e72008-03-12 17:45:29 +0000131 }
Devang Patel4c758ea2008-09-25 21:00:45 +0000132 static void Profile(FoldingSetNodeID &ID, const AttributeWithIndex *Attr,
Chris Lattner8a923e72008-03-12 17:45:29 +0000133 unsigned NumAttrs) {
134 for (unsigned i = 0; i != NumAttrs; ++i)
135 ID.AddInteger(uint64_t(Attr[i].Attrs) << 32 | unsigned(Attr[i].Index));
136 }
137};
138}
139
Owen Andersond91e6b02009-08-17 17:10:58 +0000140static ManagedStatic<sys::SmartMutex<true> > ALMutex;
Devang Patel4c758ea2008-09-25 21:00:45 +0000141static ManagedStatic<FoldingSet<AttributeListImpl> > AttributesLists;
Chris Lattner8a923e72008-03-12 17:45:29 +0000142
Devang Patel00095052008-09-24 00:29:49 +0000143AttributeListImpl::~AttributeListImpl() {
Owen Andersond91e6b02009-08-17 17:10:58 +0000144 sys::SmartScopedLock<true> Lock(*ALMutex);
Devang Patel4c758ea2008-09-25 21:00:45 +0000145 AttributesLists->RemoveNode(this);
Chris Lattner8a923e72008-03-12 17:45:29 +0000146}
147
148
Devang Patel4c758ea2008-09-25 21:00:45 +0000149AttrListPtr AttrListPtr::get(const AttributeWithIndex *Attrs, unsigned NumAttrs) {
150 // If there are no attributes then return a null AttributesList pointer.
Chris Lattner8a923e72008-03-12 17:45:29 +0000151 if (NumAttrs == 0)
Devang Patel4c758ea2008-09-25 21:00:45 +0000152 return AttrListPtr();
Chris Lattner8a923e72008-03-12 17:45:29 +0000153
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000154#ifndef NDEBUG
Chris Lattner8a923e72008-03-12 17:45:29 +0000155 for (unsigned i = 0; i != NumAttrs; ++i) {
Devang Patel4c758ea2008-09-25 21:00:45 +0000156 assert(Attrs[i].Attrs != Attribute::None &&
157 "Pointless attribute!");
Chris Lattner8a923e72008-03-12 17:45:29 +0000158 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
Devang Patel4c758ea2008-09-25 21:00:45 +0000159 "Misordered AttributesList!");
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000160 }
161#endif
Chris Lattner8a923e72008-03-12 17:45:29 +0000162
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000163 // Otherwise, build a key to look up the existing attributes.
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000164 FoldingSetNodeID ID;
Devang Patel00095052008-09-24 00:29:49 +0000165 AttributeListImpl::Profile(ID, Attrs, NumAttrs);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000166 void *InsertPos;
Owen Andersond91e6b02009-08-17 17:10:58 +0000167
168 sys::SmartScopedLock<true> Lock(*ALMutex);
169
Devang Patel00095052008-09-24 00:29:49 +0000170 AttributeListImpl *PAL =
Devang Patel4c758ea2008-09-25 21:00:45 +0000171 AttributesLists->FindNodeOrInsertPos(ID, InsertPos);
Chris Lattner8a923e72008-03-12 17:45:29 +0000172
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000173 // If we didn't find any existing attributes of the same shape then
174 // create a new one and insert it.
175 if (!PAL) {
Devang Patel00095052008-09-24 00:29:49 +0000176 PAL = new AttributeListImpl(Attrs, NumAttrs);
Devang Patel4c758ea2008-09-25 21:00:45 +0000177 AttributesLists->InsertNode(PAL, InsertPos);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000178 }
Chris Lattner8a923e72008-03-12 17:45:29 +0000179
Devang Patel4c758ea2008-09-25 21:00:45 +0000180 // Return the AttributesList that we found or created.
181 return AttrListPtr(PAL);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000182}
183
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000184
Chris Lattner8a923e72008-03-12 17:45:29 +0000185//===----------------------------------------------------------------------===//
Devang Patel4c758ea2008-09-25 21:00:45 +0000186// AttrListPtr Method Implementations
Chris Lattner8a923e72008-03-12 17:45:29 +0000187//===----------------------------------------------------------------------===//
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000188
Devang Patel4c758ea2008-09-25 21:00:45 +0000189AttrListPtr::AttrListPtr(AttributeListImpl *LI) : AttrList(LI) {
Chris Lattner8a923e72008-03-12 17:45:29 +0000190 if (LI) LI->AddRef();
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000191}
192
Devang Patel4c758ea2008-09-25 21:00:45 +0000193AttrListPtr::AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) {
194 if (AttrList) AttrList->AddRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000195}
196
Devang Patel4c758ea2008-09-25 21:00:45 +0000197const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) {
198 if (AttrList == RHS.AttrList) return *this;
199 if (AttrList) AttrList->DropRef();
200 AttrList = RHS.AttrList;
201 if (AttrList) AttrList->AddRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000202 return *this;
203}
204
Devang Patel4c758ea2008-09-25 21:00:45 +0000205AttrListPtr::~AttrListPtr() {
206 if (AttrList) AttrList->DropRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000207}
208
209/// getNumSlots - Return the number of slots used in this attribute list.
210/// This is the number of arguments that have an attribute set on them
211/// (including the function itself).
Devang Patel4c758ea2008-09-25 21:00:45 +0000212unsigned AttrListPtr::getNumSlots() const {
213 return AttrList ? AttrList->Attrs.size() : 0;
Chris Lattner8a923e72008-03-12 17:45:29 +0000214}
215
Devang Patel4c758ea2008-09-25 21:00:45 +0000216/// getSlot - Return the AttributeWithIndex at the specified slot. This
217/// holds a number plus a set of attributes.
218const AttributeWithIndex &AttrListPtr::getSlot(unsigned Slot) const {
219 assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!");
220 return AttrList->Attrs[Slot];
Chris Lattner8a923e72008-03-12 17:45:29 +0000221}
222
223
Devang Patel4c758ea2008-09-25 21:00:45 +0000224/// getAttributes - The attributes for the specified index are
225/// returned. Attributes for the result are denoted with Idx = 0.
Devang Patel82fed672008-09-23 22:35:17 +0000226/// Function notes are denoted with idx = ~0.
Devang Patel4c758ea2008-09-25 21:00:45 +0000227Attributes AttrListPtr::getAttributes(unsigned Idx) const {
228 if (AttrList == 0) return Attribute::None;
Chris Lattner8a923e72008-03-12 17:45:29 +0000229
Devang Patel4c758ea2008-09-25 21:00:45 +0000230 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000231 for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
232 if (Attrs[i].Index == Idx)
233 return Attrs[i].Attrs;
Devang Patel4c758ea2008-09-25 21:00:45 +0000234 return Attribute::None;
Chris Lattner8a923e72008-03-12 17:45:29 +0000235}
236
237/// hasAttrSomewhere - Return true if the specified attribute is set for at
238/// least one parameter or for the return value.
Devang Patel4c758ea2008-09-25 21:00:45 +0000239bool AttrListPtr::hasAttrSomewhere(Attributes Attr) const {
240 if (AttrList == 0) return false;
Chris Lattner8a923e72008-03-12 17:45:29 +0000241
Devang Patel4c758ea2008-09-25 21:00:45 +0000242 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000243 for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
244 if (Attrs[i].Attrs & Attr)
245 return true;
246 return false;
247}
248
249
Devang Patel4c758ea2008-09-25 21:00:45 +0000250AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
251 Attributes OldAttrs = getAttributes(Idx);
Dale Johannesen11a555e2008-02-19 23:51:49 +0000252#ifndef NDEBUG
253 // FIXME it is not obvious how this should work for alignment.
254 // For now, say we can't change a known alignment.
Devang Patel4c758ea2008-09-25 21:00:45 +0000255 Attributes OldAlign = OldAttrs & Attribute::Alignment;
256 Attributes NewAlign = Attrs & Attribute::Alignment;
Anton Korobeynikov18991d72008-02-20 12:07:57 +0000257 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
Dale Johannesen11a555e2008-02-19 23:51:49 +0000258 "Attempt to change alignment!");
259#endif
Chris Lattner8a923e72008-03-12 17:45:29 +0000260
Devang Patelba3fa6c2008-09-23 23:03:40 +0000261 Attributes NewAttrs = OldAttrs | Attrs;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000262 if (NewAttrs == OldAttrs)
Chris Lattner8a923e72008-03-12 17:45:29 +0000263 return *this;
264
Devang Patel4c758ea2008-09-25 21:00:45 +0000265 SmallVector<AttributeWithIndex, 8> NewAttrList;
266 if (AttrList == 0)
267 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000268 else {
Devang Patel4c758ea2008-09-25 21:00:45 +0000269 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000270 unsigned i = 0, e = OldAttrList.size();
271 // Copy attributes for arguments before this one.
272 for (; i != e && OldAttrList[i].Index < Idx; ++i)
273 NewAttrList.push_back(OldAttrList[i]);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000274
Chris Lattner8a923e72008-03-12 17:45:29 +0000275 // If there are attributes already at this index, merge them in.
276 if (i != e && OldAttrList[i].Index == Idx) {
277 Attrs |= OldAttrList[i].Attrs;
278 ++i;
279 }
280
Devang Patel4c758ea2008-09-25 21:00:45 +0000281 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000282
283 // Copy attributes for arguments after this one.
284 NewAttrList.insert(NewAttrList.end(),
285 OldAttrList.begin()+i, OldAttrList.end());
286 }
287
Jay Foad7d0479f2009-05-21 09:52:38 +0000288 return get(NewAttrList.data(), NewAttrList.size());
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000289}
290
Devang Patel4c758ea2008-09-25 21:00:45 +0000291AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
Dale Johannesen11a555e2008-02-19 23:51:49 +0000292#ifndef NDEBUG
293 // FIXME it is not obvious how this should work for alignment.
294 // For now, say we can't pass in alignment, which no current use does.
Devang Patel4c758ea2008-09-25 21:00:45 +0000295 assert(!(Attrs & Attribute::Alignment) && "Attempt to exclude alignment!");
Dale Johannesen11a555e2008-02-19 23:51:49 +0000296#endif
Devang Patel4c758ea2008-09-25 21:00:45 +0000297 if (AttrList == 0) return AttrListPtr();
Chris Lattner8a923e72008-03-12 17:45:29 +0000298
Devang Patel4c758ea2008-09-25 21:00:45 +0000299 Attributes OldAttrs = getAttributes(Idx);
Devang Patelba3fa6c2008-09-23 23:03:40 +0000300 Attributes NewAttrs = OldAttrs & ~Attrs;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000301 if (NewAttrs == OldAttrs)
Chris Lattner8a923e72008-03-12 17:45:29 +0000302 return *this;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000303
Devang Patel4c758ea2008-09-25 21:00:45 +0000304 SmallVector<AttributeWithIndex, 8> NewAttrList;
305 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000306 unsigned i = 0, e = OldAttrList.size();
307
308 // Copy attributes for arguments before this one.
309 for (; i != e && OldAttrList[i].Index < Idx; ++i)
310 NewAttrList.push_back(OldAttrList[i]);
311
312 // If there are attributes already at this index, merge them in.
313 assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
314 Attrs = OldAttrList[i].Attrs & ~Attrs;
315 ++i;
316 if (Attrs) // If any attributes left for this parameter, add them.
Devang Patel4c758ea2008-09-25 21:00:45 +0000317 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000318
319 // Copy attributes for arguments after this one.
320 NewAttrList.insert(NewAttrList.end(),
321 OldAttrList.begin()+i, OldAttrList.end());
322
Jay Foad7d0479f2009-05-21 09:52:38 +0000323 return get(NewAttrList.data(), NewAttrList.size());
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000324}
325
Devang Patel4c758ea2008-09-25 21:00:45 +0000326void AttrListPtr::dump() const {
David Greenef7014732010-01-05 01:29:58 +0000327 dbgs() << "PAL[ ";
Chris Lattner8a923e72008-03-12 17:45:29 +0000328 for (unsigned i = 0; i < getNumSlots(); ++i) {
Devang Patel4c758ea2008-09-25 21:00:45 +0000329 const AttributeWithIndex &PAWI = getSlot(i);
David Greenef7014732010-01-05 01:29:58 +0000330 dbgs() << "{" << PAWI.Index << "," << PAWI.Attrs << "} ";
Chris Lattner8a923e72008-03-12 17:45:29 +0000331 }
332
David Greenef7014732010-01-05 01:29:58 +0000333 dbgs() << "]\n";
Duncan Sands404eb052008-01-06 18:27:01 +0000334}