blob: d68bba30729df9c996f9f4494bcfe1b51a4c90c0 [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"
Chris Lattner3e13b8c2008-01-02 23:42:30 +000020#include "llvm/Support/ManagedStatic.h"
Benjamin Kramer1a25d732009-08-23 11:37:21 +000021#include "llvm/Support/raw_ostream.h"
Chris Lattner3e13b8c2008-01-02 23:42:30 +000022using namespace llvm;
23
Chris Lattner8a923e72008-03-12 17:45:29 +000024//===----------------------------------------------------------------------===//
Devang Patel4c758ea2008-09-25 21:00:45 +000025// Attribute Function Definitions
Chris Lattner8a923e72008-03-12 17:45:29 +000026//===----------------------------------------------------------------------===//
Chris Lattnerd0e1f102008-01-03 00:10:22 +000027
Devang Patel4c758ea2008-09-25 21:00:45 +000028std::string Attribute::getAsString(Attributes Attrs) {
Chris Lattner3e13b8c2008-01-02 23:42:30 +000029 std::string Result;
Devang Patel4c758ea2008-09-25 21:00:45 +000030 if (Attrs & Attribute::ZExt)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000031 Result += "zeroext ";
Devang Patel4c758ea2008-09-25 21:00:45 +000032 if (Attrs & Attribute::SExt)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000033 Result += "signext ";
Devang Patel4c758ea2008-09-25 21:00:45 +000034 if (Attrs & Attribute::NoReturn)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000035 Result += "noreturn ";
Devang Patel4c758ea2008-09-25 21:00:45 +000036 if (Attrs & Attribute::NoUnwind)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000037 Result += "nounwind ";
Devang Patel4c758ea2008-09-25 21:00:45 +000038 if (Attrs & Attribute::InReg)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000039 Result += "inreg ";
Devang Patel4c758ea2008-09-25 21:00:45 +000040 if (Attrs & Attribute::NoAlias)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000041 Result += "noalias ";
Nick Lewycky8d69f482008-12-19 09:38:31 +000042 if (Attrs & Attribute::NoCapture)
43 Result += "nocapture ";
Devang Patel4c758ea2008-09-25 21:00:45 +000044 if (Attrs & Attribute::StructRet)
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +000045 Result += "sret ";
Devang Patel4c758ea2008-09-25 21:00:45 +000046 if (Attrs & Attribute::ByVal)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000047 Result += "byval ";
Devang Patel4c758ea2008-09-25 21:00:45 +000048 if (Attrs & Attribute::Nest)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000049 Result += "nest ";
Devang Patel4c758ea2008-09-25 21:00:45 +000050 if (Attrs & Attribute::ReadNone)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000051 Result += "readnone ";
Devang Patel4c758ea2008-09-25 21:00:45 +000052 if (Attrs & Attribute::ReadOnly)
Chris Lattner3e13b8c2008-01-02 23:42:30 +000053 Result += "readonly ";
Devang Patela05633e2008-09-26 22:53:05 +000054 if (Attrs & Attribute::OptimizeForSize)
55 Result += "optsize ";
56 if (Attrs & Attribute::NoInline)
57 Result += "noinline ";
Dale Johannesen2aaf5392009-08-26 01:08:21 +000058 if (Attrs & Attribute::InlineHint)
59 Result += "inlinehint ";
Devang Patela05633e2008-09-26 22:53:05 +000060 if (Attrs & Attribute::AlwaysInline)
61 Result += "alwaysinline ";
Bill Wendlingccb67a3d2008-11-13 01:02:14 +000062 if (Attrs & Attribute::StackProtect)
63 Result += "ssp ";
64 if (Attrs & Attribute::StackProtectReq)
65 Result += "sspreq ";
Devang Patel72a4d2f2009-06-04 22:05:33 +000066 if (Attrs & Attribute::NoRedZone)
67 Result += "noredzone ";
Devang Pateld1c7d342009-06-05 21:57:13 +000068 if (Attrs & Attribute::NoImplicitFloat)
69 Result += "noimplicitfloat ";
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +000070 if (Attrs & Attribute::Naked)
71 Result += "naked ";
Devang Patel4c758ea2008-09-25 21:00:45 +000072 if (Attrs & Attribute::Alignment) {
Dale Johannesen11a555e2008-02-19 23:51:49 +000073 Result += "align ";
Nick Lewycky93787d12009-01-11 17:02:06 +000074 Result += utostr(Attribute::getAlignmentFromAttrs(Attrs));
Dale Johannesen11a555e2008-02-19 23:51:49 +000075 Result += " ";
76 }
Dan Gohman1a70bcc2008-08-05 15:51:44 +000077 // Trim the trailing space.
Nick Lewycky8d69f482008-12-19 09:38:31 +000078 assert(!Result.empty() && "Unknown attribute!");
Dan Gohman1a70bcc2008-08-05 15:51:44 +000079 Result.erase(Result.end()-1);
Chris Lattner3e13b8c2008-01-02 23:42:30 +000080 return Result;
81}
82
Devang Patel4c758ea2008-09-25 21:00:45 +000083Attributes Attribute::typeIncompatible(const Type *Ty) {
Devang Patelba3fa6c2008-09-23 23:03:40 +000084 Attributes Incompatible = None;
Chris Lattner8a923e72008-03-12 17:45:29 +000085
86 if (!Ty->isInteger())
87 // Attributes that only apply to integers.
88 Incompatible |= SExt | ZExt;
89
90 if (!isa<PointerType>(Ty))
91 // Attributes that only apply to pointers.
Nick Lewycky8d69f482008-12-19 09:38:31 +000092 Incompatible |= ByVal | Nest | NoAlias | StructRet | NoCapture;
Chris Lattner8a923e72008-03-12 17:45:29 +000093
94 return Incompatible;
Chris Lattner3e13b8c2008-01-02 23:42:30 +000095}
96
Chris Lattner8a923e72008-03-12 17:45:29 +000097//===----------------------------------------------------------------------===//
Devang Patel00095052008-09-24 00:29:49 +000098// AttributeListImpl Definition
Chris Lattner8a923e72008-03-12 17:45:29 +000099//===----------------------------------------------------------------------===//
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000100
Chris Lattner8a923e72008-03-12 17:45:29 +0000101namespace llvm {
Devang Patel00095052008-09-24 00:29:49 +0000102class AttributeListImpl : public FoldingSetNode {
Owen Andersonc1a3a472009-08-20 19:03:20 +0000103 sys::cas_flag RefCount;
Chris Lattner8a923e72008-03-12 17:45:29 +0000104
Devang Patel4c758ea2008-09-25 21:00:45 +0000105 // AttributesList is uniqued, these should not be publicly available.
Devang Patel00095052008-09-24 00:29:49 +0000106 void operator=(const AttributeListImpl &); // Do not implement
107 AttributeListImpl(const AttributeListImpl &); // Do not implement
108 ~AttributeListImpl(); // Private implementation
Chris Lattner8a923e72008-03-12 17:45:29 +0000109public:
Devang Patel4c758ea2008-09-25 21:00:45 +0000110 SmallVector<AttributeWithIndex, 4> Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000111
Devang Patel4c758ea2008-09-25 21:00:45 +0000112 AttributeListImpl(const AttributeWithIndex *Attr, unsigned NumAttrs)
Chris Lattner8a923e72008-03-12 17:45:29 +0000113 : Attrs(Attr, Attr+NumAttrs) {
114 RefCount = 0;
115 }
116
Owen Andersonc1a3a472009-08-20 19:03:20 +0000117 void AddRef() { sys::AtomicIncrement(&RefCount); }
118 void DropRef() {
119 sys::cas_flag old = sys::AtomicDecrement(&RefCount);
120 if (old == 0) delete this;
121 }
Chris Lattner8a923e72008-03-12 17:45:29 +0000122
123 void Profile(FoldingSetNodeID &ID) const {
Jay Foad7d0479f2009-05-21 09:52:38 +0000124 Profile(ID, Attrs.data(), Attrs.size());
Chris Lattner8a923e72008-03-12 17:45:29 +0000125 }
Devang Patel4c758ea2008-09-25 21:00:45 +0000126 static void Profile(FoldingSetNodeID &ID, const AttributeWithIndex *Attr,
Chris Lattner8a923e72008-03-12 17:45:29 +0000127 unsigned NumAttrs) {
128 for (unsigned i = 0; i != NumAttrs; ++i)
129 ID.AddInteger(uint64_t(Attr[i].Attrs) << 32 | unsigned(Attr[i].Index));
130 }
131};
132}
133
Owen Andersond91e6b02009-08-17 17:10:58 +0000134static ManagedStatic<sys::SmartMutex<true> > ALMutex;
Devang Patel4c758ea2008-09-25 21:00:45 +0000135static ManagedStatic<FoldingSet<AttributeListImpl> > AttributesLists;
Chris Lattner8a923e72008-03-12 17:45:29 +0000136
Devang Patel00095052008-09-24 00:29:49 +0000137AttributeListImpl::~AttributeListImpl() {
Owen Andersond91e6b02009-08-17 17:10:58 +0000138 sys::SmartScopedLock<true> Lock(*ALMutex);
Devang Patel4c758ea2008-09-25 21:00:45 +0000139 AttributesLists->RemoveNode(this);
Chris Lattner8a923e72008-03-12 17:45:29 +0000140}
141
142
Devang Patel4c758ea2008-09-25 21:00:45 +0000143AttrListPtr AttrListPtr::get(const AttributeWithIndex *Attrs, unsigned NumAttrs) {
144 // If there are no attributes then return a null AttributesList pointer.
Chris Lattner8a923e72008-03-12 17:45:29 +0000145 if (NumAttrs == 0)
Devang Patel4c758ea2008-09-25 21:00:45 +0000146 return AttrListPtr();
Chris Lattner8a923e72008-03-12 17:45:29 +0000147
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000148#ifndef NDEBUG
Chris Lattner8a923e72008-03-12 17:45:29 +0000149 for (unsigned i = 0; i != NumAttrs; ++i) {
Devang Patel4c758ea2008-09-25 21:00:45 +0000150 assert(Attrs[i].Attrs != Attribute::None &&
151 "Pointless attribute!");
Chris Lattner8a923e72008-03-12 17:45:29 +0000152 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
Devang Patel4c758ea2008-09-25 21:00:45 +0000153 "Misordered AttributesList!");
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000154 }
155#endif
Chris Lattner8a923e72008-03-12 17:45:29 +0000156
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000157 // Otherwise, build a key to look up the existing attributes.
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000158 FoldingSetNodeID ID;
Devang Patel00095052008-09-24 00:29:49 +0000159 AttributeListImpl::Profile(ID, Attrs, NumAttrs);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000160 void *InsertPos;
Owen Andersond91e6b02009-08-17 17:10:58 +0000161
162 sys::SmartScopedLock<true> Lock(*ALMutex);
163
Devang Patel00095052008-09-24 00:29:49 +0000164 AttributeListImpl *PAL =
Devang Patel4c758ea2008-09-25 21:00:45 +0000165 AttributesLists->FindNodeOrInsertPos(ID, InsertPos);
Chris Lattner8a923e72008-03-12 17:45:29 +0000166
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000167 // If we didn't find any existing attributes of the same shape then
168 // create a new one and insert it.
169 if (!PAL) {
Devang Patel00095052008-09-24 00:29:49 +0000170 PAL = new AttributeListImpl(Attrs, NumAttrs);
Devang Patel4c758ea2008-09-25 21:00:45 +0000171 AttributesLists->InsertNode(PAL, InsertPos);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000172 }
Chris Lattner8a923e72008-03-12 17:45:29 +0000173
Devang Patel4c758ea2008-09-25 21:00:45 +0000174 // Return the AttributesList that we found or created.
175 return AttrListPtr(PAL);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000176}
177
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000178
Chris Lattner8a923e72008-03-12 17:45:29 +0000179//===----------------------------------------------------------------------===//
Devang Patel4c758ea2008-09-25 21:00:45 +0000180// AttrListPtr Method Implementations
Chris Lattner8a923e72008-03-12 17:45:29 +0000181//===----------------------------------------------------------------------===//
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000182
Devang Patel4c758ea2008-09-25 21:00:45 +0000183AttrListPtr::AttrListPtr(AttributeListImpl *LI) : AttrList(LI) {
Chris Lattner8a923e72008-03-12 17:45:29 +0000184 if (LI) LI->AddRef();
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000185}
186
Devang Patel4c758ea2008-09-25 21:00:45 +0000187AttrListPtr::AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) {
188 if (AttrList) AttrList->AddRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000189}
190
Devang Patel4c758ea2008-09-25 21:00:45 +0000191const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) {
192 if (AttrList == RHS.AttrList) return *this;
193 if (AttrList) AttrList->DropRef();
194 AttrList = RHS.AttrList;
195 if (AttrList) AttrList->AddRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000196 return *this;
197}
198
Devang Patel4c758ea2008-09-25 21:00:45 +0000199AttrListPtr::~AttrListPtr() {
200 if (AttrList) AttrList->DropRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000201}
202
203/// getNumSlots - Return the number of slots used in this attribute list.
204/// This is the number of arguments that have an attribute set on them
205/// (including the function itself).
Devang Patel4c758ea2008-09-25 21:00:45 +0000206unsigned AttrListPtr::getNumSlots() const {
207 return AttrList ? AttrList->Attrs.size() : 0;
Chris Lattner8a923e72008-03-12 17:45:29 +0000208}
209
Devang Patel4c758ea2008-09-25 21:00:45 +0000210/// getSlot - Return the AttributeWithIndex at the specified slot. This
211/// holds a number plus a set of attributes.
212const AttributeWithIndex &AttrListPtr::getSlot(unsigned Slot) const {
213 assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!");
214 return AttrList->Attrs[Slot];
Chris Lattner8a923e72008-03-12 17:45:29 +0000215}
216
217
Devang Patel4c758ea2008-09-25 21:00:45 +0000218/// getAttributes - The attributes for the specified index are
219/// returned. Attributes for the result are denoted with Idx = 0.
Devang Patel82fed672008-09-23 22:35:17 +0000220/// Function notes are denoted with idx = ~0.
Devang Patel4c758ea2008-09-25 21:00:45 +0000221Attributes AttrListPtr::getAttributes(unsigned Idx) const {
222 if (AttrList == 0) return Attribute::None;
Chris Lattner8a923e72008-03-12 17:45:29 +0000223
Devang Patel4c758ea2008-09-25 21:00:45 +0000224 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000225 for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
226 if (Attrs[i].Index == Idx)
227 return Attrs[i].Attrs;
Devang Patel4c758ea2008-09-25 21:00:45 +0000228 return Attribute::None;
Chris Lattner8a923e72008-03-12 17:45:29 +0000229}
230
231/// hasAttrSomewhere - Return true if the specified attribute is set for at
232/// least one parameter or for the return value.
Devang Patel4c758ea2008-09-25 21:00:45 +0000233bool AttrListPtr::hasAttrSomewhere(Attributes Attr) const {
234 if (AttrList == 0) return false;
Chris Lattner8a923e72008-03-12 17:45:29 +0000235
Devang Patel4c758ea2008-09-25 21:00:45 +0000236 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000237 for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
238 if (Attrs[i].Attrs & Attr)
239 return true;
240 return false;
241}
242
243
Devang Patel4c758ea2008-09-25 21:00:45 +0000244AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
245 Attributes OldAttrs = getAttributes(Idx);
Dale Johannesen11a555e2008-02-19 23:51:49 +0000246#ifndef NDEBUG
247 // FIXME it is not obvious how this should work for alignment.
248 // For now, say we can't change a known alignment.
Devang Patel4c758ea2008-09-25 21:00:45 +0000249 Attributes OldAlign = OldAttrs & Attribute::Alignment;
250 Attributes NewAlign = Attrs & Attribute::Alignment;
Anton Korobeynikov18991d72008-02-20 12:07:57 +0000251 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
Dale Johannesen11a555e2008-02-19 23:51:49 +0000252 "Attempt to change alignment!");
253#endif
Chris Lattner8a923e72008-03-12 17:45:29 +0000254
Devang Patelba3fa6c2008-09-23 23:03:40 +0000255 Attributes NewAttrs = OldAttrs | Attrs;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000256 if (NewAttrs == OldAttrs)
Chris Lattner8a923e72008-03-12 17:45:29 +0000257 return *this;
258
Devang Patel4c758ea2008-09-25 21:00:45 +0000259 SmallVector<AttributeWithIndex, 8> NewAttrList;
260 if (AttrList == 0)
261 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000262 else {
Devang Patel4c758ea2008-09-25 21:00:45 +0000263 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000264 unsigned i = 0, e = OldAttrList.size();
265 // Copy attributes for arguments before this one.
266 for (; i != e && OldAttrList[i].Index < Idx; ++i)
267 NewAttrList.push_back(OldAttrList[i]);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000268
Chris Lattner8a923e72008-03-12 17:45:29 +0000269 // If there are attributes already at this index, merge them in.
270 if (i != e && OldAttrList[i].Index == Idx) {
271 Attrs |= OldAttrList[i].Attrs;
272 ++i;
273 }
274
Devang Patel4c758ea2008-09-25 21:00:45 +0000275 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000276
277 // Copy attributes for arguments after this one.
278 NewAttrList.insert(NewAttrList.end(),
279 OldAttrList.begin()+i, OldAttrList.end());
280 }
281
Jay Foad7d0479f2009-05-21 09:52:38 +0000282 return get(NewAttrList.data(), NewAttrList.size());
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000283}
284
Devang Patel4c758ea2008-09-25 21:00:45 +0000285AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
Dale Johannesen11a555e2008-02-19 23:51:49 +0000286#ifndef NDEBUG
287 // FIXME it is not obvious how this should work for alignment.
288 // For now, say we can't pass in alignment, which no current use does.
Devang Patel4c758ea2008-09-25 21:00:45 +0000289 assert(!(Attrs & Attribute::Alignment) && "Attempt to exclude alignment!");
Dale Johannesen11a555e2008-02-19 23:51:49 +0000290#endif
Devang Patel4c758ea2008-09-25 21:00:45 +0000291 if (AttrList == 0) return AttrListPtr();
Chris Lattner8a923e72008-03-12 17:45:29 +0000292
Devang Patel4c758ea2008-09-25 21:00:45 +0000293 Attributes OldAttrs = getAttributes(Idx);
Devang Patelba3fa6c2008-09-23 23:03:40 +0000294 Attributes NewAttrs = OldAttrs & ~Attrs;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000295 if (NewAttrs == OldAttrs)
Chris Lattner8a923e72008-03-12 17:45:29 +0000296 return *this;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000297
Devang Patel4c758ea2008-09-25 21:00:45 +0000298 SmallVector<AttributeWithIndex, 8> NewAttrList;
299 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000300 unsigned i = 0, e = OldAttrList.size();
301
302 // Copy attributes for arguments before this one.
303 for (; i != e && OldAttrList[i].Index < Idx; ++i)
304 NewAttrList.push_back(OldAttrList[i]);
305
306 // If there are attributes already at this index, merge them in.
307 assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
308 Attrs = OldAttrList[i].Attrs & ~Attrs;
309 ++i;
310 if (Attrs) // If any attributes left for this parameter, add them.
Devang Patel4c758ea2008-09-25 21:00:45 +0000311 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000312
313 // Copy attributes for arguments after this one.
314 NewAttrList.insert(NewAttrList.end(),
315 OldAttrList.begin()+i, OldAttrList.end());
316
Jay Foad7d0479f2009-05-21 09:52:38 +0000317 return get(NewAttrList.data(), NewAttrList.size());
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000318}
319
Devang Patel4c758ea2008-09-25 21:00:45 +0000320void AttrListPtr::dump() const {
Benjamin Kramer1a25d732009-08-23 11:37:21 +0000321 errs() << "PAL[ ";
Chris Lattner8a923e72008-03-12 17:45:29 +0000322 for (unsigned i = 0; i < getNumSlots(); ++i) {
Devang Patel4c758ea2008-09-25 21:00:45 +0000323 const AttributeWithIndex &PAWI = getSlot(i);
Benjamin Kramer1a25d732009-08-23 11:37:21 +0000324 errs() << "{" << PAWI.Index << "," << PAWI.Attrs << "} ";
Chris Lattner8a923e72008-03-12 17:45:29 +0000325 }
326
Benjamin Kramer1a25d732009-08-23 11:37:21 +0000327 errs() << "]\n";
Duncan Sands404eb052008-01-06 18:27:01 +0000328}