1 //==-- CGFunctionInfo.h - Representation of function argument/return types -==//
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 // Defines CGFunctionInfo and associated types used in representing the
11 // LLVM source types and ABI-coerced types for function arguments and
12 // return values.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
17 #define LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
18 
19 #include "clang/AST/CanonicalType.h"
20 #include "clang/AST/CharUnits.h"
21 #include "clang/AST/Type.h"
22 #include "llvm/IR/DerivedTypes.h"
23 #include "llvm/ADT/FoldingSet.h"
24 #include "llvm/Support/TrailingObjects.h"
25 #include <cassert>
26 
27 namespace clang {
28 class Decl;
29 
30 namespace CodeGen {
31 
32 /// ABIArgInfo - Helper class to encapsulate information about how a
33 /// specific C type should be passed to or returned from a function.
34 class ABIArgInfo {
35 public:
36   enum Kind : uint8_t {
37     /// Direct - Pass the argument directly using the normal converted LLVM
38     /// type, or by coercing to another specified type stored in
39     /// 'CoerceToType').  If an offset is specified (in UIntData), then the
40     /// argument passed is offset by some number of bytes in the memory
41     /// representation. A dummy argument is emitted before the real argument
42     /// if the specified type stored in "PaddingType" is not zero.
43     Direct,
44 
45     /// Extend - Valid only for integer argument types. Same as 'direct'
46     /// but also emit a zero/sign extension attribute.
47     Extend,
48 
49     /// Indirect - Pass the argument indirectly via a hidden pointer
50     /// with the specified alignment (0 indicates default alignment).
51     Indirect,
52 
53     /// Ignore - Ignore the argument (treat as void). Useful for void and
54     /// empty structs.
55     Ignore,
56 
57     /// Expand - Only valid for aggregate argument types. The structure should
58     /// be expanded into consecutive arguments for its constituent fields.
59     /// Currently expand is only allowed on structures whose fields
60     /// are all scalar types or are themselves expandable types.
61     Expand,
62 
63     /// CoerceAndExpand - Only valid for aggregate argument types. The
64     /// structure should be expanded into consecutive arguments corresponding
65     /// to the non-array elements of the type stored in CoerceToType.
66     /// Array elements in the type are assumed to be padding and skipped.
67     CoerceAndExpand,
68 
69     /// InAlloca - Pass the argument directly using the LLVM inalloca attribute.
70     /// This is similar to indirect with byval, except it only applies to
71     /// arguments stored in memory and forbids any implicit copies.  When
72     /// applied to a return type, it means the value is returned indirectly via
73     /// an implicit sret parameter stored in the argument struct.
74     InAlloca,
75     KindFirst = Direct,
76     KindLast = InAlloca
77   };
78 
79 private:
80   llvm::Type *TypeData; // canHaveCoerceToType()
81   union {
82     llvm::Type *PaddingType; // canHavePaddingType()
83     llvm::Type *UnpaddedCoerceAndExpandType; // isCoerceAndExpand()
84   };
85   union {
86     unsigned DirectOffset;     // isDirect() || isExtend()
87     unsigned IndirectAlign;    // isIndirect()
88     unsigned AllocaFieldIndex; // isInAlloca()
89   };
90   Kind TheKind;
91   bool PaddingInReg : 1;
92   bool InAllocaSRet : 1;    // isInAlloca()
93   bool IndirectByVal : 1;   // isIndirect()
94   bool IndirectRealign : 1; // isIndirect()
95   bool SRetAfterThis : 1;   // isIndirect()
96   bool InReg : 1;           // isDirect() || isExtend() || isIndirect()
97   bool CanBeFlattened: 1;   // isDirect()
98 
99   bool canHavePaddingType() const {
100     return isDirect() || isExtend() || isIndirect() || isExpand();
101   }
102   void setPaddingType(llvm::Type *T) {
103     assert(canHavePaddingType());
104     PaddingType = T;
105   }
106 
107   void setUnpaddedCoerceToType(llvm::Type *T) {
108     assert(isCoerceAndExpand());
109     UnpaddedCoerceAndExpandType = T;
110   }
111 
112   ABIArgInfo(Kind K)
113       : TheKind(K), PaddingInReg(false), InReg(false) {
114   }
115 
116 public:
117   ABIArgInfo()
118       : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0),
119         TheKind(Direct), PaddingInReg(false), InReg(false) {}
120 
121   static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
122                               llvm::Type *Padding = nullptr,
123                               bool CanBeFlattened = true) {
124     auto AI = ABIArgInfo(Direct);
125     AI.setCoerceToType(T);
126     AI.setPaddingType(Padding);
127     AI.setDirectOffset(Offset);
128     AI.setCanBeFlattened(CanBeFlattened);
129     return AI;
130   }
131   static ABIArgInfo getDirectInReg(llvm::Type *T = nullptr) {
132     auto AI = getDirect(T);
133     AI.setInReg(true);
134     return AI;
135   }
136   static ABIArgInfo getExtend(llvm::Type *T = nullptr) {
137     auto AI = ABIArgInfo(Extend);
138     AI.setCoerceToType(T);
139     AI.setPaddingType(nullptr);
140     AI.setDirectOffset(0);
141     return AI;
142   }
143   static ABIArgInfo getExtendInReg(llvm::Type *T = nullptr) {
144     auto AI = getExtend(T);
145     AI.setInReg(true);
146     return AI;
147   }
148   static ABIArgInfo getIgnore() {
149     return ABIArgInfo(Ignore);
150   }
151   static ABIArgInfo getIndirect(CharUnits Alignment, bool ByVal = true,
152                                 bool Realign = false,
153                                 llvm::Type *Padding = nullptr) {
154     auto AI = ABIArgInfo(Indirect);
155     AI.setIndirectAlign(Alignment);
156     AI.setIndirectByVal(ByVal);
157     AI.setIndirectRealign(Realign);
158     AI.setSRetAfterThis(false);
159     AI.setPaddingType(Padding);
160     return AI;
161   }
162   static ABIArgInfo getIndirectInReg(CharUnits Alignment, bool ByVal = true,
163                                      bool Realign = false) {
164     auto AI = getIndirect(Alignment, ByVal, Realign);
165     AI.setInReg(true);
166     return AI;
167   }
168   static ABIArgInfo getInAlloca(unsigned FieldIndex) {
169     auto AI = ABIArgInfo(InAlloca);
170     AI.setInAllocaFieldIndex(FieldIndex);
171     return AI;
172   }
173   static ABIArgInfo getExpand() {
174     auto AI = ABIArgInfo(Expand);
175     AI.setPaddingType(nullptr);
176     return AI;
177   }
178   static ABIArgInfo getExpandWithPadding(bool PaddingInReg,
179                                          llvm::Type *Padding) {
180     auto AI = getExpand();
181     AI.setPaddingInReg(PaddingInReg);
182     AI.setPaddingType(Padding);
183     return AI;
184   }
185 
186   /// \param unpaddedCoerceToType The coerce-to type with padding elements
187   ///   removed, canonicalized to a single element if it would otherwise
188   ///   have exactly one element.
189   static ABIArgInfo getCoerceAndExpand(llvm::StructType *coerceToType,
190                                        llvm::Type *unpaddedCoerceToType) {
191 #ifndef NDEBUG
192     // Sanity checks on unpaddedCoerceToType.
193 
194     // Assert that we only have a struct type if there are multiple elements.
195     auto unpaddedStruct = dyn_cast<llvm::StructType>(unpaddedCoerceToType);
196     assert(!unpaddedStruct || unpaddedStruct->getNumElements() != 1);
197 
198     // Assert that all the non-padding elements have a corresponding element
199     // in the unpadded type.
200     unsigned unpaddedIndex = 0;
201     for (auto eltType : coerceToType->elements()) {
202       if (isPaddingForCoerceAndExpand(eltType)) continue;
203       if (unpaddedStruct) {
204         assert(unpaddedStruct->getElementType(unpaddedIndex) == eltType);
205       } else {
206         assert(unpaddedIndex == 0 && unpaddedCoerceToType == eltType);
207       }
208       unpaddedIndex++;
209     }
210 
211     // Assert that there aren't extra elements in the unpadded type.
212     if (unpaddedStruct) {
213       assert(unpaddedStruct->getNumElements() == unpaddedIndex);
214     } else {
215       assert(unpaddedIndex == 1);
216     }
217 #endif
218 
219     auto AI = ABIArgInfo(CoerceAndExpand);
220     AI.setCoerceToType(coerceToType);
221     AI.setUnpaddedCoerceToType(unpaddedCoerceToType);
222     return AI;
223   }
224 
225   static bool isPaddingForCoerceAndExpand(llvm::Type *eltType) {
226     if (eltType->isArrayTy()) {
227       assert(eltType->getArrayElementType()->isIntegerTy(8));
228       return true;
229     } else {
230       return false;
231     }
232   }
233 
234   Kind getKind() const { return TheKind; }
235   bool isDirect() const { return TheKind == Direct; }
236   bool isInAlloca() const { return TheKind == InAlloca; }
237   bool isExtend() const { return TheKind == Extend; }
238   bool isIgnore() const { return TheKind == Ignore; }
239   bool isIndirect() const { return TheKind == Indirect; }
240   bool isExpand() const { return TheKind == Expand; }
241   bool isCoerceAndExpand() const { return TheKind == CoerceAndExpand; }
242 
243   bool canHaveCoerceToType() const {
244     return isDirect() || isExtend() || isCoerceAndExpand();
245   }
246 
247   // Direct/Extend accessors
248   unsigned getDirectOffset() const {
249     assert((isDirect() || isExtend()) && "Not a direct or extend kind");
250     return DirectOffset;
251   }
252   void setDirectOffset(unsigned Offset) {
253     assert((isDirect() || isExtend()) && "Not a direct or extend kind");
254     DirectOffset = Offset;
255   }
256 
257   llvm::Type *getPaddingType() const {
258     return (canHavePaddingType() ? PaddingType : nullptr);
259   }
260 
261   bool getPaddingInReg() const {
262     return PaddingInReg;
263   }
264   void setPaddingInReg(bool PIR) {
265     PaddingInReg = PIR;
266   }
267 
268   llvm::Type *getCoerceToType() const {
269     assert(canHaveCoerceToType() && "Invalid kind!");
270     return TypeData;
271   }
272 
273   void setCoerceToType(llvm::Type *T) {
274     assert(canHaveCoerceToType() && "Invalid kind!");
275     TypeData = T;
276   }
277 
278   llvm::StructType *getCoerceAndExpandType() const {
279     assert(isCoerceAndExpand());
280     return cast<llvm::StructType>(TypeData);
281   }
282 
283   llvm::Type *getUnpaddedCoerceAndExpandType() const {
284     assert(isCoerceAndExpand());
285     return UnpaddedCoerceAndExpandType;
286   }
287 
288   ArrayRef<llvm::Type *>getCoerceAndExpandTypeSequence() const {
289     assert(isCoerceAndExpand());
290     if (auto structTy =
291           dyn_cast<llvm::StructType>(UnpaddedCoerceAndExpandType)) {
292       return structTy->elements();
293     } else {
294       return llvm::makeArrayRef(&UnpaddedCoerceAndExpandType, 1);
295     }
296   }
297 
298   bool getInReg() const {
299     assert((isDirect() || isExtend() || isIndirect()) && "Invalid kind!");
300     return InReg;
301   }
302 
303   void setInReg(bool IR) {
304     assert((isDirect() || isExtend() || isIndirect()) && "Invalid kind!");
305     InReg = IR;
306   }
307 
308   // Indirect accessors
309   CharUnits getIndirectAlign() const {
310     assert(isIndirect() && "Invalid kind!");
311     return CharUnits::fromQuantity(IndirectAlign);
312   }
313   void setIndirectAlign(CharUnits IA) {
314     assert(isIndirect() && "Invalid kind!");
315     IndirectAlign = IA.getQuantity();
316   }
317 
318   bool getIndirectByVal() const {
319     assert(isIndirect() && "Invalid kind!");
320     return IndirectByVal;
321   }
322   void setIndirectByVal(bool IBV) {
323     assert(isIndirect() && "Invalid kind!");
324     IndirectByVal = IBV;
325   }
326 
327   bool getIndirectRealign() const {
328     assert(isIndirect() && "Invalid kind!");
329     return IndirectRealign;
330   }
331   void setIndirectRealign(bool IR) {
332     assert(isIndirect() && "Invalid kind!");
333     IndirectRealign = IR;
334   }
335 
336   bool isSRetAfterThis() const {
337     assert(isIndirect() && "Invalid kind!");
338     return SRetAfterThis;
339   }
340   void setSRetAfterThis(bool AfterThis) {
341     assert(isIndirect() && "Invalid kind!");
342     SRetAfterThis = AfterThis;
343   }
344 
345   unsigned getInAllocaFieldIndex() const {
346     assert(isInAlloca() && "Invalid kind!");
347     return AllocaFieldIndex;
348   }
349   void setInAllocaFieldIndex(unsigned FieldIndex) {
350     assert(isInAlloca() && "Invalid kind!");
351     AllocaFieldIndex = FieldIndex;
352   }
353 
354   /// \brief Return true if this field of an inalloca struct should be returned
355   /// to implement a struct return calling convention.
356   bool getInAllocaSRet() const {
357     assert(isInAlloca() && "Invalid kind!");
358     return InAllocaSRet;
359   }
360 
361   void setInAllocaSRet(bool SRet) {
362     assert(isInAlloca() && "Invalid kind!");
363     InAllocaSRet = SRet;
364   }
365 
366   bool getCanBeFlattened() const {
367     assert(isDirect() && "Invalid kind!");
368     return CanBeFlattened;
369   }
370 
371   void setCanBeFlattened(bool Flatten) {
372     assert(isDirect() && "Invalid kind!");
373     CanBeFlattened = Flatten;
374   }
375 
376   void dump() const;
377 };
378 
379 /// A class for recording the number of arguments that a function
380 /// signature requires.
381 class RequiredArgs {
382   /// The number of required arguments, or ~0 if the signature does
383   /// not permit optional arguments.
384   unsigned NumRequired;
385 public:
386   enum All_t { All };
387 
388   RequiredArgs(All_t _) : NumRequired(~0U) {}
389   explicit RequiredArgs(unsigned n) : NumRequired(n) {
390     assert(n != ~0U);
391   }
392 
393   /// Compute the arguments required by the given formal prototype,
394   /// given that there may be some additional, non-formal arguments
395   /// in play.
396   static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype,
397                                        unsigned additional) {
398     if (!prototype->isVariadic()) return All;
399     return RequiredArgs(prototype->getNumParams() + additional);
400   }
401 
402   static RequiredArgs forPrototype(const FunctionProtoType *prototype) {
403     return forPrototypePlus(prototype, 0);
404   }
405 
406   static RequiredArgs forPrototype(CanQual<FunctionProtoType> prototype) {
407     return forPrototype(prototype.getTypePtr());
408   }
409 
410   static RequiredArgs forPrototypePlus(CanQual<FunctionProtoType> prototype,
411                                        unsigned additional) {
412     return forPrototypePlus(prototype.getTypePtr(), additional);
413   }
414 
415   bool allowsOptionalArgs() const { return NumRequired != ~0U; }
416   unsigned getNumRequiredArgs() const {
417     assert(allowsOptionalArgs());
418     return NumRequired;
419   }
420 
421   unsigned getOpaqueData() const { return NumRequired; }
422   static RequiredArgs getFromOpaqueData(unsigned value) {
423     if (value == ~0U) return All;
424     return RequiredArgs(value);
425   }
426 };
427 
428 // Implementation detail of CGFunctionInfo, factored out so it can be named
429 // in the TrailingObjects base class of CGFunctionInfo.
430 struct CGFunctionInfoArgInfo {
431   CanQualType type;
432   ABIArgInfo info;
433 };
434 
435 /// CGFunctionInfo - Class to encapsulate the information about a
436 /// function definition.
437 class CGFunctionInfo final
438     : public llvm::FoldingSetNode,
439       private llvm::TrailingObjects<CGFunctionInfo, CGFunctionInfoArgInfo,
440                                     FunctionProtoType::ExtParameterInfo> {
441   typedef CGFunctionInfoArgInfo ArgInfo;
442   typedef FunctionProtoType::ExtParameterInfo ExtParameterInfo;
443 
444   /// The LLVM::CallingConv to use for this function (as specified by the
445   /// user).
446   unsigned CallingConvention : 8;
447 
448   /// The LLVM::CallingConv to actually use for this function, which may
449   /// depend on the ABI.
450   unsigned EffectiveCallingConvention : 8;
451 
452   /// The clang::CallingConv that this was originally created with.
453   unsigned ASTCallingConvention : 8;
454 
455   /// Whether this is an instance method.
456   unsigned InstanceMethod : 1;
457 
458   /// Whether this is a chain call.
459   unsigned ChainCall : 1;
460 
461   /// Whether this function is noreturn.
462   unsigned NoReturn : 1;
463 
464   /// Whether this function is returns-retained.
465   unsigned ReturnsRetained : 1;
466 
467   /// How many arguments to pass inreg.
468   unsigned HasRegParm : 1;
469   unsigned RegParm : 3;
470 
471   RequiredArgs Required;
472 
473   /// The struct representing all arguments passed in memory.  Only used when
474   /// passing non-trivial types with inalloca.  Not part of the profile.
475   llvm::StructType *ArgStruct;
476   unsigned ArgStructAlign : 31;
477   unsigned HasExtParameterInfos : 1;
478 
479   unsigned NumArgs;
480 
481   ArgInfo *getArgsBuffer() {
482     return getTrailingObjects<ArgInfo>();
483   }
484   const ArgInfo *getArgsBuffer() const {
485     return getTrailingObjects<ArgInfo>();
486   }
487 
488   ExtParameterInfo *getExtParameterInfosBuffer() {
489     return getTrailingObjects<ExtParameterInfo>();
490   }
491   const ExtParameterInfo *getExtParameterInfosBuffer() const{
492     return getTrailingObjects<ExtParameterInfo>();
493   }
494 
495   CGFunctionInfo() : Required(RequiredArgs::All) {}
496 
497 public:
498   static CGFunctionInfo *create(unsigned llvmCC,
499                                 bool instanceMethod,
500                                 bool chainCall,
501                                 const FunctionType::ExtInfo &extInfo,
502                                 ArrayRef<ExtParameterInfo> paramInfos,
503                                 CanQualType resultType,
504                                 ArrayRef<CanQualType> argTypes,
505                                 RequiredArgs required);
506   void operator delete(void *p) { ::operator delete(p); }
507 
508   // Friending class TrailingObjects is apparently not good enough for MSVC,
509   // so these have to be public.
510   friend class TrailingObjects;
511   size_t numTrailingObjects(OverloadToken<ArgInfo>) const {
512     return NumArgs + 1;
513   }
514   size_t numTrailingObjects(OverloadToken<ExtParameterInfo>) const {
515     return (HasExtParameterInfos ? NumArgs : 0);
516   }
517 
518   typedef const ArgInfo *const_arg_iterator;
519   typedef ArgInfo *arg_iterator;
520 
521   typedef llvm::iterator_range<arg_iterator> arg_range;
522   typedef llvm::iterator_range<const_arg_iterator> arg_const_range;
523 
524   arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
525   arg_const_range arguments() const {
526     return arg_const_range(arg_begin(), arg_end());
527   }
528 
529   const_arg_iterator arg_begin() const { return getArgsBuffer() + 1; }
530   const_arg_iterator arg_end() const { return getArgsBuffer() + 1 + NumArgs; }
531   arg_iterator arg_begin() { return getArgsBuffer() + 1; }
532   arg_iterator arg_end() { return getArgsBuffer() + 1 + NumArgs; }
533 
534   unsigned  arg_size() const { return NumArgs; }
535 
536   bool isVariadic() const { return Required.allowsOptionalArgs(); }
537   RequiredArgs getRequiredArgs() const { return Required; }
538   unsigned getNumRequiredArgs() const {
539     return isVariadic() ? getRequiredArgs().getNumRequiredArgs() : arg_size();
540   }
541 
542   bool isInstanceMethod() const { return InstanceMethod; }
543 
544   bool isChainCall() const { return ChainCall; }
545 
546   bool isNoReturn() const { return NoReturn; }
547 
548   /// In ARC, whether this function retains its return value.  This
549   /// is not always reliable for call sites.
550   bool isReturnsRetained() const { return ReturnsRetained; }
551 
552   /// getASTCallingConvention() - Return the AST-specified calling
553   /// convention.
554   CallingConv getASTCallingConvention() const {
555     return CallingConv(ASTCallingConvention);
556   }
557 
558   /// getCallingConvention - Return the user specified calling
559   /// convention, which has been translated into an LLVM CC.
560   unsigned getCallingConvention() const { return CallingConvention; }
561 
562   /// getEffectiveCallingConvention - Return the actual calling convention to
563   /// use, which may depend on the ABI.
564   unsigned getEffectiveCallingConvention() const {
565     return EffectiveCallingConvention;
566   }
567   void setEffectiveCallingConvention(unsigned Value) {
568     EffectiveCallingConvention = Value;
569   }
570 
571   bool getHasRegParm() const { return HasRegParm; }
572   unsigned getRegParm() const { return RegParm; }
573 
574   FunctionType::ExtInfo getExtInfo() const {
575     return FunctionType::ExtInfo(isNoReturn(),
576                                  getHasRegParm(), getRegParm(),
577                                  getASTCallingConvention(),
578                                  isReturnsRetained());
579   }
580 
581   CanQualType getReturnType() const { return getArgsBuffer()[0].type; }
582 
583   ABIArgInfo &getReturnInfo() { return getArgsBuffer()[0].info; }
584   const ABIArgInfo &getReturnInfo() const { return getArgsBuffer()[0].info; }
585 
586   ArrayRef<ExtParameterInfo> getExtParameterInfos() const {
587     if (!HasExtParameterInfos) return {};
588     return llvm::makeArrayRef(getExtParameterInfosBuffer(), NumArgs);
589   }
590   ExtParameterInfo getExtParameterInfo(unsigned argIndex) const {
591     assert(argIndex <= NumArgs);
592     if (!HasExtParameterInfos) return ExtParameterInfo();
593     return getExtParameterInfos()[argIndex];
594   }
595 
596   /// \brief Return true if this function uses inalloca arguments.
597   bool usesInAlloca() const { return ArgStruct; }
598 
599   /// \brief Get the struct type used to represent all the arguments in memory.
600   llvm::StructType *getArgStruct() const { return ArgStruct; }
601   CharUnits getArgStructAlignment() const {
602     return CharUnits::fromQuantity(ArgStructAlign);
603   }
604   void setArgStruct(llvm::StructType *Ty, CharUnits Align) {
605     ArgStruct = Ty;
606     ArgStructAlign = Align.getQuantity();
607   }
608 
609   void Profile(llvm::FoldingSetNodeID &ID) {
610     ID.AddInteger(getASTCallingConvention());
611     ID.AddBoolean(InstanceMethod);
612     ID.AddBoolean(ChainCall);
613     ID.AddBoolean(NoReturn);
614     ID.AddBoolean(ReturnsRetained);
615     ID.AddBoolean(HasRegParm);
616     ID.AddInteger(RegParm);
617     ID.AddInteger(Required.getOpaqueData());
618     ID.AddBoolean(HasExtParameterInfos);
619     if (HasExtParameterInfos) {
620       for (auto paramInfo : getExtParameterInfos())
621         ID.AddInteger(paramInfo.getOpaqueValue());
622     }
623     getReturnType().Profile(ID);
624     for (const auto &I : arguments())
625       I.type.Profile(ID);
626   }
627   static void Profile(llvm::FoldingSetNodeID &ID,
628                       bool InstanceMethod,
629                       bool ChainCall,
630                       const FunctionType::ExtInfo &info,
631                       ArrayRef<ExtParameterInfo> paramInfos,
632                       RequiredArgs required,
633                       CanQualType resultType,
634                       ArrayRef<CanQualType> argTypes) {
635     ID.AddInteger(info.getCC());
636     ID.AddBoolean(InstanceMethod);
637     ID.AddBoolean(ChainCall);
638     ID.AddBoolean(info.getNoReturn());
639     ID.AddBoolean(info.getProducesResult());
640     ID.AddBoolean(info.getHasRegParm());
641     ID.AddInteger(info.getRegParm());
642     ID.AddInteger(required.getOpaqueData());
643     ID.AddBoolean(!paramInfos.empty());
644     if (!paramInfos.empty()) {
645       for (auto paramInfo : paramInfos)
646         ID.AddInteger(paramInfo.getOpaqueValue());
647     }
648     resultType.Profile(ID);
649     for (ArrayRef<CanQualType>::iterator
650            i = argTypes.begin(), e = argTypes.end(); i != e; ++i) {
651       i->Profile(ID);
652     }
653   }
654 };
655 
656 /// CGCalleeInfo - Class to encapsulate the information about a callee to be
657 /// used during the generation of call/invoke instructions.
658 class CGCalleeInfo {
659   /// \brief The function proto type of the callee.
660   const FunctionProtoType *CalleeProtoTy;
661   /// \brief The function declaration of the callee.
662   const Decl *CalleeDecl;
663 
664 public:
665   explicit CGCalleeInfo() : CalleeProtoTy(nullptr), CalleeDecl(nullptr) {}
666   CGCalleeInfo(const FunctionProtoType *calleeProtoTy, const Decl *calleeDecl)
667       : CalleeProtoTy(calleeProtoTy), CalleeDecl(calleeDecl) {}
668   CGCalleeInfo(const FunctionProtoType *calleeProtoTy)
669       : CalleeProtoTy(calleeProtoTy), CalleeDecl(nullptr) {}
670   CGCalleeInfo(const Decl *calleeDecl)
671       : CalleeProtoTy(nullptr), CalleeDecl(calleeDecl) {}
672 
673   const FunctionProtoType *getCalleeFunctionProtoType() {
674     return CalleeProtoTy;
675   }
676   const Decl *getCalleeDecl() { return CalleeDecl; }
677 };
678 
679 }  // end namespace CodeGen
680 }  // end namespace clang
681 
682 #endif
683