blob: 68aa954f6108b3fb4baa5c61d796da4f404cf91a [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//
Bill Wendling118a78b2012-10-16 06:10:45 +000010// This file implements the Attributes, AttributeImpl, AttrBuilder,
11// AttributeListImpl, and AttrListPtr classes.
Chris Lattner3e13b8c2008-01-02 23:42:30 +000012//
13//===----------------------------------------------------------------------===//
14
Devang Patelba3fa6c2008-09-23 23:03:40 +000015#include "llvm/Attributes.h"
Bill Wendling8c3e65d2012-10-15 05:40:12 +000016#include "AttributesImpl.h"
Bill Wendlinge38b8042012-09-26 21:07:29 +000017#include "LLVMContextImpl.h"
Chris Lattner8a923e72008-03-12 17:45:29 +000018#include "llvm/Type.h"
Dan Gohmanfc429612008-03-10 23:55:07 +000019#include "llvm/ADT/StringExtras.h"
Chris Lattner8a923e72008-03-12 17:45:29 +000020#include "llvm/ADT/FoldingSet.h"
Michael J. Spencer447762d2010-11-29 18:16:10 +000021#include "llvm/Support/Atomic.h"
22#include "llvm/Support/Mutex.h"
David Greenef7014732010-01-05 01:29:58 +000023#include "llvm/Support/Debug.h"
Chris Lattner3e13b8c2008-01-02 23:42:30 +000024#include "llvm/Support/ManagedStatic.h"
Benjamin Kramer1a25d732009-08-23 11:37:21 +000025#include "llvm/Support/raw_ostream.h"
Chris Lattner3e13b8c2008-01-02 23:42:30 +000026using namespace llvm;
27
Chris Lattner8a923e72008-03-12 17:45:29 +000028//===----------------------------------------------------------------------===//
Bill Wendling73ea2de2012-10-08 21:47:17 +000029// Attributes Implementation
Chris Lattner8a923e72008-03-12 17:45:29 +000030//===----------------------------------------------------------------------===//
Chris Lattnerd0e1f102008-01-03 00:10:22 +000031
Bill Wendling79d45db2012-10-15 06:53:28 +000032Attributes Attributes::get(LLVMContext &Context, ArrayRef<AttrVal> Vals) {
Bill Wendling50d27842012-10-15 20:35:56 +000033 AttrBuilder B;
Bill Wendlingd079a442012-10-15 04:46:55 +000034 for (ArrayRef<AttrVal>::iterator I = Vals.begin(), E = Vals.end();
35 I != E; ++I)
36 B.addAttribute(*I);
Bill Wendling79d45db2012-10-15 06:53:28 +000037 return Attributes::get(Context, B);
Bill Wendlingd079a442012-10-15 04:46:55 +000038}
Bill Wendling73ea2de2012-10-08 21:47:17 +000039
Bill Wendling50d27842012-10-15 20:35:56 +000040Attributes Attributes::get(LLVMContext &Context, AttrBuilder &B) {
Bill Wendling73ea2de2012-10-08 21:47:17 +000041 // If there are no attributes, return an empty Attributes class.
Bill Wendling3ffbac42012-10-16 05:55:09 +000042 if (!B.hasAttributes())
Bill Wendling73ea2de2012-10-08 21:47:17 +000043 return Attributes();
44
45 // Otherwise, build a key to look up the existing attributes.
46 LLVMContextImpl *pImpl = Context.pImpl;
47 FoldingSetNodeID ID;
Bill Wendling3ffbac42012-10-16 05:55:09 +000048 ID.AddInteger(B.Raw());
Bill Wendling73ea2de2012-10-08 21:47:17 +000049
50 void *InsertPoint;
51 AttributesImpl *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.
Bill Wendling3ffbac42012-10-16 05:55:09 +000056 PA = new AttributesImpl(B.Raw());
Bill Wendling73ea2de2012-10-08 21:47:17 +000057 pImpl->AttrsSet.InsertNode(PA, InsertPoint);
58 }
59
60 // Return the AttributesList that we found or created.
61 return Attributes(PA);
62}
63
Bill Wendlingc9b22d72012-10-09 07:45:08 +000064bool Attributes::hasAttribute(AttrVal Val) const {
Bill Wendlingd079a442012-10-15 04:46:55 +000065 return Attrs && Attrs->hasAttribute(Val);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000066}
67
Bill Wendling8c3e65d2012-10-15 05:40:12 +000068bool Attributes::hasAttributes() const {
69 return Attrs && Attrs->hasAttributes();
70}
71
Bill Wendling93f70b72012-10-09 09:11:20 +000072bool Attributes::hasAttributes(const Attributes &A) const {
Bill Wendlingd079a442012-10-15 04:46:55 +000073 return Attrs && Attrs->hasAttributes(A);
Bill Wendling93f70b72012-10-09 09:11:20 +000074}
75
Bill Wendlingabf3feb2012-10-05 06:44:41 +000076/// This returns the alignment field of an attribute as a byte alignment value.
77unsigned Attributes::getAlignment() const {
Bill Wendlingb3723342012-10-09 20:56:48 +000078 if (!hasAttribute(Attributes::Alignment))
79 return 0;
Bill Wendlingd079a442012-10-15 04:46:55 +000080 return 1U << ((Attrs->getAlignment() >> 16) - 1);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000081}
82
83/// This returns the stack alignment field of an attribute as a byte alignment
84/// value.
85unsigned Attributes::getStackAlignment() const {
Bill Wendlingb3723342012-10-09 20:56:48 +000086 if (!hasAttribute(Attributes::StackAlignment))
87 return 0;
Bill Wendlingd079a442012-10-15 04:46:55 +000088 return 1U << ((Attrs->getStackAlignment() >> 26) - 1);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000089}
90
Bill Wendling73ea2de2012-10-08 21:47:17 +000091uint64_t Attributes::Raw() const {
Bill Wendling147ee8e2012-10-16 05:57:28 +000092 return Attrs ? Attrs->Raw() : 0;
Bill Wendlingbe7c6f22012-10-07 08:55:05 +000093}
94
Bill Wendlingabf3feb2012-10-05 06:44:41 +000095Attributes Attributes::typeIncompatible(Type *Ty) {
Bill Wendling50d27842012-10-15 20:35:56 +000096 AttrBuilder Incompatible;
Bill Wendlinga529ade2012-10-16 06:01:44 +000097
Bill Wendling7c04e042012-10-09 19:01:18 +000098 if (!Ty->isIntegerTy())
Bill Wendlingabf3feb2012-10-05 06:44:41 +000099 // Attributes that only apply to integers.
Bill Wendling7c04e042012-10-09 19:01:18 +0000100 Incompatible.addAttribute(Attributes::SExt)
101 .addAttribute(Attributes::ZExt);
Bill Wendlinga529ade2012-10-16 06:01:44 +0000102
Bill Wendling7c04e042012-10-09 19:01:18 +0000103 if (!Ty->isPointerTy())
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000104 // Attributes that only apply to pointers.
Bill Wendling7c04e042012-10-09 19:01:18 +0000105 Incompatible.addAttribute(Attributes::ByVal)
106 .addAttribute(Attributes::Nest)
107 .addAttribute(Attributes::NoAlias)
108 .addAttribute(Attributes::NoCapture)
109 .addAttribute(Attributes::StructRet);
Bill Wendlinga529ade2012-10-16 06:01:44 +0000110
Bill Wendlingd079a442012-10-15 04:46:55 +0000111 return Attributes::get(Ty->getContext(), Incompatible);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000112}
113
Bill Wendling50d27842012-10-15 20:35:56 +0000114/// encodeLLVMAttributesForBitcode - This returns an integer containing an
115/// encoding of all the LLVM attributes found in the given attribute bitset.
116/// Any change to this encoding is a breaking change to bitcode compatibility.
117uint64_t Attributes::encodeLLVMAttributesForBitcode(Attributes Attrs) {
118 // FIXME: It doesn't make sense to store the alignment information as an
119 // expanded out value, we should store it as a log2 value. However, we can't
120 // just change that here without breaking bitcode compatibility. If this ever
121 // becomes a problem in practice, we should introduce new tag numbers in the
122 // bitcode file and have those tags use a more efficiently encoded alignment
123 // field.
124
125 // Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit
126 // log2 encoded value. Shift the bits above the alignment up by 11 bits.
127 uint64_t EncodedAttrs = Attrs.Raw() & 0xffff;
128 if (Attrs.hasAttribute(Attributes::Alignment))
129 EncodedAttrs |= Attrs.getAlignment() << 16;
Nadav Rotemdbf47832012-10-22 17:33:31 +0000130 EncodedAttrs |= (Attrs.Raw() & (0xffffULL << 21)) << 11;
Bill Wendling50d27842012-10-15 20:35:56 +0000131 return EncodedAttrs;
132}
133
134/// decodeLLVMAttributesForBitcode - This returns an attribute bitset containing
135/// the LLVM attributes that have been decoded from the given integer. This
136/// function must stay in sync with 'encodeLLVMAttributesForBitcode'.
137Attributes Attributes::decodeLLVMAttributesForBitcode(LLVMContext &C,
138 uint64_t EncodedAttrs) {
139 // The alignment is stored as a 16-bit raw value from bits 31--16. We shift
140 // the bits above 31 down by 11 bits.
141 unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
142 assert((!Alignment || isPowerOf2_32(Alignment)) &&
143 "Alignment must be a power of two.");
144
145 AttrBuilder B(EncodedAttrs & 0xffff);
146 if (Alignment)
147 B.addAlignmentAttr(Alignment);
Nadav Rotemdbf47832012-10-22 17:33:31 +0000148 B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
Bill Wendling50d27842012-10-15 20:35:56 +0000149 return Attributes::get(C, B);
150}
151
Bill Wendlingde74cf52012-09-20 14:44:42 +0000152std::string Attributes::getAsString() const {
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000153 std::string Result;
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000154 if (hasAttribute(Attributes::ZExt))
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000155 Result += "zeroext ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000156 if (hasAttribute(Attributes::SExt))
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000157 Result += "signext ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000158 if (hasAttribute(Attributes::NoReturn))
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000159 Result += "noreturn ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000160 if (hasAttribute(Attributes::NoUnwind))
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000161 Result += "nounwind ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000162 if (hasAttribute(Attributes::UWTable))
Rafael Espindolafc9bae62011-05-25 03:44:17 +0000163 Result += "uwtable ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000164 if (hasAttribute(Attributes::ReturnsTwice))
Rafael Espindolacc349c82011-10-03 14:45:37 +0000165 Result += "returns_twice ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000166 if (hasAttribute(Attributes::InReg))
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000167 Result += "inreg ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000168 if (hasAttribute(Attributes::NoAlias))
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000169 Result += "noalias ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000170 if (hasAttribute(Attributes::NoCapture))
Nick Lewycky8d69f482008-12-19 09:38:31 +0000171 Result += "nocapture ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000172 if (hasAttribute(Attributes::StructRet))
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +0000173 Result += "sret ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000174 if (hasAttribute(Attributes::ByVal))
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000175 Result += "byval ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000176 if (hasAttribute(Attributes::Nest))
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000177 Result += "nest ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000178 if (hasAttribute(Attributes::ReadNone))
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000179 Result += "readnone ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000180 if (hasAttribute(Attributes::ReadOnly))
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000181 Result += "readonly ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000182 if (hasAttribute(Attributes::OptimizeForSize))
Devang Patela05633e2008-09-26 22:53:05 +0000183 Result += "optsize ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000184 if (hasAttribute(Attributes::NoInline))
Devang Patela05633e2008-09-26 22:53:05 +0000185 Result += "noinline ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000186 if (hasAttribute(Attributes::InlineHint))
Jakob Stoklund Olesen74bb06c2010-02-06 01:16:28 +0000187 Result += "inlinehint ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000188 if (hasAttribute(Attributes::AlwaysInline))
Devang Patela05633e2008-09-26 22:53:05 +0000189 Result += "alwaysinline ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000190 if (hasAttribute(Attributes::StackProtect))
Bill Wendlingccb67a3d2008-11-13 01:02:14 +0000191 Result += "ssp ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000192 if (hasAttribute(Attributes::StackProtectReq))
Bill Wendlingccb67a3d2008-11-13 01:02:14 +0000193 Result += "sspreq ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000194 if (hasAttribute(Attributes::NoRedZone))
Devang Patel72a4d2f2009-06-04 22:05:33 +0000195 Result += "noredzone ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000196 if (hasAttribute(Attributes::NoImplicitFloat))
Devang Pateld1c7d342009-06-05 21:57:13 +0000197 Result += "noimplicitfloat ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000198 if (hasAttribute(Attributes::Naked))
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +0000199 Result += "naked ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000200 if (hasAttribute(Attributes::NonLazyBind))
John McCall4b7a8d62011-06-15 20:36:13 +0000201 Result += "nonlazybind ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000202 if (hasAttribute(Attributes::AddressSafety))
Kostya Serebryanya5054ad2012-01-20 17:56:17 +0000203 Result += "address_safety ";
Quentin Colombet5799e9f2012-10-30 16:32:52 +0000204 if (hasAttribute(Attributes::MinSize))
205 Result += "minsize ";
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000206 if (hasAttribute(Attributes::StackAlignment)) {
Charles Davisbe5557e2010-02-12 00:31:15 +0000207 Result += "alignstack(";
Bill Wendling9be77592012-09-21 15:26:31 +0000208 Result += utostr(getStackAlignment());
Charles Davisbe5557e2010-02-12 00:31:15 +0000209 Result += ") ";
210 }
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000211 if (hasAttribute(Attributes::Alignment)) {
Dale Johannesen11a555e2008-02-19 23:51:49 +0000212 Result += "align ";
Bill Wendling9be77592012-09-21 15:26:31 +0000213 Result += utostr(getAlignment());
Dale Johannesen11a555e2008-02-19 23:51:49 +0000214 Result += " ";
215 }
Dan Gohman1a70bcc2008-08-05 15:51:44 +0000216 // Trim the trailing space.
Nick Lewycky8d69f482008-12-19 09:38:31 +0000217 assert(!Result.empty() && "Unknown attribute!");
Dan Gohman1a70bcc2008-08-05 15:51:44 +0000218 Result.erase(Result.end()-1);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000219 return Result;
220}
221
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000222//===----------------------------------------------------------------------===//
Bill Wendling50d27842012-10-15 20:35:56 +0000223// AttrBuilder Implementation
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000224//===----------------------------------------------------------------------===//
225
Bill Wendling50d27842012-10-15 20:35:56 +0000226AttrBuilder &AttrBuilder::addAttribute(Attributes::AttrVal Val){
Bill Wendling93f70b72012-10-09 09:11:20 +0000227 Bits |= AttributesImpl::getAttrMask(Val);
Bill Wendling7c04e042012-10-09 19:01:18 +0000228 return *this;
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000229}
230
Bill Wendling50d27842012-10-15 20:35:56 +0000231AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
Bill Wendling1fcc8222012-10-14 04:10:01 +0000232 Bits |= Val;
233 return *this;
234}
235
Bill Wendling50d27842012-10-15 20:35:56 +0000236AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) {
Bill Wendlingabd5ba22012-10-14 03:58:29 +0000237 if (Align == 0) return *this;
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000238 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
239 assert(Align <= 0x40000000 && "Alignment too large.");
240 Bits |= (Log2_32(Align) + 1) << 16;
Bill Wendlingabd5ba22012-10-14 03:58:29 +0000241 return *this;
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000242}
Bill Wendling50d27842012-10-15 20:35:56 +0000243AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align){
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000244 // Default alignment, allow the target to define how to align it.
Bill Wendlingabd5ba22012-10-14 03:58:29 +0000245 if (Align == 0) return *this;
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000246 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
247 assert(Align <= 0x100 && "Alignment too large.");
248 Bits |= (Log2_32(Align) + 1) << 26;
Bill Wendlingabd5ba22012-10-14 03:58:29 +0000249 return *this;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000250}
251
Bill Wendlinga517c302012-10-16 05:22:28 +0000252AttrBuilder &AttrBuilder::removeAttribute(Attributes::AttrVal Val) {
Bill Wendling93f70b72012-10-09 09:11:20 +0000253 Bits &= ~AttributesImpl::getAttrMask(Val);
Bill Wendling7c04e042012-10-09 19:01:18 +0000254 return *this;
Bill Wendling93f70b72012-10-09 09:11:20 +0000255}
256
Bill Wendling50d27842012-10-15 20:35:56 +0000257AttrBuilder &AttrBuilder::addAttributes(const Attributes &A) {
Bill Wendling5c407ed2012-10-14 07:17:34 +0000258 Bits |= A.Raw();
259 return *this;
260}
261
Bill Wendling50d27842012-10-15 20:35:56 +0000262AttrBuilder &AttrBuilder::removeAttributes(const Attributes &A){
Bill Wendling70f39172012-10-09 00:01:21 +0000263 Bits &= ~A.Raw();
Bill Wendling85a64c22012-10-14 06:39:53 +0000264 return *this;
Bill Wendling70f39172012-10-09 00:01:21 +0000265}
266
Bill Wendling50d27842012-10-15 20:35:56 +0000267bool AttrBuilder::hasAttribute(Attributes::AttrVal A) const {
Bill Wendlingbbcdf4e2012-10-10 07:36:45 +0000268 return Bits & AttributesImpl::getAttrMask(A);
269}
270
Bill Wendling50d27842012-10-15 20:35:56 +0000271bool AttrBuilder::hasAttributes() const {
Bill Wendlingc6daefa2012-10-08 23:27:46 +0000272 return Bits != 0;
273}
Bill Wendling50d27842012-10-15 20:35:56 +0000274bool AttrBuilder::hasAttributes(const Attributes &A) const {
Bill Wendling70f39172012-10-09 00:01:21 +0000275 return Bits & A.Raw();
276}
Bill Wendling50d27842012-10-15 20:35:56 +0000277bool AttrBuilder::hasAlignmentAttr() const {
Bill Wendling4caad412012-10-09 20:28:54 +0000278 return Bits & AttributesImpl::getAttrMask(Attributes::Alignment);
Bill Wendlingc6daefa2012-10-08 23:27:46 +0000279}
280
Bill Wendling50d27842012-10-15 20:35:56 +0000281uint64_t AttrBuilder::getAlignment() const {
Bill Wendlingb3723342012-10-09 20:56:48 +0000282 if (!hasAlignmentAttr())
283 return 0;
NAKAMURA Takumib54ac212012-11-19 10:03:09 +0000284 return 1ULL <<
Bill Wendling4caad412012-10-09 20:28:54 +0000285 (((Bits & AttributesImpl::getAttrMask(Attributes::Alignment)) >> 16) - 1);
Bill Wendlingc6daefa2012-10-08 23:27:46 +0000286}
287
Bill Wendling50d27842012-10-15 20:35:56 +0000288uint64_t AttrBuilder::getStackAlignment() const {
Bill Wendlingbbcdf4e2012-10-10 07:36:45 +0000289 if (!hasAlignmentAttr())
290 return 0;
NAKAMURA Takumib54ac212012-11-19 10:03:09 +0000291 return 1ULL <<
Bill Wendlingbbcdf4e2012-10-10 07:36:45 +0000292 (((Bits & AttributesImpl::getAttrMask(Attributes::StackAlignment))>>26)-1);
293}
294
Chris Lattner8a923e72008-03-12 17:45:29 +0000295//===----------------------------------------------------------------------===//
Bill Wendlinge38b8042012-09-26 21:07:29 +0000296// AttributeImpl Definition
297//===----------------------------------------------------------------------===//
298
Bill Wendling93f70b72012-10-09 09:11:20 +0000299uint64_t AttributesImpl::getAttrMask(uint64_t Val) {
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000300 switch (Val) {
301 case Attributes::None: return 0;
302 case Attributes::ZExt: return 1 << 0;
303 case Attributes::SExt: return 1 << 1;
304 case Attributes::NoReturn: return 1 << 2;
305 case Attributes::InReg: return 1 << 3;
306 case Attributes::StructRet: return 1 << 4;
307 case Attributes::NoUnwind: return 1 << 5;
308 case Attributes::NoAlias: return 1 << 6;
309 case Attributes::ByVal: return 1 << 7;
310 case Attributes::Nest: return 1 << 8;
311 case Attributes::ReadNone: return 1 << 9;
312 case Attributes::ReadOnly: return 1 << 10;
313 case Attributes::NoInline: return 1 << 11;
314 case Attributes::AlwaysInline: return 1 << 12;
315 case Attributes::OptimizeForSize: return 1 << 13;
316 case Attributes::StackProtect: return 1 << 14;
317 case Attributes::StackProtectReq: return 1 << 15;
318 case Attributes::Alignment: return 31 << 16;
319 case Attributes::NoCapture: return 1 << 21;
320 case Attributes::NoRedZone: return 1 << 22;
321 case Attributes::NoImplicitFloat: return 1 << 23;
322 case Attributes::Naked: return 1 << 24;
323 case Attributes::InlineHint: return 1 << 25;
324 case Attributes::StackAlignment: return 7 << 26;
325 case Attributes::ReturnsTwice: return 1 << 29;
326 case Attributes::UWTable: return 1 << 30;
327 case Attributes::NonLazyBind: return 1U << 31;
328 case Attributes::AddressSafety: return 1ULL << 32;
Quentin Colombet5799e9f2012-10-30 16:32:52 +0000329 case Attributes::MinSize: return 1ULL << 33;
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000330 }
331 llvm_unreachable("Unsupported attribute type");
332}
333
Bill Wendling73ea2de2012-10-08 21:47:17 +0000334bool AttributesImpl::hasAttribute(uint64_t A) const {
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000335 return (Bits & getAttrMask(A)) != 0;
Bill Wendling73ea2de2012-10-08 21:47:17 +0000336}
Bill Wendlinge38b8042012-09-26 21:07:29 +0000337
Bill Wendling73ea2de2012-10-08 21:47:17 +0000338bool AttributesImpl::hasAttributes() const {
339 return Bits != 0;
340}
Bill Wendlinge38b8042012-09-26 21:07:29 +0000341
Bill Wendling73ea2de2012-10-08 21:47:17 +0000342bool AttributesImpl::hasAttributes(const Attributes &A) const {
343 return Bits & A.Raw(); // FIXME: Raw() won't work here in the future.
344}
Bill Wendlinge38b8042012-09-26 21:07:29 +0000345
Bill Wendling73ea2de2012-10-08 21:47:17 +0000346uint64_t AttributesImpl::getAlignment() const {
Bill Wendlingb3723342012-10-09 20:56:48 +0000347 return Bits & getAttrMask(Attributes::Alignment);
Bill Wendling73ea2de2012-10-08 21:47:17 +0000348}
Bill Wendlinge38b8042012-09-26 21:07:29 +0000349
Bill Wendling73ea2de2012-10-08 21:47:17 +0000350uint64_t AttributesImpl::getStackAlignment() const {
Bill Wendlingb3723342012-10-09 20:56:48 +0000351 return Bits & getAttrMask(Attributes::StackAlignment);
Bill Wendling73ea2de2012-10-08 21:47:17 +0000352}
Bill Wendlinge38b8042012-09-26 21:07:29 +0000353
Bill Wendlinge38b8042012-09-26 21:07:29 +0000354//===----------------------------------------------------------------------===//
Devang Patel00095052008-09-24 00:29:49 +0000355// AttributeListImpl Definition
Chris Lattner8a923e72008-03-12 17:45:29 +0000356//===----------------------------------------------------------------------===//
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000357
Owen Anderson2e831892010-11-18 18:59:13 +0000358namespace llvm {
359 class AttributeListImpl;
360}
361
362static ManagedStatic<FoldingSet<AttributeListImpl> > AttributesLists;
Owen Anderson9b14a252010-11-09 00:27:03 +0000363
Chris Lattner8a923e72008-03-12 17:45:29 +0000364namespace llvm {
Owen Anderson9b14a252010-11-09 00:27:03 +0000365static ManagedStatic<sys::SmartMutex<true> > ALMutex;
366
Devang Patel00095052008-09-24 00:29:49 +0000367class AttributeListImpl : public FoldingSetNode {
Owen Andersonc1a3a472009-08-20 19:03:20 +0000368 sys::cas_flag RefCount;
Bill Wendlinga529ade2012-10-16 06:01:44 +0000369
Devang Patel4c758ea2008-09-25 21:00:45 +0000370 // AttributesList is uniqued, these should not be publicly available.
Craig Topperb1d83e82012-09-18 02:01:41 +0000371 void operator=(const AttributeListImpl &) LLVM_DELETED_FUNCTION;
372 AttributeListImpl(const AttributeListImpl &) LLVM_DELETED_FUNCTION;
Devang Patel00095052008-09-24 00:29:49 +0000373 ~AttributeListImpl(); // Private implementation
Chris Lattner8a923e72008-03-12 17:45:29 +0000374public:
Devang Patel4c758ea2008-09-25 21:00:45 +0000375 SmallVector<AttributeWithIndex, 4> Attrs;
Bill Wendlinga529ade2012-10-16 06:01:44 +0000376
Chris Lattner3cb6f832012-05-28 01:47:44 +0000377 AttributeListImpl(ArrayRef<AttributeWithIndex> attrs)
378 : Attrs(attrs.begin(), attrs.end()) {
Chris Lattner8a923e72008-03-12 17:45:29 +0000379 RefCount = 0;
380 }
Bill Wendlinga529ade2012-10-16 06:01:44 +0000381
Owen Anderson9b14a252010-11-09 00:27:03 +0000382 void AddRef() {
383 sys::SmartScopedLock<true> Lock(*ALMutex);
384 ++RefCount;
385 }
Owen Andersonc1a3a472009-08-20 19:03:20 +0000386 void DropRef() {
Owen Anderson9b14a252010-11-09 00:27:03 +0000387 sys::SmartScopedLock<true> Lock(*ALMutex);
Owen Anderson2e831892010-11-18 18:59:13 +0000388 if (!AttributesLists.isConstructed())
389 return;
Owen Anderson91bfeb12010-11-09 17:47:10 +0000390 sys::cas_flag new_val = --RefCount;
Owen Anderson2d335432010-11-09 17:46:38 +0000391 if (new_val == 0)
Owen Anderson9b14a252010-11-09 00:27:03 +0000392 delete this;
Owen Andersonc1a3a472009-08-20 19:03:20 +0000393 }
Bill Wendlinga529ade2012-10-16 06:01:44 +0000394
Chris Lattner8a923e72008-03-12 17:45:29 +0000395 void Profile(FoldingSetNodeID &ID) const {
Chris Lattner3cb6f832012-05-28 01:47:44 +0000396 Profile(ID, Attrs);
Chris Lattner8a923e72008-03-12 17:45:29 +0000397 }
Chris Lattner3cb6f832012-05-28 01:47:44 +0000398 static void Profile(FoldingSetNodeID &ID, ArrayRef<AttributeWithIndex> Attrs){
399 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
400 ID.AddInteger(Attrs[i].Attrs.Raw());
401 ID.AddInteger(Attrs[i].Index);
Kostya Serebryanya5054ad2012-01-20 17:56:17 +0000402 }
Chris Lattner8a923e72008-03-12 17:45:29 +0000403 }
404};
Bill Wendlinga529ade2012-10-16 06:01:44 +0000405
406} // end llvm namespace
Chris Lattner8a923e72008-03-12 17:45:29 +0000407
Devang Patel00095052008-09-24 00:29:49 +0000408AttributeListImpl::~AttributeListImpl() {
Owen Anderson9b14a252010-11-09 00:27:03 +0000409 // NOTE: Lock must be acquired by caller.
Devang Patel4c758ea2008-09-25 21:00:45 +0000410 AttributesLists->RemoveNode(this);
Chris Lattner8a923e72008-03-12 17:45:29 +0000411}
412
Chris Lattner3cb6f832012-05-28 01:47:44 +0000413AttrListPtr AttrListPtr::get(ArrayRef<AttributeWithIndex> Attrs) {
Devang Patel4c758ea2008-09-25 21:00:45 +0000414 // If there are no attributes then return a null AttributesList pointer.
Chris Lattner3cb6f832012-05-28 01:47:44 +0000415 if (Attrs.empty())
Devang Patel4c758ea2008-09-25 21:00:45 +0000416 return AttrListPtr();
Bill Wendlinga529ade2012-10-16 06:01:44 +0000417
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000418#ifndef NDEBUG
Chris Lattner3cb6f832012-05-28 01:47:44 +0000419 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
Bill Wendlinga529ade2012-10-16 06:01:44 +0000420 assert(Attrs[i].Attrs.hasAttributes() &&
Devang Patel4c758ea2008-09-25 21:00:45 +0000421 "Pointless attribute!");
Chris Lattner8a923e72008-03-12 17:45:29 +0000422 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
Devang Patel4c758ea2008-09-25 21:00:45 +0000423 "Misordered AttributesList!");
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000424 }
425#endif
Bill Wendlinga529ade2012-10-16 06:01:44 +0000426
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000427 // Otherwise, build a key to look up the existing attributes.
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000428 FoldingSetNodeID ID;
Chris Lattner3cb6f832012-05-28 01:47:44 +0000429 AttributeListImpl::Profile(ID, Attrs);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000430 void *InsertPos;
Bill Wendlinga529ade2012-10-16 06:01:44 +0000431
Owen Andersond91e6b02009-08-17 17:10:58 +0000432 sys::SmartScopedLock<true> Lock(*ALMutex);
Bill Wendlinga529ade2012-10-16 06:01:44 +0000433
Devang Patel00095052008-09-24 00:29:49 +0000434 AttributeListImpl *PAL =
Devang Patel4c758ea2008-09-25 21:00:45 +0000435 AttributesLists->FindNodeOrInsertPos(ID, InsertPos);
Bill Wendlinga529ade2012-10-16 06:01:44 +0000436
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000437 // If we didn't find any existing attributes of the same shape then
438 // create a new one and insert it.
439 if (!PAL) {
Chris Lattner3cb6f832012-05-28 01:47:44 +0000440 PAL = new AttributeListImpl(Attrs);
Devang Patel4c758ea2008-09-25 21:00:45 +0000441 AttributesLists->InsertNode(PAL, InsertPos);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000442 }
Bill Wendlinga529ade2012-10-16 06:01:44 +0000443
Devang Patel4c758ea2008-09-25 21:00:45 +0000444 // Return the AttributesList that we found or created.
445 return AttrListPtr(PAL);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000446}
447
Chris Lattner8a923e72008-03-12 17:45:29 +0000448//===----------------------------------------------------------------------===//
Devang Patel4c758ea2008-09-25 21:00:45 +0000449// AttrListPtr Method Implementations
Chris Lattner8a923e72008-03-12 17:45:29 +0000450//===----------------------------------------------------------------------===//
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000451
Devang Patel4c758ea2008-09-25 21:00:45 +0000452AttrListPtr::AttrListPtr(AttributeListImpl *LI) : AttrList(LI) {
Chris Lattner8a923e72008-03-12 17:45:29 +0000453 if (LI) LI->AddRef();
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000454}
455
Devang Patel4c758ea2008-09-25 21:00:45 +0000456AttrListPtr::AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) {
Bill Wendlinga529ade2012-10-16 06:01:44 +0000457 if (AttrList) AttrList->AddRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000458}
459
Devang Patel4c758ea2008-09-25 21:00:45 +0000460const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) {
Owen Anderson8dc0b042010-09-16 00:27:35 +0000461 sys::SmartScopedLock<true> Lock(*ALMutex);
Devang Patel4c758ea2008-09-25 21:00:45 +0000462 if (AttrList == RHS.AttrList) return *this;
463 if (AttrList) AttrList->DropRef();
464 AttrList = RHS.AttrList;
465 if (AttrList) AttrList->AddRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000466 return *this;
467}
468
Devang Patel4c758ea2008-09-25 21:00:45 +0000469AttrListPtr::~AttrListPtr() {
470 if (AttrList) AttrList->DropRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000471}
472
Bill Wendlinga529ade2012-10-16 06:01:44 +0000473/// getNumSlots - Return the number of slots used in this attribute list.
Chris Lattner8a923e72008-03-12 17:45:29 +0000474/// This is the number of arguments that have an attribute set on them
475/// (including the function itself).
Devang Patel4c758ea2008-09-25 21:00:45 +0000476unsigned AttrListPtr::getNumSlots() const {
477 return AttrList ? AttrList->Attrs.size() : 0;
Chris Lattner8a923e72008-03-12 17:45:29 +0000478}
479
Devang Patel4c758ea2008-09-25 21:00:45 +0000480/// getSlot - Return the AttributeWithIndex at the specified slot. This
481/// holds a number plus a set of attributes.
482const AttributeWithIndex &AttrListPtr::getSlot(unsigned Slot) const {
483 assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!");
484 return AttrList->Attrs[Slot];
Chris Lattner8a923e72008-03-12 17:45:29 +0000485}
486
Bill Wendlinga529ade2012-10-16 06:01:44 +0000487/// getAttributes - The attributes for the specified index are returned.
488/// Attributes for the result are denoted with Idx = 0. Function notes are
489/// denoted with idx = ~0.
Devang Patel4c758ea2008-09-25 21:00:45 +0000490Attributes AttrListPtr::getAttributes(unsigned Idx) const {
Bill Wendling9be77592012-09-21 15:26:31 +0000491 if (AttrList == 0) return Attributes();
Bill Wendlinga529ade2012-10-16 06:01:44 +0000492
Devang Patel4c758ea2008-09-25 21:00:45 +0000493 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000494 for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
495 if (Attrs[i].Index == Idx)
496 return Attrs[i].Attrs;
Bill Wendling9be77592012-09-21 15:26:31 +0000497
498 return Attributes();
Chris Lattner8a923e72008-03-12 17:45:29 +0000499}
500
501/// hasAttrSomewhere - Return true if the specified attribute is set for at
502/// least one parameter or for the return value.
Bill Wendlingbbcdf4e2012-10-10 07:36:45 +0000503bool AttrListPtr::hasAttrSomewhere(Attributes::AttrVal Attr) const {
Devang Patel4c758ea2008-09-25 21:00:45 +0000504 if (AttrList == 0) return false;
Bill Wendlingbbcdf4e2012-10-10 07:36:45 +0000505
Devang Patel4c758ea2008-09-25 21:00:45 +0000506 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000507 for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
Bill Wendlingbbcdf4e2012-10-10 07:36:45 +0000508 if (Attrs[i].Attrs.hasAttribute(Attr))
Chris Lattner8a923e72008-03-12 17:45:29 +0000509 return true;
510 return false;
511}
512
Bill Wendling70f39172012-10-09 00:01:21 +0000513unsigned AttrListPtr::getNumAttrs() const {
514 return AttrList ? AttrList->Attrs.size() : 0;
515}
516
517Attributes &AttrListPtr::getAttributesAtIndex(unsigned i) const {
518 assert(AttrList && "Trying to get an attribute from an empty list!");
519 assert(i < AttrList->Attrs.size() && "Index out of range!");
520 return AttrList->Attrs[i].Attrs;
521}
Chris Lattner8a923e72008-03-12 17:45:29 +0000522
Bill Wendling722b26c2012-10-14 07:35:59 +0000523AttrListPtr AttrListPtr::addAttr(LLVMContext &C, unsigned Idx,
524 Attributes Attrs) const {
Devang Patel4c758ea2008-09-25 21:00:45 +0000525 Attributes OldAttrs = getAttributes(Idx);
Dale Johannesen11a555e2008-02-19 23:51:49 +0000526#ifndef NDEBUG
527 // FIXME it is not obvious how this should work for alignment.
528 // For now, say we can't change a known alignment.
Bill Wendling9be77592012-09-21 15:26:31 +0000529 unsigned OldAlign = OldAttrs.getAlignment();
530 unsigned NewAlign = Attrs.getAlignment();
Anton Korobeynikov18991d72008-02-20 12:07:57 +0000531 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
Dale Johannesen11a555e2008-02-19 23:51:49 +0000532 "Attempt to change alignment!");
533#endif
Bill Wendlinga529ade2012-10-16 06:01:44 +0000534
Bill Wendling50d27842012-10-15 20:35:56 +0000535 AttrBuilder NewAttrs =
536 AttrBuilder(OldAttrs).addAttributes(Attrs);
537 if (NewAttrs == AttrBuilder(OldAttrs))
Chris Lattner8a923e72008-03-12 17:45:29 +0000538 return *this;
Bill Wendlinga529ade2012-10-16 06:01:44 +0000539
Devang Patel4c758ea2008-09-25 21:00:45 +0000540 SmallVector<AttributeWithIndex, 8> NewAttrList;
541 if (AttrList == 0)
542 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000543 else {
Devang Patel4c758ea2008-09-25 21:00:45 +0000544 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000545 unsigned i = 0, e = OldAttrList.size();
546 // Copy attributes for arguments before this one.
547 for (; i != e && OldAttrList[i].Index < Idx; ++i)
548 NewAttrList.push_back(OldAttrList[i]);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000549
Chris Lattner8a923e72008-03-12 17:45:29 +0000550 // If there are attributes already at this index, merge them in.
551 if (i != e && OldAttrList[i].Index == Idx) {
Bill Wendling722b26c2012-10-14 07:35:59 +0000552 Attrs =
Bill Wendling50d27842012-10-15 20:35:56 +0000553 Attributes::get(C, AttrBuilder(Attrs).
Bill Wendling722b26c2012-10-14 07:35:59 +0000554 addAttributes(OldAttrList[i].Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000555 ++i;
556 }
Bill Wendlinga529ade2012-10-16 06:01:44 +0000557
Devang Patel4c758ea2008-09-25 21:00:45 +0000558 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Bill Wendlinga529ade2012-10-16 06:01:44 +0000559
Chris Lattner8a923e72008-03-12 17:45:29 +0000560 // Copy attributes for arguments after this one.
Bill Wendlinga529ade2012-10-16 06:01:44 +0000561 NewAttrList.insert(NewAttrList.end(),
Chris Lattner8a923e72008-03-12 17:45:29 +0000562 OldAttrList.begin()+i, OldAttrList.end());
563 }
Bill Wendlinga529ade2012-10-16 06:01:44 +0000564
Chris Lattner3cb6f832012-05-28 01:47:44 +0000565 return get(NewAttrList);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000566}
567
Bill Wendling85a64c22012-10-14 06:39:53 +0000568AttrListPtr AttrListPtr::removeAttr(LLVMContext &C, unsigned Idx,
569 Attributes Attrs) const {
Dale Johannesen11a555e2008-02-19 23:51:49 +0000570#ifndef NDEBUG
571 // FIXME it is not obvious how this should work for alignment.
572 // For now, say we can't pass in alignment, which no current use does.
Bill Wendlingc9b22d72012-10-09 07:45:08 +0000573 assert(!Attrs.hasAttribute(Attributes::Alignment) &&
574 "Attempt to exclude alignment!");
Dale Johannesen11a555e2008-02-19 23:51:49 +0000575#endif
Devang Patel4c758ea2008-09-25 21:00:45 +0000576 if (AttrList == 0) return AttrListPtr();
Bill Wendlinga529ade2012-10-16 06:01:44 +0000577
Devang Patel4c758ea2008-09-25 21:00:45 +0000578 Attributes OldAttrs = getAttributes(Idx);
Bill Wendling50d27842012-10-15 20:35:56 +0000579 AttrBuilder NewAttrs =
580 AttrBuilder(OldAttrs).removeAttributes(Attrs);
581 if (NewAttrs == AttrBuilder(OldAttrs))
Chris Lattner8a923e72008-03-12 17:45:29 +0000582 return *this;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000583
Devang Patel4c758ea2008-09-25 21:00:45 +0000584 SmallVector<AttributeWithIndex, 8> NewAttrList;
585 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000586 unsigned i = 0, e = OldAttrList.size();
Bill Wendlinga529ade2012-10-16 06:01:44 +0000587
Chris Lattner8a923e72008-03-12 17:45:29 +0000588 // Copy attributes for arguments before this one.
589 for (; i != e && OldAttrList[i].Index < Idx; ++i)
590 NewAttrList.push_back(OldAttrList[i]);
Bill Wendlinga529ade2012-10-16 06:01:44 +0000591
Chris Lattner8a923e72008-03-12 17:45:29 +0000592 // If there are attributes already at this index, merge them in.
593 assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
Bill Wendling50d27842012-10-15 20:35:56 +0000594 Attrs = Attributes::get(C, AttrBuilder(OldAttrList[i].Attrs).
Bill Wendling85a64c22012-10-14 06:39:53 +0000595 removeAttributes(Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000596 ++i;
Bill Wendling76d2cd22012-10-14 08:54:26 +0000597 if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
Devang Patel4c758ea2008-09-25 21:00:45 +0000598 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Bill Wendlinga529ade2012-10-16 06:01:44 +0000599
Chris Lattner8a923e72008-03-12 17:45:29 +0000600 // Copy attributes for arguments after this one.
Bill Wendlinga529ade2012-10-16 06:01:44 +0000601 NewAttrList.insert(NewAttrList.end(),
Chris Lattner8a923e72008-03-12 17:45:29 +0000602 OldAttrList.begin()+i, OldAttrList.end());
Bill Wendlinga529ade2012-10-16 06:01:44 +0000603
Chris Lattner3cb6f832012-05-28 01:47:44 +0000604 return get(NewAttrList);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000605}
606
Devang Patel4c758ea2008-09-25 21:00:45 +0000607void AttrListPtr::dump() const {
David Greenef7014732010-01-05 01:29:58 +0000608 dbgs() << "PAL[ ";
Chris Lattner8a923e72008-03-12 17:45:29 +0000609 for (unsigned i = 0; i < getNumSlots(); ++i) {
Devang Patel4c758ea2008-09-25 21:00:45 +0000610 const AttributeWithIndex &PAWI = getSlot(i);
Bill Wendling76d2cd22012-10-14 08:54:26 +0000611 dbgs() << "{" << PAWI.Index << "," << PAWI.Attrs.getAsString() << "} ";
Chris Lattner8a923e72008-03-12 17:45:29 +0000612 }
Bill Wendlinga529ade2012-10-16 06:01:44 +0000613
David Greenef7014732010-01-05 01:29:58 +0000614 dbgs() << "]\n";
Duncan Sands404eb052008-01-06 18:27:01 +0000615}