• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- llvm/Attributes.h - Container for Attributes ------------*- C++ -*-===//
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 /// \file
11 /// \brief This file contains the simple types necessary to represent the
12 /// attributes associated with functions and their calls.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_IR_ATTRIBUTES_H
17 #define LLVM_IR_ATTRIBUTES_H
18 
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/FoldingSet.h"
21 #include "llvm/ADT/Optional.h"
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Support/PointerLikeTypeTraits.h"
24 #include "llvm-c/Types.h"
25 #include <bitset>
26 #include <cassert>
27 #include <map>
28 #include <string>
29 
30 namespace llvm {
31 
32 class AttrBuilder;
33 class AttributeImpl;
34 class AttributeSetImpl;
35 class AttributeSetNode;
36 class Constant;
37 template<typename T> struct DenseMapInfo;
38 class Function;
39 class LLVMContext;
40 class Type;
41 
42 //===----------------------------------------------------------------------===//
43 /// \class
44 /// \brief Functions, function parameters, and return types can have attributes
45 /// to indicate how they should be treated by optimizations and code
46 /// generation. This class represents one of those attributes. It's light-weight
47 /// and should be passed around by-value.
48 class Attribute {
49 public:
50   /// This enumeration lists the attributes that can be associated with
51   /// parameters, function results, or the function itself.
52   ///
53   /// Note: The `uwtable' attribute is about the ABI or the user mandating an
54   /// entry in the unwind table. The `nounwind' attribute is about an exception
55   /// passing by the function.
56   ///
57   /// In a theoretical system that uses tables for profiling and SjLj for
58   /// exceptions, they would be fully independent. In a normal system that uses
59   /// tables for both, the semantics are:
60   ///
61   /// nil                = Needs an entry because an exception might pass by.
62   /// nounwind           = No need for an entry
63   /// uwtable            = Needs an entry because the ABI says so and because
64   ///                      an exception might pass by.
65   /// uwtable + nounwind = Needs an entry because the ABI says so.
66 
67   enum AttrKind {
68     // IR-Level Attributes
69     None,                  ///< No attributes have been set
70     #define GET_ATTR_ENUM
71     #include "llvm/IR/Attributes.gen"
72     EndAttrKinds           ///< Sentinal value useful for loops
73   };
74 
75 private:
76   AttributeImpl *pImpl;
Attribute(AttributeImpl * A)77   Attribute(AttributeImpl *A) : pImpl(A) {}
78 
79 public:
Attribute()80   Attribute() : pImpl(nullptr) {}
81 
82   //===--------------------------------------------------------------------===//
83   // Attribute Construction
84   //===--------------------------------------------------------------------===//
85 
86   /// \brief Return a uniquified Attribute object.
87   static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val = 0);
88   static Attribute get(LLVMContext &Context, StringRef Kind,
89                        StringRef Val = StringRef());
90 
91   /// \brief Return a uniquified Attribute object that has the specific
92   /// alignment set.
93   static Attribute getWithAlignment(LLVMContext &Context, uint64_t Align);
94   static Attribute getWithStackAlignment(LLVMContext &Context, uint64_t Align);
95   static Attribute getWithDereferenceableBytes(LLVMContext &Context,
96                                               uint64_t Bytes);
97   static Attribute getWithDereferenceableOrNullBytes(LLVMContext &Context,
98                                                      uint64_t Bytes);
99   static Attribute getWithAllocSizeArgs(LLVMContext &Context,
100                                         unsigned ElemSizeArg,
101                                         const Optional<unsigned> &NumElemsArg);
102 
103   //===--------------------------------------------------------------------===//
104   // Attribute Accessors
105   //===--------------------------------------------------------------------===//
106 
107   /// \brief Return true if the attribute is an Attribute::AttrKind type.
108   bool isEnumAttribute() const;
109 
110   /// \brief Return true if the attribute is an integer attribute.
111   bool isIntAttribute() const;
112 
113   /// \brief Return true if the attribute is a string (target-dependent)
114   /// attribute.
115   bool isStringAttribute() const;
116 
117   /// \brief Return true if the attribute is present.
118   bool hasAttribute(AttrKind Val) const;
119 
120   /// \brief Return true if the target-dependent attribute is present.
121   bool hasAttribute(StringRef Val) const;
122 
123   /// \brief Return the attribute's kind as an enum (Attribute::AttrKind). This
124   /// requires the attribute to be an enum or integer attribute.
125   Attribute::AttrKind getKindAsEnum() const;
126 
127   /// \brief Return the attribute's value as an integer. This requires that the
128   /// attribute be an integer attribute.
129   uint64_t getValueAsInt() const;
130 
131   /// \brief Return the attribute's kind as a string. This requires the
132   /// attribute to be a string attribute.
133   StringRef getKindAsString() const;
134 
135   /// \brief Return the attribute's value as a string. This requires the
136   /// attribute to be a string attribute.
137   StringRef getValueAsString() const;
138 
139   /// \brief Returns the alignment field of an attribute as a byte alignment
140   /// value.
141   unsigned getAlignment() const;
142 
143   /// \brief Returns the stack alignment field of an attribute as a byte
144   /// alignment value.
145   unsigned getStackAlignment() const;
146 
147   /// \brief Returns the number of dereferenceable bytes from the
148   /// dereferenceable attribute.
149   uint64_t getDereferenceableBytes() const;
150 
151   /// \brief Returns the number of dereferenceable_or_null bytes from the
152   /// dereferenceable_or_null attribute.
153   uint64_t getDereferenceableOrNullBytes() const;
154 
155   /// Returns the argument numbers for the allocsize attribute (or pair(0, 0)
156   /// if not known).
157   std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
158 
159   /// \brief The Attribute is converted to a string of equivalent mnemonic. This
160   /// is, presumably, for writing out the mnemonics for the assembly writer.
161   std::string getAsString(bool InAttrGrp = false) const;
162 
163   /// \brief Equality and non-equality operators.
164   bool operator==(Attribute A) const { return pImpl == A.pImpl; }
165   bool operator!=(Attribute A) const { return pImpl != A.pImpl; }
166 
167   /// \brief Less-than operator. Useful for sorting the attributes list.
168   bool operator<(Attribute A) const;
169 
Profile(FoldingSetNodeID & ID)170   void Profile(FoldingSetNodeID &ID) const {
171     ID.AddPointer(pImpl);
172   }
173 
174   /// \brief Return a raw pointer that uniquely identifies this attribute.
getRawPointer()175   void *getRawPointer() const {
176     return pImpl;
177   }
178 
179   /// \brief Get an attribute from a raw pointer created by getRawPointer.
fromRawPointer(void * RawPtr)180   static Attribute fromRawPointer(void *RawPtr) {
181     return Attribute(reinterpret_cast<AttributeImpl*>(RawPtr));
182   }
183 };
184 
185 // Specialized opaque value conversions.
wrap(Attribute Attr)186 inline LLVMAttributeRef wrap(Attribute Attr) {
187   return reinterpret_cast<LLVMAttributeRef>(Attr.getRawPointer());
188 }
189 
190 // Specialized opaque value conversions.
unwrap(LLVMAttributeRef Attr)191 inline Attribute unwrap(LLVMAttributeRef Attr) {
192   return Attribute::fromRawPointer(Attr);
193 }
194 
195 //===----------------------------------------------------------------------===//
196 /// \class
197 /// \brief This class holds the attributes for a function, its return value, and
198 /// its parameters. You access the attributes for each of them via an index into
199 /// the AttributeSet object. The function attributes are at index
200 /// `AttributeSet::FunctionIndex', the return value is at index
201 /// `AttributeSet::ReturnIndex', and the attributes for the parameters start at
202 /// index `1'.
203 class AttributeSet {
204 public:
205   enum AttrIndex : unsigned {
206     ReturnIndex = 0U,
207     FunctionIndex = ~0U
208   };
209 
210 private:
211   friend class AttrBuilder;
212   friend class AttributeSetImpl;
213   friend class AttributeSetNode;
214   template <typename Ty> friend struct DenseMapInfo;
215 
216   /// \brief The attributes that we are managing. This can be null to represent
217   /// the empty attributes list.
218   AttributeSetImpl *pImpl;
219 
220   /// \brief The attributes for the specified index are returned.
221   AttributeSetNode *getAttributes(unsigned Index) const;
222 
223   /// \brief Create an AttributeSet with the specified parameters in it.
224   static AttributeSet get(LLVMContext &C,
225                           ArrayRef<std::pair<unsigned, Attribute> > Attrs);
226   static AttributeSet get(LLVMContext &C,
227                           ArrayRef<std::pair<unsigned,
228                                              AttributeSetNode*> > Attrs);
229 
230   static AttributeSet getImpl(LLVMContext &C,
231                               ArrayRef<std::pair<unsigned,
232                                                  AttributeSetNode*> > Attrs);
233 
AttributeSet(AttributeSetImpl * LI)234   explicit AttributeSet(AttributeSetImpl *LI) : pImpl(LI) {}
235 
236 public:
AttributeSet()237   AttributeSet() : pImpl(nullptr) {}
238 
239   //===--------------------------------------------------------------------===//
240   // AttributeSet Construction and Mutation
241   //===--------------------------------------------------------------------===//
242 
243   /// \brief Return an AttributeSet with the specified parameters in it.
244   static AttributeSet get(LLVMContext &C, ArrayRef<AttributeSet> Attrs);
245   static AttributeSet get(LLVMContext &C, unsigned Index,
246                           ArrayRef<Attribute::AttrKind> Kinds);
247   static AttributeSet get(LLVMContext &C, unsigned Index,
248                           ArrayRef<StringRef> Kind);
249   static AttributeSet get(LLVMContext &C, unsigned Index, const AttrBuilder &B);
250 
251   /// \brief Add an attribute to the attribute set at the given index. Because
252   /// attribute sets are immutable, this returns a new set.
253   AttributeSet addAttribute(LLVMContext &C, unsigned Index,
254                             Attribute::AttrKind Kind) const;
255 
256   /// \brief Add an attribute to the attribute set at the given index. Because
257   /// attribute sets are immutable, this returns a new set.
258   AttributeSet addAttribute(LLVMContext &C, unsigned Index, StringRef Kind,
259                             StringRef Value = StringRef()) const;
260 
261   /// Add an attribute to the attribute set at the given indices. Because
262   /// attribute sets are immutable, this returns a new set.
263   AttributeSet addAttribute(LLVMContext &C, ArrayRef<unsigned> Indices,
264                             Attribute A) const;
265 
266   /// \brief Add attributes to the attribute set at the given index. Because
267   /// attribute sets are immutable, this returns a new set.
268   AttributeSet addAttributes(LLVMContext &C, unsigned Index,
269                              AttributeSet Attrs) const;
270 
271   /// \brief Remove the specified attribute at the specified index from this
272   /// attribute list. Because attribute lists are immutable, this returns the
273   /// new list.
274   AttributeSet removeAttribute(LLVMContext &C, unsigned Index,
275                                Attribute::AttrKind Kind) const;
276 
277   /// \brief Remove the specified attribute at the specified index from this
278   /// attribute list. Because attribute lists are immutable, this returns the
279   /// new list.
280   AttributeSet removeAttribute(LLVMContext &C, unsigned Index,
281                                StringRef Kind) const;
282 
283   /// \brief Remove the specified attributes at the specified index from this
284   /// attribute list. Because attribute lists are immutable, this returns the
285   /// new list.
286   AttributeSet removeAttributes(LLVMContext &C, unsigned Index,
287                                 AttributeSet Attrs) const;
288 
289   /// \brief Remove the specified attributes at the specified index from this
290   /// attribute list. Because attribute lists are immutable, this returns the
291   /// new list.
292   AttributeSet removeAttributes(LLVMContext &C, unsigned Index,
293                                 const AttrBuilder &Attrs) const;
294 
295   /// \brief Add the dereferenceable attribute to the attribute set at the given
296   /// index. Because attribute sets are immutable, this returns a new set.
297   AttributeSet addDereferenceableAttr(LLVMContext &C, unsigned Index,
298                                       uint64_t Bytes) const;
299 
300   /// \brief Add the dereferenceable_or_null attribute to the attribute set at
301   /// the given index. Because attribute sets are immutable, this returns a new
302   /// set.
303   AttributeSet addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index,
304                                             uint64_t Bytes) const;
305 
306   /// Add the allocsize attribute to the attribute set at the given index.
307   /// Because attribute sets are immutable, this returns a new set.
308   AttributeSet addAllocSizeAttr(LLVMContext &C, unsigned Index,
309                                 unsigned ElemSizeArg,
310                                 const Optional<unsigned> &NumElemsArg);
311 
312   //===--------------------------------------------------------------------===//
313   // AttributeSet Accessors
314   //===--------------------------------------------------------------------===//
315 
316   /// \brief Retrieve the LLVM context.
317   LLVMContext &getContext() const;
318 
319   /// \brief The attributes for the specified index are returned.
320   AttributeSet getParamAttributes(unsigned Index) const;
321 
322   /// \brief The attributes for the ret value are returned.
323   AttributeSet getRetAttributes() const;
324 
325   /// \brief The function attributes are returned.
326   AttributeSet getFnAttributes() const;
327 
328   /// \brief Return true if the attribute exists at the given index.
329   bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const;
330 
331   /// \brief Return true if the attribute exists at the given index.
332   bool hasAttribute(unsigned Index, StringRef Kind) const;
333 
334   /// \brief Return true if attribute exists at the given index.
335   bool hasAttributes(unsigned Index) const;
336 
337   /// \brief Equivalent to hasAttribute(AttributeSet::FunctionIndex, Kind) but
338   /// may be faster.
339   bool hasFnAttribute(Attribute::AttrKind Kind) const;
340 
341   /// \brief Equivalent to hasAttribute(AttributeSet::FunctionIndex, Kind) but
342   /// may be faster.
343   bool hasFnAttribute(StringRef Kind) const;
344 
345   /// \brief Return true if the specified attribute is set for at least one
346   /// parameter or for the return value. If Index is not nullptr, the index
347   /// of a parameter with the specified attribute is provided.
348   bool hasAttrSomewhere(Attribute::AttrKind Kind,
349                         unsigned *Index = nullptr) const;
350 
351   /// \brief Return the attribute object that exists at the given index.
352   Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const;
353 
354   /// \brief Return the attribute object that exists at the given index.
355   Attribute getAttribute(unsigned Index, StringRef Kind) const;
356 
357   /// \brief Return the alignment for the specified function parameter.
358   unsigned getParamAlignment(unsigned Index) const;
359 
360   /// \brief Get the stack alignment.
361   unsigned getStackAlignment(unsigned Index) const;
362 
363   /// \brief Get the number of dereferenceable bytes (or zero if unknown).
364   uint64_t getDereferenceableBytes(unsigned Index) const;
365 
366   /// \brief Get the number of dereferenceable_or_null bytes (or zero if
367   /// unknown).
368   uint64_t getDereferenceableOrNullBytes(unsigned Index) const;
369 
370   /// Get the allocsize argument numbers (or pair(0, 0) if unknown).
371   std::pair<unsigned, Optional<unsigned>>
372   getAllocSizeArgs(unsigned Index) const;
373 
374   /// \brief Return the attributes at the index as a string.
375   std::string getAsString(unsigned Index, bool InAttrGrp = false) const;
376 
377   typedef ArrayRef<Attribute>::iterator iterator;
378 
379   iterator begin(unsigned Slot) const;
380   iterator end(unsigned Slot) const;
381 
382   /// operator==/!= - Provide equality predicates.
383   bool operator==(const AttributeSet &RHS) const {
384     return pImpl == RHS.pImpl;
385   }
386   bool operator!=(const AttributeSet &RHS) const {
387     return pImpl != RHS.pImpl;
388   }
389 
390   //===--------------------------------------------------------------------===//
391   // AttributeSet Introspection
392   //===--------------------------------------------------------------------===//
393 
394   /// \brief Return a raw pointer that uniquely identifies this attribute list.
getRawPointer()395   void *getRawPointer() const {
396     return pImpl;
397   }
398 
399   /// \brief Return true if there are no attributes.
isEmpty()400   bool isEmpty() const {
401     return getNumSlots() == 0;
402   }
403 
404   /// \brief Return the number of slots used in this attribute list.  This is
405   /// the number of arguments that have an attribute set on them (including the
406   /// function itself).
407   unsigned getNumSlots() const;
408 
409   /// \brief Return the index for the given slot.
410   unsigned getSlotIndex(unsigned Slot) const;
411 
412   /// \brief Return the attributes at the given slot.
413   AttributeSet getSlotAttributes(unsigned Slot) const;
414 
415   void dump() const;
416 };
417 
418 //===----------------------------------------------------------------------===//
419 /// \class
420 /// \brief Provide DenseMapInfo for AttributeSet.
421 template<> struct DenseMapInfo<AttributeSet> {
422   static inline AttributeSet getEmptyKey() {
423     uintptr_t Val = static_cast<uintptr_t>(-1);
424     Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
425     return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
426   }
427   static inline AttributeSet getTombstoneKey() {
428     uintptr_t Val = static_cast<uintptr_t>(-2);
429     Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
430     return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
431   }
432   static unsigned getHashValue(AttributeSet AS) {
433     return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
434            (unsigned((uintptr_t)AS.pImpl) >> 9);
435   }
436   static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
437 };
438 
439 //===----------------------------------------------------------------------===//
440 /// \class
441 /// \brief This class is used in conjunction with the Attribute::get method to
442 /// create an Attribute object. The object itself is uniquified. The Builder's
443 /// value, however, is not. So this can be used as a quick way to test for
444 /// equality, presence of attributes, etc.
445 class AttrBuilder {
446   std::bitset<Attribute::EndAttrKinds> Attrs;
447   std::map<std::string, std::string> TargetDepAttrs;
448   uint64_t Alignment;
449   uint64_t StackAlignment;
450   uint64_t DerefBytes;
451   uint64_t DerefOrNullBytes;
452   uint64_t AllocSizeArgs;
453 
454 public:
455   AttrBuilder()
456       : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
457         DerefOrNullBytes(0), AllocSizeArgs(0) {}
458   AttrBuilder(const Attribute &A)
459       : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
460         DerefOrNullBytes(0), AllocSizeArgs(0) {
461     addAttribute(A);
462   }
463   AttrBuilder(AttributeSet AS, unsigned Idx);
464 
465   void clear();
466 
467   /// \brief Add an attribute to the builder.
468   AttrBuilder &addAttribute(Attribute::AttrKind Val);
469 
470   /// \brief Add the Attribute object to the builder.
471   AttrBuilder &addAttribute(Attribute A);
472 
473   /// \brief Add the target-dependent attribute to the builder.
474   AttrBuilder &addAttribute(StringRef A, StringRef V = StringRef());
475 
476   /// \brief Remove an attribute from the builder.
477   AttrBuilder &removeAttribute(Attribute::AttrKind Val);
478 
479   /// \brief Remove the attributes from the builder.
480   AttrBuilder &removeAttributes(AttributeSet A, uint64_t Index);
481 
482   /// \brief Remove the target-dependent attribute to the builder.
483   AttrBuilder &removeAttribute(StringRef A);
484 
485   /// \brief Add the attributes from the builder.
486   AttrBuilder &merge(const AttrBuilder &B);
487 
488   /// \brief Remove the attributes from the builder.
489   AttrBuilder &remove(const AttrBuilder &B);
490 
491   /// \brief Return true if the builder has any attribute that's in the
492   /// specified builder.
493   bool overlaps(const AttrBuilder &B) const;
494 
495   /// \brief Return true if the builder has the specified attribute.
496   bool contains(Attribute::AttrKind A) const {
497     assert((unsigned)A < Attribute::EndAttrKinds && "Attribute out of range!");
498     return Attrs[A];
499   }
500 
501   /// \brief Return true if the builder has the specified target-dependent
502   /// attribute.
503   bool contains(StringRef A) const;
504 
505   /// \brief Return true if the builder has IR-level attributes.
506   bool hasAttributes() const;
507 
508   /// \brief Return true if the builder has any attribute that's in the
509   /// specified attribute.
510   bool hasAttributes(AttributeSet A, uint64_t Index) const;
511 
512   /// \brief Return true if the builder has an alignment attribute.
513   bool hasAlignmentAttr() const;
514 
515   /// \brief Retrieve the alignment attribute, if it exists.
516   uint64_t getAlignment() const { return Alignment; }
517 
518   /// \brief Retrieve the stack alignment attribute, if it exists.
519   uint64_t getStackAlignment() const { return StackAlignment; }
520 
521   /// \brief Retrieve the number of dereferenceable bytes, if the
522   /// dereferenceable attribute exists (zero is returned otherwise).
523   uint64_t getDereferenceableBytes() const { return DerefBytes; }
524 
525   /// \brief Retrieve the number of dereferenceable_or_null bytes, if the
526   /// dereferenceable_or_null attribute exists (zero is returned otherwise).
527   uint64_t getDereferenceableOrNullBytes() const { return DerefOrNullBytes; }
528 
529   /// Retrieve the allocsize args, if the allocsize attribute exists.  If it
530   /// doesn't exist, pair(0, 0) is returned.
531   std::pair<unsigned, Optional<unsigned>> getAllocSizeArgs() const;
532 
533   /// \brief This turns an int alignment (which must be a power of 2) into the
534   /// form used internally in Attribute.
535   AttrBuilder &addAlignmentAttr(unsigned Align);
536 
537   /// \brief This turns an int stack alignment (which must be a power of 2) into
538   /// the form used internally in Attribute.
539   AttrBuilder &addStackAlignmentAttr(unsigned Align);
540 
541   /// \brief This turns the number of dereferenceable bytes into the form used
542   /// internally in Attribute.
543   AttrBuilder &addDereferenceableAttr(uint64_t Bytes);
544 
545   /// \brief This turns the number of dereferenceable_or_null bytes into the
546   /// form used internally in Attribute.
547   AttrBuilder &addDereferenceableOrNullAttr(uint64_t Bytes);
548 
549   /// This turns one (or two) ints into the form used internally in Attribute.
550   AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
551                                 const Optional<unsigned> &NumElemsArg);
552 
553   /// Add an allocsize attribute, using the representation returned by
554   /// Attribute.getIntValue().
555   AttrBuilder &addAllocSizeAttrFromRawRepr(uint64_t RawAllocSizeRepr);
556 
557   /// \brief Return true if the builder contains no target-independent
558   /// attributes.
559   bool empty() const { return Attrs.none(); }
560 
561   // Iterators for target-dependent attributes.
562   typedef std::pair<std::string, std::string>                td_type;
563   typedef std::map<std::string, std::string>::iterator       td_iterator;
564   typedef std::map<std::string, std::string>::const_iterator td_const_iterator;
565   typedef llvm::iterator_range<td_iterator>                  td_range;
566   typedef llvm::iterator_range<td_const_iterator>            td_const_range;
567 
568   td_iterator td_begin()             { return TargetDepAttrs.begin(); }
569   td_iterator td_end()               { return TargetDepAttrs.end(); }
570 
571   td_const_iterator td_begin() const { return TargetDepAttrs.begin(); }
572   td_const_iterator td_end() const   { return TargetDepAttrs.end(); }
573 
574   td_range td_attrs() { return td_range(td_begin(), td_end()); }
575   td_const_range td_attrs() const {
576     return td_const_range(td_begin(), td_end());
577   }
578 
579   bool td_empty() const              { return TargetDepAttrs.empty(); }
580 
581   bool operator==(const AttrBuilder &B);
582   bool operator!=(const AttrBuilder &B) {
583     return !(*this == B);
584   }
585 };
586 
587 namespace AttributeFuncs {
588 
589 /// \brief Which attributes cannot be applied to a type.
590 AttrBuilder typeIncompatible(Type *Ty);
591 
592 /// \returns Return true if the two functions have compatible target-independent
593 /// attributes for inlining purposes.
594 bool areInlineCompatible(const Function &Caller, const Function &Callee);
595 
596 /// \brief Merge caller's and callee's attributes.
597 void mergeAttributesForInlining(Function &Caller, const Function &Callee);
598 
599 } // end AttributeFuncs namespace
600 
601 } // end llvm namespace
602 
603 #endif
604