Revert everything to r171366 to try to fix the build.
[oota-llvm.git] / lib / IR / Attributes.cpp
1 //===-- Attribute.cpp - Implement AttributesList -------------------------===//
2 //
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 //
10 // This file implements the Attribute, AttributeImpl, AttrBuilder,
11 // AttributeSetImpl, and AttributeSet classes.
12 //
13 //===----------------------------------------------------------------------===//
14
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"
26 using namespace llvm;
27
28 //===----------------------------------------------------------------------===//
29 // Attribute Implementation
30 //===----------------------------------------------------------------------===//
31
32 Attribute Attribute::get(LLVMContext &Context, ArrayRef<AttrKind> Vals) {
33   AttrBuilder B;
34   for (ArrayRef<AttrKind>::iterator I = Vals.begin(), E = Vals.end();
35        I != E; ++I)
36     B.addAttribute(*I);
37   return Attribute::get(Context, B);
38 }
39
40 Attribute Attribute::get(LLVMContext &Context, AttrBuilder &B) {
41   // If there are no attributes, return an empty Attribute class.
42   if (!B.hasAttributes())
43     return Attribute();
44
45   // Otherwise, build a key to look up the existing attributes.
46   LLVMContextImpl *pImpl = Context.pImpl;
47   FoldingSetNodeID ID;
48   ID.AddInteger(B.getBitMask());
49
50   void *InsertPoint;
51   AttributeImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
52
53   if (!PA) {
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);
58   }
59
60   // Return the AttributesList that we found or created.
61   return Attribute(PA);
62 }
63
64 bool Attribute::hasAttribute(AttrKind Val) const {
65   return pImpl && pImpl->hasAttribute(Val);
66 }
67
68 bool Attribute::hasAttributes() const {
69   return pImpl && pImpl->hasAttributes();
70 }
71
72 bool Attribute::hasAttributes(const Attribute &A) const {
73   return pImpl && pImpl->hasAttributes(A);
74 }
75
76 /// This returns the alignment field of an attribute as a byte alignment value.
77 unsigned Attribute::getAlignment() const {
78   if (!hasAttribute(Attribute::Alignment))
79     return 0;
80   return 1U << ((pImpl->getAlignment() >> 16) - 1);
81 }
82
83 /// This returns the stack alignment field of an attribute as a byte alignment
84 /// value.
85 unsigned Attribute::getStackAlignment() const {
86   if (!hasAttribute(Attribute::StackAlignment))
87     return 0;
88   return 1U << ((pImpl->getStackAlignment() >> 26) - 1);
89 }
90
91 bool Attribute::operator==(AttrKind K) const {
92   return pImpl && pImpl->contains(K);
93 }
94
95 bool Attribute::operator!=(AttrKind K) const {
96   return !(pImpl && pImpl->contains(K));
97 }
98
99 uint64_t Attribute::getBitMask() const {
100   return pImpl ? pImpl->getBitMask() : 0;
101 }
102
103 Attribute Attribute::typeIncompatible(Type *Ty) {
104   AttrBuilder Incompatible;
105
106   if (!Ty->isIntegerTy())
107     // Attribute that only apply to integers.
108     Incompatible.addAttribute(Attribute::SExt)
109       .addAttribute(Attribute::ZExt);
110
111   if (!Ty->isPointerTy())
112     // Attribute that only apply to pointers.
113     Incompatible.addAttribute(Attribute::ByVal)
114       .addAttribute(Attribute::Nest)
115       .addAttribute(Attribute::NoAlias)
116       .addAttribute(Attribute::NoCapture)
117       .addAttribute(Attribute::StructRet);
118
119   return Attribute::get(Ty->getContext(), Incompatible);
120 }
121
122 /// encodeLLVMAttributesForBitcode - This returns an integer containing an
123 /// encoding of all the LLVM attributes found in the given attribute bitset.
124 /// Any change to this encoding is a breaking change to bitcode compatibility.
125 uint64_t Attribute::encodeLLVMAttributesForBitcode(Attribute Attrs) {
126   // FIXME: It doesn't make sense to store the alignment information as an
127   // expanded out value, we should store it as a log2 value.  However, we can't
128   // just change that here without breaking bitcode compatibility.  If this ever
129   // becomes a problem in practice, we should introduce new tag numbers in the
130   // bitcode file and have those tags use a more efficiently encoded alignment
131   // field.
132
133   // Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit
134   // log2 encoded value. Shift the bits above the alignment up by 11 bits.
135   uint64_t EncodedAttrs = Attrs.getBitMask() & 0xffff;
136   if (Attrs.hasAttribute(Attribute::Alignment))
137     EncodedAttrs |= Attrs.getAlignment() << 16;
138   EncodedAttrs |= (Attrs.getBitMask() & (0xffffULL << 21)) << 11;
139   return EncodedAttrs;
140 }
141
142 /// decodeLLVMAttributesForBitcode - This returns an attribute bitset containing
143 /// the LLVM attributes that have been decoded from the given integer.  This
144 /// function must stay in sync with 'encodeLLVMAttributesForBitcode'.
145 Attribute Attribute::decodeLLVMAttributesForBitcode(LLVMContext &C,
146                                                       uint64_t EncodedAttrs) {
147   // The alignment is stored as a 16-bit raw value from bits 31--16.  We shift
148   // the bits above 31 down by 11 bits.
149   unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
150   assert((!Alignment || isPowerOf2_32(Alignment)) &&
151          "Alignment must be a power of two.");
152
153   AttrBuilder B(EncodedAttrs & 0xffff);
154   if (Alignment)
155     B.addAlignmentAttr(Alignment);
156   B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
157   return Attribute::get(C, B);
158 }
159
160 std::string Attribute::getAsString() const {
161   std::string Result;
162   if (hasAttribute(Attribute::ZExt))
163     Result += "zeroext ";
164   if (hasAttribute(Attribute::SExt))
165     Result += "signext ";
166   if (hasAttribute(Attribute::NoReturn))
167     Result += "noreturn ";
168   if (hasAttribute(Attribute::NoUnwind))
169     Result += "nounwind ";
170   if (hasAttribute(Attribute::UWTable))
171     Result += "uwtable ";
172   if (hasAttribute(Attribute::ReturnsTwice))
173     Result += "returns_twice ";
174   if (hasAttribute(Attribute::InReg))
175     Result += "inreg ";
176   if (hasAttribute(Attribute::NoAlias))
177     Result += "noalias ";
178   if (hasAttribute(Attribute::NoCapture))
179     Result += "nocapture ";
180   if (hasAttribute(Attribute::StructRet))
181     Result += "sret ";
182   if (hasAttribute(Attribute::ByVal))
183     Result += "byval ";
184   if (hasAttribute(Attribute::Nest))
185     Result += "nest ";
186   if (hasAttribute(Attribute::ReadNone))
187     Result += "readnone ";
188   if (hasAttribute(Attribute::ReadOnly))
189     Result += "readonly ";
190   if (hasAttribute(Attribute::OptimizeForSize))
191     Result += "optsize ";
192   if (hasAttribute(Attribute::NoInline))
193     Result += "noinline ";
194   if (hasAttribute(Attribute::InlineHint))
195     Result += "inlinehint ";
196   if (hasAttribute(Attribute::AlwaysInline))
197     Result += "alwaysinline ";
198   if (hasAttribute(Attribute::StackProtect))
199     Result += "ssp ";
200   if (hasAttribute(Attribute::StackProtectReq))
201     Result += "sspreq ";
202   if (hasAttribute(Attribute::NoRedZone))
203     Result += "noredzone ";
204   if (hasAttribute(Attribute::NoImplicitFloat))
205     Result += "noimplicitfloat ";
206   if (hasAttribute(Attribute::Naked))
207     Result += "naked ";
208   if (hasAttribute(Attribute::NonLazyBind))
209     Result += "nonlazybind ";
210   if (hasAttribute(Attribute::AddressSafety))
211     Result += "address_safety ";
212   if (hasAttribute(Attribute::MinSize))
213     Result += "minsize ";
214   if (hasAttribute(Attribute::StackAlignment)) {
215     Result += "alignstack(";
216     Result += utostr(getStackAlignment());
217     Result += ") ";
218   }
219   if (hasAttribute(Attribute::Alignment)) {
220     Result += "align ";
221     Result += utostr(getAlignment());
222     Result += " ";
223   }
224   if (hasAttribute(Attribute::NoDuplicate))
225     Result += "noduplicate ";
226   // Trim the trailing space.
227   assert(!Result.empty() && "Unknown attribute!");
228   Result.erase(Result.end()-1);
229   return Result;
230 }
231
232 //===----------------------------------------------------------------------===//
233 // AttrBuilder Implementation
234 //===----------------------------------------------------------------------===//
235
236 AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val){
237   Bits |= AttributeImpl::getAttrMask(Val);
238   return *this;
239 }
240
241 AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
242   Bits |= Val;
243   return *this;
244 }
245
246 AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) {
247   if (Align == 0) return *this;
248   assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
249   assert(Align <= 0x40000000 && "Alignment too large.");
250   Bits |= (Log2_32(Align) + 1) << 16;
251   return *this;
252 }
253 AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align){
254   // Default alignment, allow the target to define how to align it.
255   if (Align == 0) return *this;
256   assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
257   assert(Align <= 0x100 && "Alignment too large.");
258   Bits |= (Log2_32(Align) + 1) << 26;
259   return *this;
260 }
261
262 AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
263   Bits &= ~AttributeImpl::getAttrMask(Val);
264   return *this;
265 }
266
267 AttrBuilder &AttrBuilder::addAttributes(const Attribute &A) {
268   Bits |= A.getBitMask();
269   return *this;
270 }
271
272 AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){
273   Bits &= ~A.getBitMask();
274   return *this;
275 }
276
277 bool AttrBuilder::contains(Attribute::AttrKind A) const {
278   return Bits & AttributeImpl::getAttrMask(A);
279 }
280
281 bool AttrBuilder::hasAttributes() const {
282   return Bits != 0;
283 }
284 bool AttrBuilder::hasAttributes(const Attribute &A) const {
285   return Bits & A.getBitMask();
286 }
287 bool AttrBuilder::hasAlignmentAttr() const {
288   return Bits & AttributeImpl::getAttrMask(Attribute::Alignment);
289 }
290
291 uint64_t AttrBuilder::getAlignment() const {
292   if (!hasAlignmentAttr())
293     return 0;
294   return 1ULL <<
295     (((Bits & AttributeImpl::getAttrMask(Attribute::Alignment)) >> 16) - 1);
296 }
297
298 uint64_t AttrBuilder::getStackAlignment() const {
299   if (!hasAlignmentAttr())
300     return 0;
301   return 1ULL <<
302     (((Bits & AttributeImpl::getAttrMask(Attribute::StackAlignment))>>26)-1);
303 }
304
305 //===----------------------------------------------------------------------===//
306 // AttributeImpl Definition
307 //===----------------------------------------------------------------------===//
308
309 AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data) {
310   Data = ConstantInt::get(Type::getInt64Ty(C), data);
311 }
312 AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data) {
313   Data = ConstantInt::get(Type::getInt64Ty(C), data);
314 }
315 AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data,
316                              ArrayRef<Constant*> values) {
317   Data = ConstantInt::get(Type::getInt64Ty(C), data);
318   Vals.reserve(values.size());
319   Vals.append(values.begin(), values.end());
320 }
321 AttributeImpl::AttributeImpl(LLVMContext &C, StringRef data) {
322   Data = ConstantDataArray::getString(C, data);
323 }
324
325 bool AttributeImpl::contains(Attribute::AttrKind Kind) const {
326   if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))
327     return CI->getZExtValue() == Kind;
328   return false;
329 }
330
331 bool AttributeImpl::contains(StringRef Kind) const {
332   if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data))
333     if (CDA->isString())
334       return CDA->getAsString() == Kind;
335   return false;
336 }
337
338 uint64_t AttributeImpl::getBitMask() const {
339   // FIXME: Remove this.
340   return cast<ConstantInt>(Data)->getZExtValue();
341 }
342
343 uint64_t AttributeImpl::getAttrMask(uint64_t Val) {
344   switch (Val) {
345   case Attribute::None:            return 0;
346   case Attribute::ZExt:            return 1 << 0;
347   case Attribute::SExt:            return 1 << 1;
348   case Attribute::NoReturn:        return 1 << 2;
349   case Attribute::InReg:           return 1 << 3;
350   case Attribute::StructRet:       return 1 << 4;
351   case Attribute::NoUnwind:        return 1 << 5;
352   case Attribute::NoAlias:         return 1 << 6;
353   case Attribute::ByVal:           return 1 << 7;
354   case Attribute::Nest:            return 1 << 8;
355   case Attribute::ReadNone:        return 1 << 9;
356   case Attribute::ReadOnly:        return 1 << 10;
357   case Attribute::NoInline:        return 1 << 11;
358   case Attribute::AlwaysInline:    return 1 << 12;
359   case Attribute::OptimizeForSize: return 1 << 13;
360   case Attribute::StackProtect:    return 1 << 14;
361   case Attribute::StackProtectReq: return 1 << 15;
362   case Attribute::Alignment:       return 31 << 16;
363   case Attribute::NoCapture:       return 1 << 21;
364   case Attribute::NoRedZone:       return 1 << 22;
365   case Attribute::NoImplicitFloat: return 1 << 23;
366   case Attribute::Naked:           return 1 << 24;
367   case Attribute::InlineHint:      return 1 << 25;
368   case Attribute::StackAlignment:  return 7 << 26;
369   case Attribute::ReturnsTwice:    return 1 << 29;
370   case Attribute::UWTable:         return 1 << 30;
371   case Attribute::NonLazyBind:     return 1U << 31;
372   case Attribute::AddressSafety:   return 1ULL << 32;
373   case Attribute::MinSize:         return 1ULL << 33;
374   case Attribute::NoDuplicate:     return 1ULL << 34;
375   }
376   llvm_unreachable("Unsupported attribute type");
377 }
378
379 bool AttributeImpl::hasAttribute(uint64_t A) const {
380   return (getBitMask() & getAttrMask(A)) != 0;
381 }
382
383 bool AttributeImpl::hasAttributes() const {
384   return getBitMask() != 0;
385 }
386
387 bool AttributeImpl::hasAttributes(const Attribute &A) const {
388   // FIXME: getBitMask() won't work here in the future.
389   return getBitMask() & A.getBitMask();
390 }
391
392 uint64_t AttributeImpl::getAlignment() const {
393   return getBitMask() & getAttrMask(Attribute::Alignment);
394 }
395
396 uint64_t AttributeImpl::getStackAlignment() const {
397   return getBitMask() & getAttrMask(Attribute::StackAlignment);
398 }
399
400 //===----------------------------------------------------------------------===//
401 // AttributeSetImpl Definition
402 //===----------------------------------------------------------------------===//
403
404 AttributeSet AttributeSet::get(LLVMContext &C,
405                                ArrayRef<AttributeWithIndex> Attrs) {
406   // If there are no attributes then return a null AttributesList pointer.
407   if (Attrs.empty())
408     return AttributeSet();
409
410 #ifndef NDEBUG
411   for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
412     assert(Attrs[i].Attrs.hasAttributes() &&
413            "Pointless attribute!");
414     assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
415            "Misordered AttributesList!");
416   }
417 #endif
418
419   // Otherwise, build a key to look up the existing attributes.
420   LLVMContextImpl *pImpl = C.pImpl;
421   FoldingSetNodeID ID;
422   AttributeSetImpl::Profile(ID, Attrs);
423
424   void *InsertPoint;
425   AttributeSetImpl *PA = pImpl->AttrsLists.FindNodeOrInsertPos(ID,
426                                                                 InsertPoint);
427
428   // If we didn't find any existing attributes of the same shape then
429   // create a new one and insert it.
430   if (!PA) {
431     PA = new AttributeSetImpl(C, Attrs);
432     pImpl->AttrsLists.InsertNode(PA, InsertPoint);
433   }
434
435   // Return the AttributesList that we found or created.
436   return AttributeSet(PA);
437 }
438
439 //===----------------------------------------------------------------------===//
440 // AttributeSet Method Implementations
441 //===----------------------------------------------------------------------===//
442
443 const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) {
444   AttrList = RHS.AttrList;
445   return *this;
446 }
447
448 /// getNumSlots - Return the number of slots used in this attribute list.
449 /// This is the number of arguments that have an attribute set on them
450 /// (including the function itself).
451 unsigned AttributeSet::getNumSlots() const {
452   return AttrList ? AttrList->Attrs.size() : 0;
453 }
454
455 /// getSlot - Return the AttributeWithIndex at the specified slot.  This
456 /// holds a number plus a set of attributes.
457 const AttributeWithIndex &AttributeSet::getSlot(unsigned Slot) const {
458   assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!");
459   return AttrList->Attrs[Slot];
460 }
461
462 bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{
463   return getAttributes(Index).hasAttribute(Kind);
464 }
465
466 bool AttributeSet::hasAttributes(unsigned Index) const {
467   return getAttributes(Index).hasAttributes();
468 }
469
470 std::string AttributeSet::getAsString(unsigned Index) const {
471   return getAttributes(Index).getAsString();
472 }
473
474 unsigned AttributeSet::getStackAlignment(unsigned Index) const {
475   return getAttributes(Index).getStackAlignment();
476 }
477
478 uint64_t AttributeSet::getBitMask(unsigned Index) const {
479   // FIXME: Remove this.
480   return getAttributes(Index).getBitMask();
481 }
482
483 /// getAttributes - The attributes for the specified index are returned.
484 /// Attributes for the result are denoted with Idx = 0.  Function attributes are
485 /// denoted with Idx = ~0.
486 Attribute AttributeSet::getAttributes(unsigned Idx) const {
487   if (AttrList == 0) return Attribute();
488
489   const SmallVectorImpl<AttributeWithIndex> &Attrs = AttrList->Attrs;
490   for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
491     if (Attrs[i].Index == Idx)
492       return Attrs[i].Attrs;
493
494   return Attribute();
495 }
496
497 /// hasAttrSomewhere - Return true if the specified attribute is set for at
498 /// least one parameter or for the return value.
499 bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
500   if (AttrList == 0) return false;
501
502   const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
503   for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
504     if (Attrs[i].Attrs.hasAttribute(Attr))
505       return true;
506
507   return false;
508 }
509
510 AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
511                                    Attribute Attrs) const {
512   Attribute OldAttrs = getAttributes(Idx);
513 #ifndef NDEBUG
514   // FIXME it is not obvious how this should work for alignment.
515   // For now, say we can't change a known alignment.
516   unsigned OldAlign = OldAttrs.getAlignment();
517   unsigned NewAlign = Attrs.getAlignment();
518   assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
519          "Attempt to change alignment!");
520 #endif
521
522   AttrBuilder NewAttrs =
523     AttrBuilder(OldAttrs).addAttributes(Attrs);
524   if (NewAttrs == AttrBuilder(OldAttrs))
525     return *this;
526
527   SmallVector<AttributeWithIndex, 8> NewAttrList;
528   if (AttrList == 0)
529     NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
530   else {
531     const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
532     unsigned i = 0, e = OldAttrList.size();
533     // Copy attributes for arguments before this one.
534     for (; i != e && OldAttrList[i].Index < Idx; ++i)
535       NewAttrList.push_back(OldAttrList[i]);
536
537     // If there are attributes already at this index, merge them in.
538     if (i != e && OldAttrList[i].Index == Idx) {
539       Attrs =
540         Attribute::get(C, AttrBuilder(Attrs).
541                         addAttributes(OldAttrList[i].Attrs));
542       ++i;
543     }
544
545     NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
546
547     // Copy attributes for arguments after this one.
548     NewAttrList.insert(NewAttrList.end(),
549                        OldAttrList.begin()+i, OldAttrList.end());
550   }
551
552   return get(C, NewAttrList);
553 }
554
555 AttributeSet AttributeSet::removeAttr(LLVMContext &C, unsigned Idx,
556                                       Attribute Attrs) const {
557 #ifndef NDEBUG
558   // FIXME it is not obvious how this should work for alignment.
559   // For now, say we can't pass in alignment, which no current use does.
560   assert(!Attrs.hasAttribute(Attribute::Alignment) &&
561          "Attempt to exclude alignment!");
562 #endif
563   if (AttrList == 0) return AttributeSet();
564
565   Attribute OldAttrs = getAttributes(Idx);
566   AttrBuilder NewAttrs =
567     AttrBuilder(OldAttrs).removeAttributes(Attrs);
568   if (NewAttrs == AttrBuilder(OldAttrs))
569     return *this;
570
571   SmallVector<AttributeWithIndex, 8> NewAttrList;
572   const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
573   unsigned i = 0, e = OldAttrList.size();
574
575   // Copy attributes for arguments before this one.
576   for (; i != e && OldAttrList[i].Index < Idx; ++i)
577     NewAttrList.push_back(OldAttrList[i]);
578
579   // If there are attributes already at this index, merge them in.
580   assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
581   Attrs = Attribute::get(C, AttrBuilder(OldAttrList[i].Attrs).
582                           removeAttributes(Attrs));
583   ++i;
584   if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
585     NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
586
587   // Copy attributes for arguments after this one.
588   NewAttrList.insert(NewAttrList.end(),
589                      OldAttrList.begin()+i, OldAttrList.end());
590
591   return get(C, NewAttrList);
592 }
593
594 void AttributeSet::dump() const {
595   dbgs() << "PAL[ ";
596   for (unsigned i = 0; i < getNumSlots(); ++i) {
597     const AttributeWithIndex &PAWI = getSlot(i);
598     dbgs() << "{" << PAWI.Index << "," << PAWI.Attrs.getAsString() << "} ";
599   }
600
601   dbgs() << "]\n";
602 }