blob: 427134b00f69e4c9a268afd4dab6b2e737d7eda7 [file] [log] [blame]
Bill Wendling034b94b2012-12-19 07:18:57 +00001//===-- Attribute.cpp - Implement AttributesList -------------------------===//
Chris Lattner50ee9dd2008-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 Wendling034b94b2012-12-19 07:18:57 +000010// This file implements the Attribute, AttributeImpl, AttrBuilder,
Bill Wendling18e72112012-12-19 22:42:22 +000011// AttributeSetImpl, and AttributeSet classes.
Chris Lattner50ee9dd2008-01-02 23:42:30 +000012//
13//===----------------------------------------------------------------------===//
14
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000015#include "llvm/IR/Attributes.h"
Bill Wendlingf6670722012-12-20 01:36:59 +000016#include "AttributeImpl.h"
Bill Wendling2c79ecb2012-09-26 21:07:29 +000017#include "LLVMContextImpl.h"
Chris Lattner58d74912008-03-12 17:45:29 +000018#include "llvm/ADT/FoldingSet.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000019#include "llvm/ADT/StringExtras.h"
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000020#include "llvm/IR/Type.h"
Michael J. Spencer1f6efa32010-11-29 18:16:10 +000021#include "llvm/Support/Atomic.h"
David Greeneef1894e2010-01-05 01:29:58 +000022#include "llvm/Support/Debug.h"
Chris Lattner50ee9dd2008-01-02 23:42:30 +000023#include "llvm/Support/ManagedStatic.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000024#include "llvm/Support/Mutex.h"
Benjamin Kramercfa6ec92009-08-23 11:37:21 +000025#include "llvm/Support/raw_ostream.h"
Chris Lattner50ee9dd2008-01-02 23:42:30 +000026using namespace llvm;
27
Chris Lattner58d74912008-03-12 17:45:29 +000028//===----------------------------------------------------------------------===//
Bill Wendling034b94b2012-12-19 07:18:57 +000029// Attribute Implementation
Chris Lattner58d74912008-03-12 17:45:29 +000030//===----------------------------------------------------------------------===//
Chris Lattnerfabfde32008-01-03 00:10:22 +000031
Bill Wendling629fb822012-12-22 00:37:52 +000032Attribute Attribute::get(LLVMContext &Context, ArrayRef<AttrKind> Vals) {
Bill Wendling702cc912012-10-15 20:35:56 +000033 AttrBuilder B;
Bill Wendling629fb822012-12-22 00:37:52 +000034 for (ArrayRef<AttrKind>::iterator I = Vals.begin(), E = Vals.end();
Bill Wendlingcb3de0b2012-10-15 04:46:55 +000035 I != E; ++I)
36 B.addAttribute(*I);
Bill Wendling034b94b2012-12-19 07:18:57 +000037 return Attribute::get(Context, B);
Bill Wendlingcb3de0b2012-10-15 04:46:55 +000038}
Bill Wendling8e635db2012-10-08 21:47:17 +000039
Bill Wendling034b94b2012-12-19 07:18:57 +000040Attribute Attribute::get(LLVMContext &Context, AttrBuilder &B) {
41 // If there are no attributes, return an empty Attribute class.
Bill Wendlinga5c699d2012-10-16 05:55:09 +000042 if (!B.hasAttributes())
Bill Wendling034b94b2012-12-19 07:18:57 +000043 return Attribute();
Bill Wendling8e635db2012-10-08 21:47:17 +000044
45 // Otherwise, build a key to look up the existing attributes.
46 LLVMContextImpl *pImpl = Context.pImpl;
47 FoldingSetNodeID ID;
Bill Wendlingc966e082012-12-30 01:05:42 +000048 ID.AddInteger(B.getBitMask());
Bill Wendling8e635db2012-10-08 21:47:17 +000049
50 void *InsertPoint;
Bill Wendlingf6670722012-12-20 01:36:59 +000051 AttributeImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
Bill Wendling8e635db2012-10-08 21:47:17 +000052
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 Wendlingc966e082012-12-30 01:05:42 +000056 PA = new AttributeImpl(Context, B.getBitMask());
Bill Wendling8e635db2012-10-08 21:47:17 +000057 pImpl->AttrsSet.InsertNode(PA, InsertPoint);
58 }
59
60 // Return the AttributesList that we found or created.
Bill Wendling034b94b2012-12-19 07:18:57 +000061 return Attribute(PA);
Bill Wendling8e635db2012-10-08 21:47:17 +000062}
63
Bill Wendling629fb822012-12-22 00:37:52 +000064bool Attribute::hasAttribute(AttrKind Val) const {
Bill Wendling27107f62012-12-20 21:28:43 +000065 return pImpl && pImpl->hasAttribute(Val);
Bill Wendlinge66f3d32012-10-05 06:44:41 +000066}
67
Bill Wendling034b94b2012-12-19 07:18:57 +000068bool Attribute::hasAttributes() const {
Bill Wendling27107f62012-12-20 21:28:43 +000069 return pImpl && pImpl->hasAttributes();
Bill Wendling05cc40d2012-10-15 05:40:12 +000070}
71
Bill Wendling034b94b2012-12-19 07:18:57 +000072bool Attribute::hasAttributes(const Attribute &A) const {
Bill Wendling27107f62012-12-20 21:28:43 +000073 return pImpl && pImpl->hasAttributes(A);
Bill Wendling2e879bc2012-10-09 09:11:20 +000074}
75
Bill Wendlinge66f3d32012-10-05 06:44:41 +000076/// This returns the alignment field of an attribute as a byte alignment value.
Bill Wendling034b94b2012-12-19 07:18:57 +000077unsigned Attribute::getAlignment() const {
78 if (!hasAttribute(Attribute::Alignment))
Bill Wendling9ef99c92012-10-09 20:56:48 +000079 return 0;
Bill Wendling27107f62012-12-20 21:28:43 +000080 return 1U << ((pImpl->getAlignment() >> 16) - 1);
Bill Wendlinge66f3d32012-10-05 06:44:41 +000081}
82
83/// This returns the stack alignment field of an attribute as a byte alignment
84/// value.
Bill Wendling034b94b2012-12-19 07:18:57 +000085unsigned Attribute::getStackAlignment() const {
86 if (!hasAttribute(Attribute::StackAlignment))
Bill Wendling9ef99c92012-10-09 20:56:48 +000087 return 0;
Bill Wendling27107f62012-12-20 21:28:43 +000088 return 1U << ((pImpl->getStackAlignment() >> 26) - 1);
Bill Wendlinge66f3d32012-10-05 06:44:41 +000089}
90
Bill Wendling92e287f2012-12-31 11:51:54 +000091bool Attribute::operator==(AttrKind K) const {
Bill Wendling22bd6412013-01-03 01:54:39 +000092 return pImpl && pImpl->contains(K);
Bill Wendling92e287f2012-12-31 11:51:54 +000093}
94
95bool Attribute::operator!=(AttrKind K) const {
Bill Wendling22bd6412013-01-03 01:54:39 +000096 return !(pImpl && pImpl->contains(K));
Bill Wendling92e287f2012-12-31 11:51:54 +000097}
98
Bill Wendlingc966e082012-12-30 01:05:42 +000099uint64_t Attribute::getBitMask() const {
100 return pImpl ? pImpl->getBitMask() : 0;
Bill Wendlingb10c88f2012-10-07 08:55:05 +0000101}
102
Bill Wendling034b94b2012-12-19 07:18:57 +0000103Attribute Attribute::typeIncompatible(Type *Ty) {
Bill Wendling702cc912012-10-15 20:35:56 +0000104 AttrBuilder Incompatible;
Bill Wendling77898682012-10-16 06:01:44 +0000105
Bill Wendling3a106e62012-10-09 19:01:18 +0000106 if (!Ty->isIntegerTy())
Bill Wendling034b94b2012-12-19 07:18:57 +0000107 // Attribute that only apply to integers.
108 Incompatible.addAttribute(Attribute::SExt)
109 .addAttribute(Attribute::ZExt);
Bill Wendling77898682012-10-16 06:01:44 +0000110
Bill Wendling3a106e62012-10-09 19:01:18 +0000111 if (!Ty->isPointerTy())
Bill Wendling034b94b2012-12-19 07:18:57 +0000112 // 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);
Bill Wendling77898682012-10-16 06:01:44 +0000118
Bill Wendling034b94b2012-12-19 07:18:57 +0000119 return Attribute::get(Ty->getContext(), Incompatible);
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000120}
121
Bill Wendling702cc912012-10-15 20:35:56 +0000122/// 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.
Bill Wendling034b94b2012-12-19 07:18:57 +0000125uint64_t Attribute::encodeLLVMAttributesForBitcode(Attribute Attrs) {
Bill Wendling702cc912012-10-15 20:35:56 +0000126 // 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.
Bill Wendlingc966e082012-12-30 01:05:42 +0000135 uint64_t EncodedAttrs = Attrs.getBitMask() & 0xffff;
Bill Wendling034b94b2012-12-19 07:18:57 +0000136 if (Attrs.hasAttribute(Attribute::Alignment))
Bill Wendling702cc912012-10-15 20:35:56 +0000137 EncodedAttrs |= Attrs.getAlignment() << 16;
Bill Wendlingc966e082012-12-30 01:05:42 +0000138 EncodedAttrs |= (Attrs.getBitMask() & (0xffffULL << 21)) << 11;
Bill Wendling702cc912012-10-15 20:35:56 +0000139 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'.
Bill Wendling034b94b2012-12-19 07:18:57 +0000145Attribute Attribute::decodeLLVMAttributesForBitcode(LLVMContext &C,
Bill Wendling702cc912012-10-15 20:35:56 +0000146 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);
Nadav Roteme7439422012-10-22 17:33:31 +0000156 B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
Bill Wendling034b94b2012-12-19 07:18:57 +0000157 return Attribute::get(C, B);
Bill Wendling702cc912012-10-15 20:35:56 +0000158}
159
Bill Wendling034b94b2012-12-19 07:18:57 +0000160std::string Attribute::getAsString() const {
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000161 std::string Result;
Bill Wendling034b94b2012-12-19 07:18:57 +0000162 if (hasAttribute(Attribute::ZExt))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000163 Result += "zeroext ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000164 if (hasAttribute(Attribute::SExt))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000165 Result += "signext ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000166 if (hasAttribute(Attribute::NoReturn))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000167 Result += "noreturn ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000168 if (hasAttribute(Attribute::NoUnwind))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000169 Result += "nounwind ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000170 if (hasAttribute(Attribute::UWTable))
Rafael Espindolafc2bb8c2011-05-25 03:44:17 +0000171 Result += "uwtable ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000172 if (hasAttribute(Attribute::ReturnsTwice))
Rafael Espindola25456ef2011-10-03 14:45:37 +0000173 Result += "returns_twice ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000174 if (hasAttribute(Attribute::InReg))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000175 Result += "inreg ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000176 if (hasAttribute(Attribute::NoAlias))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000177 Result += "noalias ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000178 if (hasAttribute(Attribute::NoCapture))
Nick Lewycky73ddd4f2008-12-19 09:38:31 +0000179 Result += "nocapture ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000180 if (hasAttribute(Attribute::StructRet))
Anton Korobeynikovc5ec8a72009-07-17 18:07:26 +0000181 Result += "sret ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000182 if (hasAttribute(Attribute::ByVal))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000183 Result += "byval ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000184 if (hasAttribute(Attribute::Nest))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000185 Result += "nest ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000186 if (hasAttribute(Attribute::ReadNone))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000187 Result += "readnone ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000188 if (hasAttribute(Attribute::ReadOnly))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000189 Result += "readonly ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000190 if (hasAttribute(Attribute::OptimizeForSize))
Devang Patel19c87462008-09-26 22:53:05 +0000191 Result += "optsize ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000192 if (hasAttribute(Attribute::NoInline))
Devang Patel19c87462008-09-26 22:53:05 +0000193 Result += "noinline ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000194 if (hasAttribute(Attribute::InlineHint))
Jakob Stoklund Olesen570a4a52010-02-06 01:16:28 +0000195 Result += "inlinehint ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000196 if (hasAttribute(Attribute::AlwaysInline))
Devang Patel19c87462008-09-26 22:53:05 +0000197 Result += "alwaysinline ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000198 if (hasAttribute(Attribute::StackProtect))
Bill Wendlinge9e6bdf2008-11-13 01:02:14 +0000199 Result += "ssp ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000200 if (hasAttribute(Attribute::StackProtectReq))
Bill Wendlinge9e6bdf2008-11-13 01:02:14 +0000201 Result += "sspreq ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000202 if (hasAttribute(Attribute::NoRedZone))
Devang Pateld18e31a2009-06-04 22:05:33 +0000203 Result += "noredzone ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000204 if (hasAttribute(Attribute::NoImplicitFloat))
Devang Patel578efa92009-06-05 21:57:13 +0000205 Result += "noimplicitfloat ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000206 if (hasAttribute(Attribute::Naked))
Anton Korobeynikovc5ec8a72009-07-17 18:07:26 +0000207 Result += "naked ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000208 if (hasAttribute(Attribute::NonLazyBind))
John McCall3a3465b2011-06-15 20:36:13 +0000209 Result += "nonlazybind ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000210 if (hasAttribute(Attribute::AddressSafety))
Kostya Serebryany164b86b2012-01-20 17:56:17 +0000211 Result += "address_safety ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000212 if (hasAttribute(Attribute::MinSize))
Quentin Colombet9a419f62012-10-30 16:32:52 +0000213 Result += "minsize ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000214 if (hasAttribute(Attribute::StackAlignment)) {
Charles Davis1e063d12010-02-12 00:31:15 +0000215 Result += "alignstack(";
Bill Wendlingef99fe82012-09-21 15:26:31 +0000216 Result += utostr(getStackAlignment());
Charles Davis1e063d12010-02-12 00:31:15 +0000217 Result += ") ";
218 }
Bill Wendling034b94b2012-12-19 07:18:57 +0000219 if (hasAttribute(Attribute::Alignment)) {
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000220 Result += "align ";
Bill Wendlingef99fe82012-09-21 15:26:31 +0000221 Result += utostr(getAlignment());
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000222 Result += " ";
223 }
James Molloy67ae1352012-12-20 16:04:27 +0000224 if (hasAttribute(Attribute::NoDuplicate))
225 Result += "noduplicate ";
Dan Gohmanc3be0fd2008-08-05 15:51:44 +0000226 // Trim the trailing space.
Nick Lewycky73ddd4f2008-12-19 09:38:31 +0000227 assert(!Result.empty() && "Unknown attribute!");
Dan Gohmanc3be0fd2008-08-05 15:51:44 +0000228 Result.erase(Result.end()-1);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000229 return Result;
230}
231
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000232//===----------------------------------------------------------------------===//
Bill Wendling702cc912012-10-15 20:35:56 +0000233// AttrBuilder Implementation
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000234//===----------------------------------------------------------------------===//
235
Bill Wendling629fb822012-12-22 00:37:52 +0000236AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val){
Bill Wendlingf6670722012-12-20 01:36:59 +0000237 Bits |= AttributeImpl::getAttrMask(Val);
Bill Wendling3a106e62012-10-09 19:01:18 +0000238 return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000239}
240
Bill Wendling702cc912012-10-15 20:35:56 +0000241AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
Bill Wendlinga19a5302012-10-14 04:10:01 +0000242 Bits |= Val;
243 return *this;
244}
245
Bill Wendling702cc912012-10-15 20:35:56 +0000246AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) {
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000247 if (Align == 0) return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000248 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;
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000251 return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000252}
Bill Wendlinge5ab1be2013-01-03 02:01:50 +0000253AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align){
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000254 // Default alignment, allow the target to define how to align it.
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000255 if (Align == 0) return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000256 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;
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000259 return *this;
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000260}
261
Bill Wendling629fb822012-12-22 00:37:52 +0000262AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
Bill Wendlingf6670722012-12-20 01:36:59 +0000263 Bits &= ~AttributeImpl::getAttrMask(Val);
Bill Wendling3a106e62012-10-09 19:01:18 +0000264 return *this;
Bill Wendling2e879bc2012-10-09 09:11:20 +0000265}
266
Bill Wendling034b94b2012-12-19 07:18:57 +0000267AttrBuilder &AttrBuilder::addAttributes(const Attribute &A) {
Bill Wendlingc966e082012-12-30 01:05:42 +0000268 Bits |= A.getBitMask();
Bill Wendling432e6062012-10-14 07:17:34 +0000269 return *this;
270}
271
Bill Wendling034b94b2012-12-19 07:18:57 +0000272AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){
Bill Wendlingc966e082012-12-30 01:05:42 +0000273 Bits &= ~A.getBitMask();
Bill Wendling5886b7b2012-10-14 06:39:53 +0000274 return *this;
Bill Wendling8831c062012-10-09 00:01:21 +0000275}
276
Bill Wendling22bd6412013-01-03 01:54:39 +0000277bool AttrBuilder::contains(Attribute::AttrKind A) const {
Bill Wendlingf6670722012-12-20 01:36:59 +0000278 return Bits & AttributeImpl::getAttrMask(A);
Bill Wendling7d2f2492012-10-10 07:36:45 +0000279}
280
Bill Wendling702cc912012-10-15 20:35:56 +0000281bool AttrBuilder::hasAttributes() const {
Bill Wendlingf385f4c2012-10-08 23:27:46 +0000282 return Bits != 0;
283}
Bill Wendling034b94b2012-12-19 07:18:57 +0000284bool AttrBuilder::hasAttributes(const Attribute &A) const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000285 return Bits & A.getBitMask();
Bill Wendling8831c062012-10-09 00:01:21 +0000286}
Bill Wendling702cc912012-10-15 20:35:56 +0000287bool AttrBuilder::hasAlignmentAttr() const {
Bill Wendlingf6670722012-12-20 01:36:59 +0000288 return Bits & AttributeImpl::getAttrMask(Attribute::Alignment);
Bill Wendlingf385f4c2012-10-08 23:27:46 +0000289}
290
Bill Wendling702cc912012-10-15 20:35:56 +0000291uint64_t AttrBuilder::getAlignment() const {
Bill Wendling9ef99c92012-10-09 20:56:48 +0000292 if (!hasAlignmentAttr())
293 return 0;
NAKAMURA Takumi1fcbb8f2012-11-19 10:03:09 +0000294 return 1ULL <<
Bill Wendlingf6670722012-12-20 01:36:59 +0000295 (((Bits & AttributeImpl::getAttrMask(Attribute::Alignment)) >> 16) - 1);
Bill Wendlingf385f4c2012-10-08 23:27:46 +0000296}
297
Bill Wendling702cc912012-10-15 20:35:56 +0000298uint64_t AttrBuilder::getStackAlignment() const {
Bill Wendling7d2f2492012-10-10 07:36:45 +0000299 if (!hasAlignmentAttr())
300 return 0;
NAKAMURA Takumi1fcbb8f2012-11-19 10:03:09 +0000301 return 1ULL <<
Bill Wendlingf6670722012-12-20 01:36:59 +0000302 (((Bits & AttributeImpl::getAttrMask(Attribute::StackAlignment))>>26)-1);
Bill Wendling7d2f2492012-10-10 07:36:45 +0000303}
304
Chris Lattner58d74912008-03-12 17:45:29 +0000305//===----------------------------------------------------------------------===//
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000306// AttributeImpl Definition
307//===----------------------------------------------------------------------===//
308
Bill Wendling7c1683d2012-12-29 12:29:38 +0000309AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data) {
310 Data = ConstantInt::get(Type::getInt64Ty(C), data);
311}
Bill Wendling979aff62012-12-30 02:22:16 +0000312AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data) {
313 Data = ConstantInt::get(Type::getInt64Ty(C), data);
314}
315AttributeImpl::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}
321AttributeImpl::AttributeImpl(LLVMContext &C, StringRef data) {
322 Data = ConstantDataArray::getString(C, data);
323}
Bill Wendling7c1683d2012-12-29 12:29:38 +0000324
Bill Wendling22bd6412013-01-03 01:54:39 +0000325bool AttributeImpl::contains(Attribute::AttrKind Kind) const {
Bill Wendling529ec712012-12-30 01:38:39 +0000326 if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))
327 return CI->getZExtValue() == Kind;
328 return false;
329}
330
Bill Wendling22bd6412013-01-03 01:54:39 +0000331bool AttributeImpl::contains(StringRef Kind) const {
Bill Wendling529ec712012-12-30 01:38:39 +0000332 if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data))
333 if (CDA->isString())
334 return CDA->getAsString() == Kind;
335 return false;
336}
337
Bill Wendlingc966e082012-12-30 01:05:42 +0000338uint64_t AttributeImpl::getBitMask() const {
Bill Wendling529ec712012-12-30 01:38:39 +0000339 // FIXME: Remove this.
Bill Wendling7c1683d2012-12-29 12:29:38 +0000340 return cast<ConstantInt>(Data)->getZExtValue();
341}
342
Bill Wendlinge5ab1be2013-01-03 02:01:50 +0000343uint64_t AttributeImpl::getAttrMask(uint64_t Val) {
Bill Wendling67658342012-10-09 07:45:08 +0000344 switch (Val) {
Bill Wendling034b94b2012-12-19 07:18:57 +0000345 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;
James Molloy67ae1352012-12-20 16:04:27 +0000374 case Attribute::NoDuplicate: return 1ULL << 34;
Bill Wendling67658342012-10-09 07:45:08 +0000375 }
376 llvm_unreachable("Unsupported attribute type");
377}
378
Bill Wendlinge5ab1be2013-01-03 02:01:50 +0000379bool AttributeImpl::hasAttribute(uint64_t A) const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000380 return (getBitMask() & getAttrMask(A)) != 0;
Bill Wendling8e635db2012-10-08 21:47:17 +0000381}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000382
Bill Wendlingf6670722012-12-20 01:36:59 +0000383bool AttributeImpl::hasAttributes() const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000384 return getBitMask() != 0;
Bill Wendling8e635db2012-10-08 21:47:17 +0000385}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000386
Bill Wendlingf6670722012-12-20 01:36:59 +0000387bool AttributeImpl::hasAttributes(const Attribute &A) const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000388 // FIXME: getBitMask() won't work here in the future.
389 return getBitMask() & A.getBitMask();
Bill Wendling8e635db2012-10-08 21:47:17 +0000390}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000391
Bill Wendlingf6670722012-12-20 01:36:59 +0000392uint64_t AttributeImpl::getAlignment() const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000393 return getBitMask() & getAttrMask(Attribute::Alignment);
Bill Wendling8e635db2012-10-08 21:47:17 +0000394}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000395
Bill Wendlingf6670722012-12-20 01:36:59 +0000396uint64_t AttributeImpl::getStackAlignment() const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000397 return getBitMask() & getAttrMask(Attribute::StackAlignment);
Bill Wendling8e635db2012-10-08 21:47:17 +0000398}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000399
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000400//===----------------------------------------------------------------------===//
Bill Wendling18e72112012-12-19 22:42:22 +0000401// AttributeSetImpl Definition
Chris Lattner58d74912008-03-12 17:45:29 +0000402//===----------------------------------------------------------------------===//
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000403
Bill Wendling99faa3b2012-12-07 23:16:57 +0000404AttributeSet AttributeSet::get(LLVMContext &C,
Bill Wendling1ce47ac2012-12-12 19:21:53 +0000405 ArrayRef<AttributeWithIndex> Attrs) {
Devang Patel05988662008-09-25 21:00:45 +0000406 // If there are no attributes then return a null AttributesList pointer.
Chris Lattnerd509d0b2012-05-28 01:47:44 +0000407 if (Attrs.empty())
Bill Wendling99faa3b2012-12-07 23:16:57 +0000408 return AttributeSet();
Bill Wendling77898682012-10-16 06:01:44 +0000409
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000410#ifndef NDEBUG
Chris Lattnerd509d0b2012-05-28 01:47:44 +0000411 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
Bill Wendling77898682012-10-16 06:01:44 +0000412 assert(Attrs[i].Attrs.hasAttributes() &&
Devang Patel05988662008-09-25 21:00:45 +0000413 "Pointless attribute!");
Chris Lattner58d74912008-03-12 17:45:29 +0000414 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
Devang Patel05988662008-09-25 21:00:45 +0000415 "Misordered AttributesList!");
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000416 }
417#endif
Bill Wendling77898682012-10-16 06:01:44 +0000418
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000419 // Otherwise, build a key to look up the existing attributes.
Bill Wendling0976e002012-11-20 05:09:20 +0000420 LLVMContextImpl *pImpl = C.pImpl;
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000421 FoldingSetNodeID ID;
Bill Wendling18e72112012-12-19 22:42:22 +0000422 AttributeSetImpl::Profile(ID, Attrs);
Bill Wendling77898682012-10-16 06:01:44 +0000423
Bill Wendling0976e002012-11-20 05:09:20 +0000424 void *InsertPoint;
Bill Wendling18e72112012-12-19 22:42:22 +0000425 AttributeSetImpl *PA = pImpl->AttrsLists.FindNodeOrInsertPos(ID,
Bill Wendling0976e002012-11-20 05:09:20 +0000426 InsertPoint);
Bill Wendling77898682012-10-16 06:01:44 +0000427
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000428 // If we didn't find any existing attributes of the same shape then
429 // create a new one and insert it.
Bill Wendling0976e002012-11-20 05:09:20 +0000430 if (!PA) {
Bill Wendling5f93e2b2012-12-19 23:55:43 +0000431 PA = new AttributeSetImpl(C, Attrs);
Bill Wendling0976e002012-11-20 05:09:20 +0000432 pImpl->AttrsLists.InsertNode(PA, InsertPoint);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000433 }
Bill Wendling77898682012-10-16 06:01:44 +0000434
Devang Patel05988662008-09-25 21:00:45 +0000435 // Return the AttributesList that we found or created.
Bill Wendling99faa3b2012-12-07 23:16:57 +0000436 return AttributeSet(PA);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000437}
438
Chris Lattner58d74912008-03-12 17:45:29 +0000439//===----------------------------------------------------------------------===//
Bill Wendling99faa3b2012-12-07 23:16:57 +0000440// AttributeSet Method Implementations
Chris Lattner58d74912008-03-12 17:45:29 +0000441//===----------------------------------------------------------------------===//
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000442
Bill Wendling99faa3b2012-12-07 23:16:57 +0000443const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) {
Bill Wendling0976e002012-11-20 05:09:20 +0000444 AttrList = RHS.AttrList;
445 return *this;
Chris Lattner58d74912008-03-12 17:45:29 +0000446}
447
Bill Wendling77898682012-10-16 06:01:44 +0000448/// getNumSlots - Return the number of slots used in this attribute list.
Chris Lattner58d74912008-03-12 17:45:29 +0000449/// This is the number of arguments that have an attribute set on them
450/// (including the function itself).
Bill Wendling99faa3b2012-12-07 23:16:57 +0000451unsigned AttributeSet::getNumSlots() const {
Devang Patel05988662008-09-25 21:00:45 +0000452 return AttrList ? AttrList->Attrs.size() : 0;
Chris Lattner58d74912008-03-12 17:45:29 +0000453}
454
Devang Patel05988662008-09-25 21:00:45 +0000455/// getSlot - Return the AttributeWithIndex at the specified slot. This
456/// holds a number plus a set of attributes.
Bill Wendling99faa3b2012-12-07 23:16:57 +0000457const AttributeWithIndex &AttributeSet::getSlot(unsigned Slot) const {
Devang Patel05988662008-09-25 21:00:45 +0000458 assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!");
459 return AttrList->Attrs[Slot];
Chris Lattner58d74912008-03-12 17:45:29 +0000460}
461
Bill Wendling831737d2012-12-30 10:32:01 +0000462bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{
463 return getAttributes(Index).hasAttribute(Kind);
464}
465
466bool AttributeSet::hasAttributes(unsigned Index) const {
467 return getAttributes(Index).hasAttributes();
468}
469
470std::string AttributeSet::getAsString(unsigned Index) const {
471 return getAttributes(Index).getAsString();
472}
473
474unsigned AttributeSet::getStackAlignment(unsigned Index) const {
475 return getAttributes(Index).getStackAlignment();
476}
477
478uint64_t AttributeSet::getBitMask(unsigned Index) const {
479 // FIXME: Remove this.
480 return getAttributes(Index).getBitMask();
481}
482
Bill Wendling77898682012-10-16 06:01:44 +0000483/// getAttributes - The attributes for the specified index are returned.
Bill Wendling92e287f2012-12-31 11:51:54 +0000484/// Attributes for the result are denoted with Idx = 0. Function attributes are
485/// denoted with Idx = ~0.
Bill Wendling034b94b2012-12-19 07:18:57 +0000486Attribute AttributeSet::getAttributes(unsigned Idx) const {
487 if (AttrList == 0) return Attribute();
Bill Wendling77898682012-10-16 06:01:44 +0000488
Bill Wendling9d30e722012-12-31 00:49:59 +0000489 const SmallVectorImpl<AttributeWithIndex> &Attrs = AttrList->Attrs;
Chris Lattner58d74912008-03-12 17:45:29 +0000490 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;
Bill Wendlingef99fe82012-09-21 15:26:31 +0000493
Bill Wendling034b94b2012-12-19 07:18:57 +0000494 return Attribute();
Chris Lattner58d74912008-03-12 17:45:29 +0000495}
496
497/// hasAttrSomewhere - Return true if the specified attribute is set for at
498/// least one parameter or for the return value.
Bill Wendling629fb822012-12-22 00:37:52 +0000499bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
Devang Patel05988662008-09-25 21:00:45 +0000500 if (AttrList == 0) return false;
Bill Wendling7d2f2492012-10-10 07:36:45 +0000501
Devang Patel05988662008-09-25 21:00:45 +0000502 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner58d74912008-03-12 17:45:29 +0000503 for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
Bill Wendling7d2f2492012-10-10 07:36:45 +0000504 if (Attrs[i].Attrs.hasAttribute(Attr))
Chris Lattner58d74912008-03-12 17:45:29 +0000505 return true;
Bill Wendling0976e002012-11-20 05:09:20 +0000506
Chris Lattner58d74912008-03-12 17:45:29 +0000507 return false;
508}
509
Bill Wendling99faa3b2012-12-07 23:16:57 +0000510AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
Bill Wendling9d30e722012-12-31 00:49:59 +0000511 Attribute Attrs) const {
Bill Wendling034b94b2012-12-19 07:18:57 +0000512 Attribute OldAttrs = getAttributes(Idx);
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000513#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.
Bill Wendlingef99fe82012-09-21 15:26:31 +0000516 unsigned OldAlign = OldAttrs.getAlignment();
517 unsigned NewAlign = Attrs.getAlignment();
Anton Korobeynikov4aefd6b2008-02-20 12:07:57 +0000518 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000519 "Attempt to change alignment!");
520#endif
Bill Wendling77898682012-10-16 06:01:44 +0000521
Bill Wendling702cc912012-10-15 20:35:56 +0000522 AttrBuilder NewAttrs =
523 AttrBuilder(OldAttrs).addAttributes(Attrs);
524 if (NewAttrs == AttrBuilder(OldAttrs))
Chris Lattner58d74912008-03-12 17:45:29 +0000525 return *this;
Bill Wendling77898682012-10-16 06:01:44 +0000526
Devang Patel05988662008-09-25 21:00:45 +0000527 SmallVector<AttributeWithIndex, 8> NewAttrList;
528 if (AttrList == 0)
529 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner58d74912008-03-12 17:45:29 +0000530 else {
Devang Patel05988662008-09-25 21:00:45 +0000531 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner58d74912008-03-12 17:45:29 +0000532 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]);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000536
Chris Lattner58d74912008-03-12 17:45:29 +0000537 // If there are attributes already at this index, merge them in.
538 if (i != e && OldAttrList[i].Index == Idx) {
Bill Wendlingc4167952012-10-14 07:35:59 +0000539 Attrs =
Bill Wendling034b94b2012-12-19 07:18:57 +0000540 Attribute::get(C, AttrBuilder(Attrs).
Bill Wendlingc4167952012-10-14 07:35:59 +0000541 addAttributes(OldAttrList[i].Attrs));
Chris Lattner58d74912008-03-12 17:45:29 +0000542 ++i;
543 }
Bill Wendling77898682012-10-16 06:01:44 +0000544
Devang Patel05988662008-09-25 21:00:45 +0000545 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Bill Wendling77898682012-10-16 06:01:44 +0000546
Chris Lattner58d74912008-03-12 17:45:29 +0000547 // Copy attributes for arguments after this one.
Bill Wendling77898682012-10-16 06:01:44 +0000548 NewAttrList.insert(NewAttrList.end(),
Chris Lattner58d74912008-03-12 17:45:29 +0000549 OldAttrList.begin()+i, OldAttrList.end());
550 }
Bill Wendling77898682012-10-16 06:01:44 +0000551
Bill Wendling0976e002012-11-20 05:09:20 +0000552 return get(C, NewAttrList);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000553}
554
Bill Wendling99faa3b2012-12-07 23:16:57 +0000555AttributeSet AttributeSet::removeAttr(LLVMContext &C, unsigned Idx,
Bill Wendling9d30e722012-12-31 00:49:59 +0000556 Attribute Attrs) const {
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000557#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.
Bill Wendling034b94b2012-12-19 07:18:57 +0000560 assert(!Attrs.hasAttribute(Attribute::Alignment) &&
Bill Wendling67658342012-10-09 07:45:08 +0000561 "Attempt to exclude alignment!");
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000562#endif
Bill Wendling99faa3b2012-12-07 23:16:57 +0000563 if (AttrList == 0) return AttributeSet();
Bill Wendling77898682012-10-16 06:01:44 +0000564
Bill Wendling034b94b2012-12-19 07:18:57 +0000565 Attribute OldAttrs = getAttributes(Idx);
Bill Wendling702cc912012-10-15 20:35:56 +0000566 AttrBuilder NewAttrs =
567 AttrBuilder(OldAttrs).removeAttributes(Attrs);
568 if (NewAttrs == AttrBuilder(OldAttrs))
Chris Lattner58d74912008-03-12 17:45:29 +0000569 return *this;
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000570
Devang Patel05988662008-09-25 21:00:45 +0000571 SmallVector<AttributeWithIndex, 8> NewAttrList;
572 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner58d74912008-03-12 17:45:29 +0000573 unsigned i = 0, e = OldAttrList.size();
Bill Wendling77898682012-10-16 06:01:44 +0000574
Chris Lattner58d74912008-03-12 17:45:29 +0000575 // Copy attributes for arguments before this one.
576 for (; i != e && OldAttrList[i].Index < Idx; ++i)
577 NewAttrList.push_back(OldAttrList[i]);
Bill Wendling77898682012-10-16 06:01:44 +0000578
Chris Lattner58d74912008-03-12 17:45:29 +0000579 // If there are attributes already at this index, merge them in.
580 assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
Bill Wendling034b94b2012-12-19 07:18:57 +0000581 Attrs = Attribute::get(C, AttrBuilder(OldAttrList[i].Attrs).
Bill Wendling5886b7b2012-10-14 06:39:53 +0000582 removeAttributes(Attrs));
Chris Lattner58d74912008-03-12 17:45:29 +0000583 ++i;
Bill Wendling7be78482012-10-14 08:54:26 +0000584 if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
Devang Patel05988662008-09-25 21:00:45 +0000585 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Bill Wendling77898682012-10-16 06:01:44 +0000586
Chris Lattner58d74912008-03-12 17:45:29 +0000587 // Copy attributes for arguments after this one.
Bill Wendling77898682012-10-16 06:01:44 +0000588 NewAttrList.insert(NewAttrList.end(),
Chris Lattner58d74912008-03-12 17:45:29 +0000589 OldAttrList.begin()+i, OldAttrList.end());
Bill Wendling77898682012-10-16 06:01:44 +0000590
Bill Wendling0976e002012-11-20 05:09:20 +0000591 return get(C, NewAttrList);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000592}
593
Bill Wendling99faa3b2012-12-07 23:16:57 +0000594void AttributeSet::dump() const {
David Greeneef1894e2010-01-05 01:29:58 +0000595 dbgs() << "PAL[ ";
Chris Lattner58d74912008-03-12 17:45:29 +0000596 for (unsigned i = 0; i < getNumSlots(); ++i) {
Devang Patel05988662008-09-25 21:00:45 +0000597 const AttributeWithIndex &PAWI = getSlot(i);
Bill Wendling7be78482012-10-14 08:54:26 +0000598 dbgs() << "{" << PAWI.Index << "," << PAWI.Attrs.getAsString() << "} ";
Chris Lattner58d74912008-03-12 17:45:29 +0000599 }
Bill Wendling77898682012-10-16 06:01:44 +0000600
David Greeneef1894e2010-01-05 01:29:58 +0000601 dbgs() << "]\n";
Duncan Sandsad9a9e12008-01-06 18:27:01 +0000602}