clang  9.0.0svn
CodeGenModule.h
Go to the documentation of this file.
1 //===--- CodeGenModule.h - Per-Module state for LLVM CodeGen ----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This is the internal per-translation-unit state used for llvm translation.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
14 #define LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
15 
16 #include "CGVTables.h"
17 #include "CodeGenTypeCache.h"
18 #include "CodeGenTypes.h"
19 #include "SanitizerMetadata.h"
20 #include "clang/AST/Attr.h"
21 #include "clang/AST/DeclCXX.h"
22 #include "clang/AST/DeclObjC.h"
23 #include "clang/AST/DeclOpenMP.h"
24 #include "clang/AST/GlobalDecl.h"
25 #include "clang/AST/Mangle.h"
26 #include "clang/Basic/ABI.h"
28 #include "clang/Basic/Module.h"
30 #include "clang/Basic/XRayLists.h"
31 #include "llvm/ADT/DenseMap.h"
32 #include "llvm/ADT/SetVector.h"
33 #include "llvm/ADT/SmallPtrSet.h"
34 #include "llvm/ADT/StringMap.h"
35 #include "llvm/IR/Module.h"
36 #include "llvm/IR/ValueHandle.h"
37 #include "llvm/Transforms/Utils/SanitizerStats.h"
38 
39 namespace llvm {
40 class Module;
41 class Constant;
42 class ConstantInt;
43 class Function;
44 class GlobalValue;
45 class DataLayout;
46 class FunctionType;
47 class LLVMContext;
48 class IndexedInstrProfReader;
49 }
50 
51 namespace clang {
52 class ASTContext;
53 class AtomicType;
54 class FunctionDecl;
55 class IdentifierInfo;
56 class ObjCMethodDecl;
57 class ObjCImplementationDecl;
58 class ObjCCategoryImplDecl;
59 class ObjCProtocolDecl;
60 class ObjCEncodeExpr;
61 class BlockExpr;
62 class CharUnits;
63 class Decl;
64 class Expr;
65 class Stmt;
66 class InitListExpr;
67 class StringLiteral;
68 class NamedDecl;
69 class ValueDecl;
70 class VarDecl;
71 class LangOptions;
72 class CodeGenOptions;
73 class HeaderSearchOptions;
74 class PreprocessorOptions;
75 class DiagnosticsEngine;
76 class AnnotateAttr;
77 class CXXDestructorDecl;
78 class Module;
79 class CoverageSourceInfo;
80 
81 namespace CodeGen {
82 
83 class CallArgList;
84 class CodeGenFunction;
85 class CodeGenTBAA;
86 class CGCXXABI;
87 class CGDebugInfo;
88 class CGObjCRuntime;
89 class CGOpenCLRuntime;
90 class CGOpenMPRuntime;
91 class CGCUDARuntime;
92 class BlockFieldFlags;
93 class FunctionArgList;
94 class CoverageMappingModuleGen;
95 class TargetCodeGenInfo;
96 
97 enum ForDefinition_t : bool {
100 };
101 
103  unsigned int priority;
104  unsigned int lex_order;
105  OrderGlobalInits(unsigned int p, unsigned int l)
106  : priority(p), lex_order(l) {}
107 
108  bool operator==(const OrderGlobalInits &RHS) const {
109  return priority == RHS.priority && lex_order == RHS.lex_order;
110  }
111 
112  bool operator<(const OrderGlobalInits &RHS) const {
113  return std::tie(priority, lex_order) <
114  std::tie(RHS.priority, RHS.lex_order);
115  }
116 };
117 
119  ObjCEntrypoints() { memset(this, 0, sizeof(*this)); }
120 
121  /// void objc_alloc(id);
122  llvm::FunctionCallee objc_alloc;
123 
124  /// void objc_allocWithZone(id);
125  llvm::FunctionCallee objc_allocWithZone;
126 
127  /// void objc_alloc_init(id);
128  llvm::FunctionCallee objc_alloc_init;
129 
130  /// void objc_autoreleasePoolPop(void*);
131  llvm::FunctionCallee objc_autoreleasePoolPop;
132 
133  /// void objc_autoreleasePoolPop(void*);
134  /// Note this method is used when we are using exception handling
135  llvm::FunctionCallee objc_autoreleasePoolPopInvoke;
136 
137  /// void *objc_autoreleasePoolPush(void);
138  llvm::Function *objc_autoreleasePoolPush;
139 
140  /// id objc_autorelease(id);
141  llvm::Function *objc_autorelease;
142 
143  /// id objc_autorelease(id);
144  /// Note this is the runtime method not the intrinsic.
145  llvm::FunctionCallee objc_autoreleaseRuntimeFunction;
146 
147  /// id objc_autoreleaseReturnValue(id);
149 
150  /// void objc_copyWeak(id *dest, id *src);
151  llvm::Function *objc_copyWeak;
152 
153  /// void objc_destroyWeak(id*);
154  llvm::Function *objc_destroyWeak;
155 
156  /// id objc_initWeak(id*, id);
157  llvm::Function *objc_initWeak;
158 
159  /// id objc_loadWeak(id*);
160  llvm::Function *objc_loadWeak;
161 
162  /// id objc_loadWeakRetained(id*);
163  llvm::Function *objc_loadWeakRetained;
164 
165  /// void objc_moveWeak(id *dest, id *src);
166  llvm::Function *objc_moveWeak;
167 
168  /// id objc_retain(id);
169  llvm::Function *objc_retain;
170 
171  /// id objc_retain(id);
172  /// Note this is the runtime method not the intrinsic.
173  llvm::FunctionCallee objc_retainRuntimeFunction;
174 
175  /// id objc_retainAutorelease(id);
176  llvm::Function *objc_retainAutorelease;
177 
178  /// id objc_retainAutoreleaseReturnValue(id);
180 
181  /// id objc_retainAutoreleasedReturnValue(id);
183 
184  /// id objc_retainBlock(id);
185  llvm::Function *objc_retainBlock;
186 
187  /// void objc_release(id);
188  llvm::Function *objc_release;
189 
190  /// void objc_release(id);
191  /// Note this is the runtime method not the intrinsic.
192  llvm::FunctionCallee objc_releaseRuntimeFunction;
193 
194  /// void objc_storeStrong(id*, id);
195  llvm::Function *objc_storeStrong;
196 
197  /// id objc_storeWeak(id*, id);
198  llvm::Function *objc_storeWeak;
199 
200  /// id objc_unsafeClaimAutoreleasedReturnValue(id);
202 
203  /// A void(void) inline asm to use to mark that the return value of
204  /// a call will be immediately retain.
206 
207  /// void clang.arc.use(...);
208  llvm::Function *clang_arc_use;
209 };
210 
211 /// This class records statistics on instrumentation based profiling.
213  uint32_t VisitedInMainFile;
214  uint32_t MissingInMainFile;
215  uint32_t Visited;
216  uint32_t Missing;
217  uint32_t Mismatched;
218 
219 public:
221  : VisitedInMainFile(0), MissingInMainFile(0), Visited(0), Missing(0),
222  Mismatched(0) {}
223  /// Record that we've visited a function and whether or not that function was
224  /// in the main source file.
225  void addVisited(bool MainFile) {
226  if (MainFile)
227  ++VisitedInMainFile;
228  ++Visited;
229  }
230  /// Record that a function we've visited has no profile data.
231  void addMissing(bool MainFile) {
232  if (MainFile)
233  ++MissingInMainFile;
234  ++Missing;
235  }
236  /// Record that a function we've visited has mismatched profile data.
237  void addMismatched(bool MainFile) { ++Mismatched; }
238  /// Whether or not the stats we've gathered indicate any potential problems.
239  bool hasDiagnostics() { return Missing || Mismatched; }
240  /// Report potential problems we've found to \c Diags.
241  void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile);
242 };
243 
244 /// A pair of helper functions for a __block variable.
245 class BlockByrefHelpers : public llvm::FoldingSetNode {
246  // MSVC requires this type to be complete in order to process this
247  // header.
248 public:
249  llvm::Constant *CopyHelper;
250  llvm::Constant *DisposeHelper;
251 
252  /// The alignment of the field. This is important because
253  /// different offsets to the field within the byref struct need to
254  /// have different helper functions.
256 
257  BlockByrefHelpers(CharUnits alignment) : Alignment(alignment) {}
258  BlockByrefHelpers(const BlockByrefHelpers &) = default;
259  virtual ~BlockByrefHelpers();
260 
261  void Profile(llvm::FoldingSetNodeID &id) const {
262  id.AddInteger(Alignment.getQuantity());
263  profileImpl(id);
264  }
265  virtual void profileImpl(llvm::FoldingSetNodeID &id) const = 0;
266 
267  virtual bool needsCopy() const { return true; }
268  virtual void emitCopy(CodeGenFunction &CGF, Address dest, Address src) = 0;
269 
270  virtual bool needsDispose() const { return true; }
271  virtual void emitDispose(CodeGenFunction &CGF, Address field) = 0;
272 };
273 
274 /// This class organizes the cross-function state that is used while generating
275 /// LLVM code.
277  CodeGenModule(const CodeGenModule &) = delete;
278  void operator=(const CodeGenModule &) = delete;
279 
280 public:
281  struct Structor {
282  Structor() : Priority(0), Initializer(nullptr), AssociatedData(nullptr) {}
283  Structor(int Priority, llvm::Constant *Initializer,
284  llvm::Constant *AssociatedData)
285  : Priority(Priority), Initializer(Initializer),
286  AssociatedData(AssociatedData) {}
287  int Priority;
288  llvm::Constant *Initializer;
289  llvm::Constant *AssociatedData;
290  };
291 
292  typedef std::vector<Structor> CtorList;
293 
294 private:
295  ASTContext &Context;
296  const LangOptions &LangOpts;
297  const HeaderSearchOptions &HeaderSearchOpts; // Only used for debug info.
298  const PreprocessorOptions &PreprocessorOpts; // Only used for debug info.
299  const CodeGenOptions &CodeGenOpts;
300  llvm::Module &TheModule;
301  DiagnosticsEngine &Diags;
302  const TargetInfo &Target;
303  std::unique_ptr<CGCXXABI> ABI;
304  llvm::LLVMContext &VMContext;
305 
306  std::unique_ptr<CodeGenTBAA> TBAA;
307 
308  mutable std::unique_ptr<TargetCodeGenInfo> TheTargetCodeGenInfo;
309 
310  // This should not be moved earlier, since its initialization depends on some
311  // of the previous reference members being already initialized and also checks
312  // if TheTargetCodeGenInfo is NULL
313  CodeGenTypes Types;
314 
315  /// Holds information about C++ vtables.
316  CodeGenVTables VTables;
317 
318  std::unique_ptr<CGObjCRuntime> ObjCRuntime;
319  std::unique_ptr<CGOpenCLRuntime> OpenCLRuntime;
320  std::unique_ptr<CGOpenMPRuntime> OpenMPRuntime;
321  std::unique_ptr<CGCUDARuntime> CUDARuntime;
322  std::unique_ptr<CGDebugInfo> DebugInfo;
323  std::unique_ptr<ObjCEntrypoints> ObjCData;
324  llvm::MDNode *NoObjCARCExceptionsMetadata = nullptr;
325  std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader;
326  InstrProfStats PGOStats;
327  std::unique_ptr<llvm::SanitizerStatReport> SanStats;
328 
329  // A set of references that have only been seen via a weakref so far. This is
330  // used to remove the weak of the reference if we ever see a direct reference
331  // or a definition.
332  llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences;
333 
334  /// This contains all the decls which have definitions but/ which are deferred
335  /// for emission and therefore should only be output if they are actually
336  /// used. If a decl is in this, then it is known to have not been referenced
337  /// yet.
338  std::map<StringRef, GlobalDecl> DeferredDecls;
339 
340  /// This is a list of deferred decls which we have seen that *are* actually
341  /// referenced. These get code generated when the module is done.
342  std::vector<GlobalDecl> DeferredDeclsToEmit;
343  void addDeferredDeclToEmit(GlobalDecl GD) {
344  DeferredDeclsToEmit.emplace_back(GD);
345  }
346 
347  /// List of alias we have emitted. Used to make sure that what they point to
348  /// is defined once we get to the end of the of the translation unit.
349  std::vector<GlobalDecl> Aliases;
350 
351  /// List of multiversion functions that have to be emitted. Used to make sure
352  /// we properly emit the iFunc.
353  std::vector<GlobalDecl> MultiVersionFuncs;
354 
355  typedef llvm::StringMap<llvm::TrackingVH<llvm::Constant> > ReplacementsTy;
356  ReplacementsTy Replacements;
357 
358  /// List of global values to be replaced with something else. Used when we
359  /// want to replace a GlobalValue but can't identify it by its mangled name
360  /// anymore (because the name is already taken).
362  GlobalValReplacements;
363 
364  /// Set of global decls for which we already diagnosed mangled name conflict.
365  /// Required to not issue a warning (on a mangling conflict) multiple times
366  /// for the same decl.
367  llvm::DenseSet<GlobalDecl> DiagnosedConflictingDefinitions;
368 
369  /// A queue of (optional) vtables to consider emitting.
370  std::vector<const CXXRecordDecl*> DeferredVTables;
371 
372  /// A queue of (optional) vtables that may be emitted opportunistically.
373  std::vector<const CXXRecordDecl *> OpportunisticVTables;
374 
375  /// List of global values which are required to be present in the object file;
376  /// bitcast to i8*. This is used for forcing visibility of symbols which may
377  /// otherwise be optimized out.
378  std::vector<llvm::WeakTrackingVH> LLVMUsed;
379  std::vector<llvm::WeakTrackingVH> LLVMCompilerUsed;
380 
381  /// Store the list of global constructors and their respective priorities to
382  /// be emitted when the translation unit is complete.
383  CtorList GlobalCtors;
384 
385  /// Store the list of global destructors and their respective priorities to be
386  /// emitted when the translation unit is complete.
387  CtorList GlobalDtors;
388 
389  /// An ordered map of canonical GlobalDecls to their mangled names.
390  llvm::MapVector<GlobalDecl, StringRef> MangledDeclNames;
391  llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> Manglings;
392 
393  // An ordered map of canonical GlobalDecls paired with the cpu-index for
394  // cpu-specific name manglings.
395  llvm::MapVector<std::pair<GlobalDecl, unsigned>, StringRef>
396  CPUSpecificMangledDeclNames;
397  llvm::StringMap<std::pair<GlobalDecl, unsigned>, llvm::BumpPtrAllocator>
398  CPUSpecificManglings;
399 
400  /// Global annotations.
401  std::vector<llvm::Constant*> Annotations;
402 
403  /// Map used to get unique annotation strings.
404  llvm::StringMap<llvm::Constant*> AnnotationStrings;
405 
406  llvm::StringMap<llvm::GlobalVariable *> CFConstantStringMap;
407 
408  llvm::DenseMap<llvm::Constant *, llvm::GlobalVariable *> ConstantStringMap;
409  llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap;
410  llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap;
411  llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap;
412 
413  llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap;
414  llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap;
415 
416  /// Map used to get unique type descriptor constants for sanitizers.
417  llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap;
418 
419  /// Map used to track internal linkage functions declared within
420  /// extern "C" regions.
421  typedef llvm::MapVector<IdentifierInfo *,
422  llvm::GlobalValue *> StaticExternCMap;
423  StaticExternCMap StaticExternCValues;
424 
425  /// thread_local variables defined or used in this TU.
426  std::vector<const VarDecl *> CXXThreadLocals;
427 
428  /// thread_local variables with initializers that need to run
429  /// before any thread_local variable in this TU is odr-used.
430  std::vector<llvm::Function *> CXXThreadLocalInits;
431  std::vector<const VarDecl *> CXXThreadLocalInitVars;
432 
433  /// Global variables with initializers that need to run before main.
434  std::vector<llvm::Function *> CXXGlobalInits;
435 
436  /// When a C++ decl with an initializer is deferred, null is
437  /// appended to CXXGlobalInits, and the index of that null is placed
438  /// here so that the initializer will be performed in the correct
439  /// order. Once the decl is emitted, the index is replaced with ~0U to ensure
440  /// that we don't re-emit the initializer.
441  llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition;
442 
443  typedef std::pair<OrderGlobalInits, llvm::Function*> GlobalInitData;
444 
445  struct GlobalInitPriorityCmp {
446  bool operator()(const GlobalInitData &LHS,
447  const GlobalInitData &RHS) const {
448  return LHS.first.priority < RHS.first.priority;
449  }
450  };
451 
452  /// Global variables with initializers whose order of initialization is set by
453  /// init_priority attribute.
454  SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits;
455 
456  /// Global destructor functions and arguments that need to run on termination.
457  std::vector<
458  std::tuple<llvm::FunctionType *, llvm::WeakTrackingVH, llvm::Constant *>>
459  CXXGlobalDtors;
460 
461  /// The complete set of modules that has been imported.
462  llvm::SetVector<clang::Module *> ImportedModules;
463 
464  /// The set of modules for which the module initializers
465  /// have been emitted.
466  llvm::SmallPtrSet<clang::Module *, 16> EmittedModuleInitializers;
467 
468  /// A vector of metadata strings.
469  SmallVector<llvm::MDNode *, 16> LinkerOptionsMetadata;
470 
471  /// @name Cache for Objective-C runtime types
472  /// @{
473 
474  /// Cached reference to the class for constant strings. This value has type
475  /// int * but is actually an Obj-C class pointer.
476  llvm::WeakTrackingVH CFConstantStringClassRef;
477 
478  /// The type used to describe the state of a fast enumeration in
479  /// Objective-C's for..in loop.
480  QualType ObjCFastEnumerationStateType;
481 
482  /// @}
483 
484  /// Lazily create the Objective-C runtime
485  void createObjCRuntime();
486 
487  void createOpenCLRuntime();
488  void createOpenMPRuntime();
489  void createCUDARuntime();
490 
491  bool isTriviallyRecursive(const FunctionDecl *F);
492  bool shouldEmitFunction(GlobalDecl GD);
493  bool shouldOpportunisticallyEmitVTables();
494  /// Map used to be sure we don't emit the same CompoundLiteral twice.
495  llvm::DenseMap<const CompoundLiteralExpr *, llvm::GlobalVariable *>
496  EmittedCompoundLiterals;
497 
498  /// Map of the global blocks we've emitted, so that we don't have to re-emit
499  /// them if the constexpr evaluator gets aggressive.
500  llvm::DenseMap<const BlockExpr *, llvm::Constant *> EmittedGlobalBlocks;
501 
502  /// @name Cache for Blocks Runtime Globals
503  /// @{
504 
505  llvm::Constant *NSConcreteGlobalBlock = nullptr;
506  llvm::Constant *NSConcreteStackBlock = nullptr;
507 
508  llvm::FunctionCallee BlockObjectAssign = nullptr;
509  llvm::FunctionCallee BlockObjectDispose = nullptr;
510 
511  llvm::Type *BlockDescriptorType = nullptr;
512  llvm::Type *GenericBlockLiteralType = nullptr;
513 
514  struct {
516  } Block;
517 
518  /// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>)
519  llvm::Function *LifetimeStartFn = nullptr;
520 
521  /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>)
522  llvm::Function *LifetimeEndFn = nullptr;
523 
524  GlobalDecl initializedGlobalDecl;
525 
526  std::unique_ptr<SanitizerMetadata> SanitizerMD;
527 
528  /// @}
529 
530  llvm::MapVector<const Decl *, bool> DeferredEmptyCoverageMappingDecls;
531 
532  std::unique_ptr<CoverageMappingModuleGen> CoverageMapping;
533 
534  /// Mapping from canonical types to their metadata identifiers. We need to
535  /// maintain this mapping because identifiers may be formed from distinct
536  /// MDNodes.
537  typedef llvm::DenseMap<QualType, llvm::Metadata *> MetadataTypeMap;
538  MetadataTypeMap MetadataIdMap;
539  MetadataTypeMap VirtualMetadataIdMap;
540  MetadataTypeMap GeneralizedMetadataIdMap;
541 
542 public:
543  CodeGenModule(ASTContext &C, const HeaderSearchOptions &headersearchopts,
544  const PreprocessorOptions &ppopts,
545  const CodeGenOptions &CodeGenOpts, llvm::Module &M,
546  DiagnosticsEngine &Diags,
547  CoverageSourceInfo *CoverageInfo = nullptr);
548 
549  ~CodeGenModule();
550 
551  void clear();
552 
553  /// Finalize LLVM code generation.
554  void Release();
555 
556  /// Return true if we should emit location information for expressions.
557  bool getExpressionLocationsEnabled() const;
558 
559  /// Return a reference to the configured Objective-C runtime.
561  if (!ObjCRuntime) createObjCRuntime();
562  return *ObjCRuntime;
563  }
564 
565  /// Return true iff an Objective-C runtime has been configured.
566  bool hasObjCRuntime() { return !!ObjCRuntime; }
567 
568  /// Return a reference to the configured OpenCL runtime.
570  assert(OpenCLRuntime != nullptr);
571  return *OpenCLRuntime;
572  }
573 
574  /// Return a reference to the configured OpenMP runtime.
576  assert(OpenMPRuntime != nullptr);
577  return *OpenMPRuntime;
578  }
579 
580  /// Return a reference to the configured CUDA runtime.
582  assert(CUDARuntime != nullptr);
583  return *CUDARuntime;
584  }
585 
587  assert(ObjCData != nullptr);
588  return *ObjCData;
589  }
590 
591  // Version checking function, used to implement ObjC's @available:
592  // i32 @__isOSVersionAtLeast(i32, i32, i32)
593  llvm::FunctionCallee IsOSVersionAtLeastFn = nullptr;
594 
595  InstrProfStats &getPGOStats() { return PGOStats; }
596  llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); }
597 
599  return CoverageMapping.get();
600  }
601 
602  llvm::Constant *getStaticLocalDeclAddress(const VarDecl *D) {
603  return StaticLocalDeclMap[D];
604  }
606  llvm::Constant *C) {
607  StaticLocalDeclMap[D] = C;
608  }
609 
610  llvm::Constant *
611  getOrCreateStaticVarDecl(const VarDecl &D,
612  llvm::GlobalValue::LinkageTypes Linkage);
613 
614  llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) {
615  return StaticLocalDeclGuardMap[D];
616  }
618  llvm::GlobalVariable *C) {
619  StaticLocalDeclGuardMap[D] = C;
620  }
621 
622  bool lookupRepresentativeDecl(StringRef MangledName,
623  GlobalDecl &Result) const;
624 
625  llvm::Constant *getAtomicSetterHelperFnMap(QualType Ty) {
626  return AtomicSetterHelperFnMap[Ty];
627  }
629  llvm::Constant *Fn) {
630  AtomicSetterHelperFnMap[Ty] = Fn;
631  }
632 
633  llvm::Constant *getAtomicGetterHelperFnMap(QualType Ty) {
634  return AtomicGetterHelperFnMap[Ty];
635  }
637  llvm::Constant *Fn) {
638  AtomicGetterHelperFnMap[Ty] = Fn;
639  }
640 
641  llvm::Constant *getTypeDescriptorFromMap(QualType Ty) {
642  return TypeDescriptorMap[Ty];
643  }
644  void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C) {
645  TypeDescriptorMap[Ty] = C;
646  }
647 
648  CGDebugInfo *getModuleDebugInfo() { return DebugInfo.get(); }
649 
651  if (!NoObjCARCExceptionsMetadata)
652  NoObjCARCExceptionsMetadata = llvm::MDNode::get(getLLVMContext(), None);
653  return NoObjCARCExceptionsMetadata;
654  }
655 
656  ASTContext &getContext() const { return Context; }
657  const LangOptions &getLangOpts() const { return LangOpts; }
659  const { return HeaderSearchOpts; }
661  const { return PreprocessorOpts; }
662  const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
663  llvm::Module &getModule() const { return TheModule; }
664  DiagnosticsEngine &getDiags() const { return Diags; }
665  const llvm::DataLayout &getDataLayout() const {
666  return TheModule.getDataLayout();
667  }
668  const TargetInfo &getTarget() const { return Target; }
669  const llvm::Triple &getTriple() const { return Target.getTriple(); }
670  bool supportsCOMDAT() const;
671  void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO);
672 
673  CGCXXABI &getCXXABI() const { return *ABI; }
674  llvm::LLVMContext &getLLVMContext() { return VMContext; }
675 
676  bool shouldUseTBAA() const { return TBAA != nullptr; }
677 
678  const TargetCodeGenInfo &getTargetCodeGenInfo();
679 
680  CodeGenTypes &getTypes() { return Types; }
681 
682  CodeGenVTables &getVTables() { return VTables; }
683 
685  return VTables.getItaniumVTableContext();
686  }
687 
689  return VTables.getMicrosoftVTableContext();
690  }
691 
692  CtorList &getGlobalCtors() { return GlobalCtors; }
693  CtorList &getGlobalDtors() { return GlobalDtors; }
694 
695  /// getTBAATypeInfo - Get metadata used to describe accesses to objects of
696  /// the given type.
697  llvm::MDNode *getTBAATypeInfo(QualType QTy);
698 
699  /// getTBAAAccessInfo - Get TBAA information that describes an access to
700  /// an object of the given type.
701  TBAAAccessInfo getTBAAAccessInfo(QualType AccessType);
702 
703  /// getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an
704  /// access to a virtual table pointer.
705  TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType);
706 
707  llvm::MDNode *getTBAAStructInfo(QualType QTy);
708 
709  /// getTBAABaseTypeInfo - Get metadata that describes the given base access
710  /// type. Return null if the type is not suitable for use in TBAA access tags.
711  llvm::MDNode *getTBAABaseTypeInfo(QualType QTy);
712 
713  /// getTBAAAccessTagInfo - Get TBAA tag for a given memory access.
714  llvm::MDNode *getTBAAAccessTagInfo(TBAAAccessInfo Info);
715 
716  /// mergeTBAAInfoForCast - Get merged TBAA information for the purposes of
717  /// type casts.
718  TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
720 
721  /// mergeTBAAInfoForConditionalOperator - Get merged TBAA information for the
722  /// purposes of conditional operator.
723  TBAAAccessInfo mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA,
724  TBAAAccessInfo InfoB);
725 
726  /// mergeTBAAInfoForMemoryTransfer - Get merged TBAA information for the
727  /// purposes of memory transfer calls.
728  TBAAAccessInfo mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo,
729  TBAAAccessInfo SrcInfo);
730 
731  /// getTBAAInfoForSubobject - Get TBAA information for an access with a given
732  /// base lvalue.
734  if (Base.getTBAAInfo().isMayAlias())
735  return TBAAAccessInfo::getMayAliasInfo();
736  return getTBAAAccessInfo(AccessType);
737  }
738 
739  bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor);
740 
741  bool isPaddedAtomicType(QualType type);
742  bool isPaddedAtomicType(const AtomicType *type);
743 
744  /// DecorateInstructionWithTBAA - Decorate the instruction with a TBAA tag.
745  void DecorateInstructionWithTBAA(llvm::Instruction *Inst,
746  TBAAAccessInfo TBAAInfo);
747 
748  /// Adds !invariant.barrier !tag to instruction
749  void DecorateInstructionWithInvariantGroup(llvm::Instruction *I,
750  const CXXRecordDecl *RD);
751 
752  /// Emit the given number of characters as a value of type size_t.
753  llvm::ConstantInt *getSize(CharUnits numChars);
754 
755  /// Set the visibility for the given LLVM GlobalValue.
756  void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
757 
758  void setGlobalVisibilityAndLocal(llvm::GlobalValue *GV,
759  const NamedDecl *D) const;
760 
761  void setDSOLocal(llvm::GlobalValue *GV) const;
762 
763  void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const;
764  void setDLLImportDLLExport(llvm::GlobalValue *GV, const NamedDecl *D) const;
765  /// Set visibility, dllimport/dllexport and dso_local.
766  /// This must be called after dllimport/dllexport is set.
767  void setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const;
768  void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;
769 
770  /// Set the TLS mode for the given LLVM GlobalValue for the thread-local
771  /// variable declaration D.
772  void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const;
773 
774  static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V) {
775  switch (V) {
779  }
780  llvm_unreachable("unknown visibility!");
781  }
782 
783  llvm::Constant *GetAddrOfGlobal(GlobalDecl GD,
784  ForDefinition_t IsForDefinition
785  = NotForDefinition);
786 
787  /// Will return a global variable of the given type. If a variable with a
788  /// different type already exists then a new variable with the right type
789  /// will be created and all uses of the old variable will be replaced with a
790  /// bitcast to the new variable.
791  llvm::GlobalVariable *
792  CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty,
793  llvm::GlobalValue::LinkageTypes Linkage,
794  unsigned Alignment);
795 
796  llvm::Function *
797  CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty, const Twine &name,
798  const CGFunctionInfo &FI,
800  bool TLS = false);
801 
802  /// Return the AST address space of the underlying global variable for D, as
803  /// determined by its declaration. Normally this is the same as the address
804  /// space of D's type, but in CUDA, address spaces are associated with
805  /// declarations, not types. If D is nullptr, return the default address
806  /// space for global variable.
807  ///
808  /// For languages without explicit address spaces, if D has default address
809  /// space, target-specific global or constant address space may be returned.
810  LangAS GetGlobalVarAddressSpace(const VarDecl *D);
811 
812  /// Return the llvm::Constant for the address of the given global variable.
813  /// If Ty is non-null and if the global doesn't exist, then it will be created
814  /// with the specified type instead of whatever the normal requested type
815  /// would be. If IsForDefinition is true, it is guaranteed that an actual
816  /// global with type Ty will be returned, not conversion of a variable with
817  /// the same mangled name but some other type.
818  llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,
819  llvm::Type *Ty = nullptr,
820  ForDefinition_t IsForDefinition
821  = NotForDefinition);
822 
823  /// Return the AST address space of string literal, which is used to emit
824  /// the string literal as global variable in LLVM IR.
825  /// Note: This is not necessarily the address space of the string literal
826  /// in AST. For address space agnostic language, e.g. C++, string literal
827  /// in AST is always in default address space.
828  LangAS getStringLiteralAddressSpace() const;
829 
830  /// Return the address of the given function. If Ty is non-null, then this
831  /// function will use the specified type if it has to create it.
832  llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = nullptr,
833  bool ForVTable = false,
834  bool DontDefer = false,
835  ForDefinition_t IsForDefinition
836  = NotForDefinition);
837 
838  /// Get the address of the RTTI descriptor for the given type.
839  llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
840 
841  /// Get the address of a uuid descriptor .
842  ConstantAddress GetAddrOfUuidDescriptor(const CXXUuidofExpr* E);
843 
844  /// Get the address of the thunk for the given global decl.
845  llvm::Constant *GetAddrOfThunk(StringRef Name, llvm::Type *FnTy,
846  GlobalDecl GD);
847 
848  /// Get a reference to the target of VD.
849  ConstantAddress GetWeakRefReference(const ValueDecl *VD);
850 
851  /// Returns the assumed alignment of an opaque pointer to the given class.
852  CharUnits getClassPointerAlignment(const CXXRecordDecl *CD);
853 
854  /// Returns the assumed alignment of a virtual base of a class.
855  CharUnits getVBaseAlignment(CharUnits DerivedAlign,
856  const CXXRecordDecl *Derived,
857  const CXXRecordDecl *VBase);
858 
859  /// Given a class pointer with an actual known alignment, and the
860  /// expected alignment of an object at a dynamic offset w.r.t that
861  /// pointer, return the alignment to assume at the offset.
862  CharUnits getDynamicOffsetAlignment(CharUnits ActualAlign,
863  const CXXRecordDecl *Class,
864  CharUnits ExpectedTargetAlign);
865 
866  CharUnits
867  computeNonVirtualBaseClassOffset(const CXXRecordDecl *DerivedClass,
870 
871  /// Returns the offset from a derived class to a class. Returns null if the
872  /// offset is 0.
873  llvm::Constant *
874  GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
877 
878  llvm::FoldingSet<BlockByrefHelpers> ByrefHelpersCache;
879 
880  /// Fetches the global unique block count.
881  int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; }
882 
883  /// Fetches the type of a generic block descriptor.
884  llvm::Type *getBlockDescriptorType();
885 
886  /// The type of a generic block literal.
887  llvm::Type *getGenericBlockLiteralType();
888 
889  /// Gets the address of a block which requires no captures.
890  llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name);
891 
892  /// Returns the address of a block which requires no caputres, or null if
893  /// we've yet to emit the block for BE.
894  llvm::Constant *getAddrOfGlobalBlockIfEmitted(const BlockExpr *BE) {
895  return EmittedGlobalBlocks.lookup(BE);
896  }
897 
898  /// Notes that BE's global block is available via Addr. Asserts that BE
899  /// isn't already emitted.
900  void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr);
901 
902  /// Return a pointer to a constant CFString object for the given string.
903  ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal);
904 
905  /// Return a pointer to a constant NSString object for the given string. Or a
906  /// user defined String object as defined via
907  /// -fconstant-string-class=class_name option.
908  ConstantAddress GetAddrOfConstantString(const StringLiteral *Literal);
909 
910  /// Return a constant array for the given string.
911  llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E);
912 
913  /// Return a pointer to a constant array for the given string literal.
915  GetAddrOfConstantStringFromLiteral(const StringLiteral *S,
916  StringRef Name = ".str");
917 
918  /// Return a pointer to a constant array for the given ObjCEncodeExpr node.
920  GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *);
921 
922  /// Returns a pointer to a character array containing the literal and a
923  /// terminating '\0' character. The result has pointer to array type.
924  ///
925  /// \param GlobalName If provided, the name to use for the global (if one is
926  /// created).
928  GetAddrOfConstantCString(const std::string &Str,
929  const char *GlobalName = nullptr);
930 
931  /// Returns a pointer to a constant global variable for the given file-scope
932  /// compound literal expression.
933  ConstantAddress GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr*E);
934 
935  /// If it's been emitted already, returns the GlobalVariable corresponding to
936  /// a compound literal. Otherwise, returns null.
937  llvm::GlobalVariable *
938  getAddrOfConstantCompoundLiteralIfEmitted(const CompoundLiteralExpr *E);
939 
940  /// Notes that CLE's GlobalVariable is GV. Asserts that CLE isn't already
941  /// emitted.
942  void setAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *CLE,
943  llvm::GlobalVariable *GV);
944 
945  /// Returns a pointer to a global variable representing a temporary
946  /// with static or thread storage duration.
947  ConstantAddress GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E,
948  const Expr *Inner);
949 
950  /// Retrieve the record type that describes the state of an
951  /// Objective-C fast enumeration loop (for..in).
952  QualType getObjCFastEnumerationStateType();
953 
954  // Produce code for this constructor/destructor. This method doesn't try
955  // to apply any ABI rules about which other constructors/destructors
956  // are needed or if they are alias to each other.
957  llvm::Function *codegenCXXStructor(const CXXMethodDecl *MD,
959 
960  /// Return the address of the constructor/destructor of the given type.
961  llvm::Constant *
963  const CGFunctionInfo *FnInfo = nullptr,
964  llvm::FunctionType *FnType = nullptr,
965  bool DontDefer = false,
966  ForDefinition_t IsForDefinition = NotForDefinition) {
967  return cast<llvm::Constant>(getAddrAndTypeOfCXXStructor(MD, Type, FnInfo,
968  FnType, DontDefer,
969  IsForDefinition)
970  .getCallee());
971  }
972 
973  llvm::FunctionCallee getAddrAndTypeOfCXXStructor(
974  const CXXMethodDecl *MD, StructorType Type,
975  const CGFunctionInfo *FnInfo = nullptr,
976  llvm::FunctionType *FnType = nullptr, bool DontDefer = false,
977  ForDefinition_t IsForDefinition = NotForDefinition);
978 
979  /// Given a builtin id for a function like "__builtin_fabsf", return a
980  /// Function* for "fabsf".
981  llvm::Constant *getBuiltinLibFunction(const FunctionDecl *FD,
982  unsigned BuiltinID);
983 
984  llvm::Function *getIntrinsic(unsigned IID, ArrayRef<llvm::Type*> Tys = None);
985 
986  /// Emit code for a single top level declaration.
987  void EmitTopLevelDecl(Decl *D);
988 
989  /// Stored a deferred empty coverage mapping for an unused
990  /// and thus uninstrumented top level declaration.
991  void AddDeferredUnusedCoverageMapping(Decl *D);
992 
993  /// Remove the deferred empty coverage mapping as this
994  /// declaration is actually instrumented.
995  void ClearUnusedCoverageMapping(const Decl *D);
996 
997  /// Emit all the deferred coverage mappings
998  /// for the uninstrumented functions.
999  void EmitDeferredUnusedCoverageMappings();
1000 
1001  /// Tell the consumer that this variable has been instantiated.
1002  void HandleCXXStaticMemberVarInstantiation(VarDecl *VD);
1003 
1004  /// If the declaration has internal linkage but is inside an
1005  /// extern "C" linkage specification, prepare to emit an alias for it
1006  /// to the expected name.
1007  template<typename SomeDecl>
1008  void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV);
1009 
1010  /// Add a global to a list to be added to the llvm.used metadata.
1011  void addUsedGlobal(llvm::GlobalValue *GV);
1012 
1013  /// Add a global to a list to be added to the llvm.compiler.used metadata.
1014  void addCompilerUsedGlobal(llvm::GlobalValue *GV);
1015 
1016  /// Add a destructor and object to add to the C++ global destructor function.
1017  void AddCXXDtorEntry(llvm::FunctionCallee DtorFn, llvm::Constant *Object) {
1018  CXXGlobalDtors.emplace_back(DtorFn.getFunctionType(), DtorFn.getCallee(),
1019  Object);
1020  }
1021 
1022  /// Create or return a runtime function declaration with the specified type
1023  /// and name.
1024  llvm::FunctionCallee
1025  CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name,
1026  llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1027  bool Local = false);
1028 
1029  /// Create a new runtime global variable with the specified type and name.
1030  llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty,
1031  StringRef Name);
1032 
1033  ///@name Custom Blocks Runtime Interfaces
1034  ///@{
1035 
1036  llvm::Constant *getNSConcreteGlobalBlock();
1037  llvm::Constant *getNSConcreteStackBlock();
1038  llvm::FunctionCallee getBlockObjectAssign();
1039  llvm::FunctionCallee getBlockObjectDispose();
1040 
1041  ///@}
1042 
1043  llvm::Function *getLLVMLifetimeStartFn();
1044  llvm::Function *getLLVMLifetimeEndFn();
1045 
1046  // Make sure that this type is translated.
1047  void UpdateCompletedType(const TagDecl *TD);
1048 
1049  llvm::Constant *getMemberPointerConstant(const UnaryOperator *e);
1050 
1051  /// Emit type info if type of an expression is a variably modified
1052  /// type. Also emit proper debug info for cast types.
1053  void EmitExplicitCastExprType(const ExplicitCastExpr *E,
1054  CodeGenFunction *CGF = nullptr);
1055 
1056  /// Return the result of value-initializing the given type, i.e. a null
1057  /// expression of the given type. This is usually, but not always, an LLVM
1058  /// null constant.
1059  llvm::Constant *EmitNullConstant(QualType T);
1060 
1061  /// Return a null constant appropriate for zero-initializing a base class with
1062  /// the given type. This is usually, but not always, an LLVM null constant.
1063  llvm::Constant *EmitNullConstantForBase(const CXXRecordDecl *Record);
1064 
1065  /// Emit a general error that something can't be done.
1066  void Error(SourceLocation loc, StringRef error);
1067 
1068  /// Print out an error that codegen doesn't support the specified stmt yet.
1069  void ErrorUnsupported(const Stmt *S, const char *Type);
1070 
1071  /// Print out an error that codegen doesn't support the specified decl yet.
1072  void ErrorUnsupported(const Decl *D, const char *Type);
1073 
1074  /// Set the attributes on the LLVM function for the given decl and function
1075  /// info. This applies attributes necessary for handling the ABI as well as
1076  /// user specified attributes like section.
1077  void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F,
1078  const CGFunctionInfo &FI);
1079 
1080  /// Set the LLVM function attributes (sext, zext, etc).
1081  void SetLLVMFunctionAttributes(GlobalDecl GD, const CGFunctionInfo &Info,
1082  llvm::Function *F);
1083 
1084  /// Set the LLVM function attributes which only apply to a function
1085  /// definition.
1086  void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F);
1087 
1088  /// Return true iff the given type uses 'sret' when used as a return type.
1089  bool ReturnTypeUsesSRet(const CGFunctionInfo &FI);
1090 
1091  /// Return true iff the given type uses an argument slot when 'sret' is used
1092  /// as a return type.
1093  bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI);
1094 
1095  /// Return true iff the given type uses 'fpret' when used as a return type.
1096  bool ReturnTypeUsesFPRet(QualType ResultType);
1097 
1098  /// Return true iff the given type uses 'fp2ret' when used as a return type.
1099  bool ReturnTypeUsesFP2Ret(QualType ResultType);
1100 
1101  /// Get the LLVM attributes and calling convention to use for a particular
1102  /// function type.
1103  ///
1104  /// \param Name - The function name.
1105  /// \param Info - The function type information.
1106  /// \param CalleeInfo - The callee information these attributes are being
1107  /// constructed for. If valid, the attributes applied to this decl may
1108  /// contribute to the function attributes and calling convention.
1109  /// \param Attrs [out] - On return, the attribute list to use.
1110  /// \param CallingConv [out] - On return, the LLVM calling convention to use.
1111  void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info,
1112  CGCalleeInfo CalleeInfo,
1113  llvm::AttributeList &Attrs, unsigned &CallingConv,
1114  bool AttrOnCallSite);
1115 
1116  /// Adds attributes to F according to our CodeGenOptions and LangOptions, as
1117  /// though we had emitted it ourselves. We remove any attributes on F that
1118  /// conflict with the attributes we add here.
1119  ///
1120  /// This is useful for adding attrs to bitcode modules that you want to link
1121  /// with but don't control, such as CUDA's libdevice. When linking with such
1122  /// a bitcode library, you might want to set e.g. its functions'
1123  /// "unsafe-fp-math" attribute to match the attr of the functions you're
1124  /// codegen'ing. Otherwise, LLVM will interpret the bitcode module's lack of
1125  /// unsafe-fp-math attrs as tantamount to unsafe-fp-math=false, and then LLVM
1126  /// will propagate unsafe-fp-math=false up to every transitive caller of a
1127  /// function in the bitcode library!
1128  ///
1129  /// With the exception of fast-math attrs, this will only make the attributes
1130  /// on the function more conservative. But it's unsafe to call this on a
1131  /// function which relies on particular fast-math attributes for correctness.
1132  /// It's up to you to ensure that this is safe.
1133  void AddDefaultFnAttrs(llvm::Function &F);
1134 
1135  /// Parses the target attributes passed in, and returns only the ones that are
1136  /// valid feature names.
1137  TargetAttr::ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD);
1138 
1139  // Fills in the supplied string map with the set of target features for the
1140  // passed in function.
1141  void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap, GlobalDecl GD);
1142 
1143  StringRef getMangledName(GlobalDecl GD);
1144  StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD);
1145 
1146  void EmitTentativeDefinition(const VarDecl *D);
1147 
1148  void EmitVTable(CXXRecordDecl *Class);
1149 
1150  void RefreshTypeCacheForClass(const CXXRecordDecl *Class);
1151 
1152  /// Appends Opts to the "llvm.linker.options" metadata value.
1153  void AppendLinkerOptions(StringRef Opts);
1154 
1155  /// Appends a detect mismatch command to the linker options.
1156  void AddDetectMismatch(StringRef Name, StringRef Value);
1157 
1158  /// Appends a dependent lib to the "llvm.linker.options" metadata
1159  /// value.
1160  void AddDependentLib(StringRef Lib);
1161 
1162  void AddELFLibDirective(StringRef Lib);
1163 
1164  llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD);
1165 
1166  void setFunctionLinkage(GlobalDecl GD, llvm::Function *F) {
1167  F->setLinkage(getFunctionLinkage(GD));
1168  }
1169 
1170  /// Return the appropriate linkage for the vtable, VTT, and type information
1171  /// of the given class.
1172  llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD);
1173 
1174  /// Return the store size, in character units, of the given LLVM type.
1175  CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const;
1176 
1177  /// Returns LLVM linkage for a declarator.
1178  llvm::GlobalValue::LinkageTypes
1179  getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage,
1180  bool IsConstantVariable);
1181 
1182  /// Returns LLVM linkage for a declarator.
1183  llvm::GlobalValue::LinkageTypes
1184  getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant);
1185 
1186  /// Emit all the global annotations.
1187  void EmitGlobalAnnotations();
1188 
1189  /// Emit an annotation string.
1190  llvm::Constant *EmitAnnotationString(StringRef Str);
1191 
1192  /// Emit the annotation's translation unit.
1193  llvm::Constant *EmitAnnotationUnit(SourceLocation Loc);
1194 
1195  /// Emit the annotation line number.
1196  llvm::Constant *EmitAnnotationLineNo(SourceLocation L);
1197 
1198  /// Generate the llvm::ConstantStruct which contains the annotation
1199  /// information for a given GlobalValue. The annotation struct is
1200  /// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the
1201  /// GlobalValue being annotated. The second field is the constant string
1202  /// created from the AnnotateAttr's annotation. The third field is a constant
1203  /// string containing the name of the translation unit. The fourth field is
1204  /// the line number in the file of the annotated value declaration.
1205  llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV,
1206  const AnnotateAttr *AA,
1207  SourceLocation L);
1208 
1209  /// Add global annotations that are set on D, for the global GV. Those
1210  /// annotations are emitted during finalization of the LLVM code.
1211  void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV);
1212 
1213  bool isInSanitizerBlacklist(SanitizerMask Kind, llvm::Function *Fn,
1214  SourceLocation Loc) const;
1215 
1216  bool isInSanitizerBlacklist(llvm::GlobalVariable *GV, SourceLocation Loc,
1217  QualType Ty,
1218  StringRef Category = StringRef()) const;
1219 
1220  /// Imbue XRay attributes to a function, applying the always/never attribute
1221  /// lists in the process. Returns true if we did imbue attributes this way,
1222  /// false otherwise.
1223  bool imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc,
1224  StringRef Category = StringRef()) const;
1225 
1227  return SanitizerMD.get();
1228  }
1229 
1231  DeferredVTables.push_back(RD);
1232  }
1233 
1234  /// Emit code for a single global function or var decl. Forward declarations
1235  /// are emitted lazily.
1236  void EmitGlobal(GlobalDecl D);
1237 
1238  bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
1239 
1240  llvm::GlobalValue *GetGlobalValue(StringRef Ref);
1241 
1242  /// Set attributes which are common to any form of a global definition (alias,
1243  /// Objective-C method, function, global variable).
1244  ///
1245  /// NOTE: This should only be called for definitions.
1246  void SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV);
1247 
1248  void addReplacement(StringRef Name, llvm::Constant *C);
1249 
1250  void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C);
1251 
1252  /// Emit a code for threadprivate directive.
1253  /// \param D Threadprivate declaration.
1254  void EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D);
1255 
1256  /// Emit a code for declare reduction construct.
1257  void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D,
1258  CodeGenFunction *CGF = nullptr);
1259 
1260  /// Emit a code for declare mapper construct.
1261  void EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D,
1262  CodeGenFunction *CGF = nullptr);
1263 
1264  /// Emit a code for requires directive.
1265  /// \param D Requires declaration
1266  void EmitOMPRequiresDecl(const OMPRequiresDecl *D);
1267 
1268  /// Returns whether the given record has hidden LTO visibility and therefore
1269  /// may participate in (single-module) CFI and whole-program vtable
1270  /// optimization.
1271  bool HasHiddenLTOVisibility(const CXXRecordDecl *RD);
1272 
1273  /// Emit type metadata for the given vtable using the given layout.
1274  void EmitVTableTypeMetadata(llvm::GlobalVariable *VTable,
1275  const VTableLayout &VTLayout);
1276 
1277  /// Generate a cross-DSO type identifier for MD.
1278  llvm::ConstantInt *CreateCrossDsoCfiTypeId(llvm::Metadata *MD);
1279 
1280  /// Create a metadata identifier for the given type. This may either be an
1281  /// MDString (for external identifiers) or a distinct unnamed MDNode (for
1282  /// internal identifiers).
1283  llvm::Metadata *CreateMetadataIdentifierForType(QualType T);
1284 
1285  /// Create a metadata identifier that is intended to be used to check virtual
1286  /// calls via a member function pointer.
1287  llvm::Metadata *CreateMetadataIdentifierForVirtualMemPtrType(QualType T);
1288 
1289  /// Create a metadata identifier for the generalization of the given type.
1290  /// This may either be an MDString (for external identifiers) or a distinct
1291  /// unnamed MDNode (for internal identifiers).
1292  llvm::Metadata *CreateMetadataIdentifierGeneralized(QualType T);
1293 
1294  /// Create and attach type metadata to the given function.
1295  void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
1296  llvm::Function *F);
1297 
1298  /// Returns whether this module needs the "all-vtables" type identifier.
1299  bool NeedAllVtablesTypeId() const;
1300 
1301  /// Create and attach type metadata for the given vtable.
1302  void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset,
1303  const CXXRecordDecl *RD);
1304 
1305  /// Return a vector of most-base classes for RD. This is used to implement
1306  /// control flow integrity checks for member function pointers.
1307  ///
1308  /// A most-base class of a class C is defined as a recursive base class of C,
1309  /// including C itself, that does not have any bases.
1310  std::vector<const CXXRecordDecl *>
1311  getMostBaseClasses(const CXXRecordDecl *RD);
1312 
1313  /// Get the declaration of std::terminate for the platform.
1314  llvm::FunctionCallee getTerminateFn();
1315 
1316  llvm::SanitizerStatReport &getSanStats();
1317 
1318  llvm::Value *
1319  createOpenCLIntToSamplerConversion(const Expr *E, CodeGenFunction &CGF);
1320 
1321  /// Get target specific null pointer.
1322  /// \param T is the LLVM type of the null pointer.
1323  /// \param QT is the clang QualType of the null pointer.
1324  llvm::Constant *getNullPointer(llvm::PointerType *T, QualType QT);
1325 
1326 private:
1327  llvm::Constant *GetOrCreateLLVMFunction(
1328  StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,
1329  bool DontDefer = false, bool IsThunk = false,
1330  llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1331  ForDefinition_t IsForDefinition = NotForDefinition);
1332 
1333  llvm::Constant *GetOrCreateMultiVersionResolver(GlobalDecl GD,
1334  llvm::Type *DeclTy,
1335  const FunctionDecl *FD);
1336  void UpdateMultiVersionNames(GlobalDecl GD, const FunctionDecl *FD);
1337 
1338  llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName,
1339  llvm::PointerType *PTy,
1340  const VarDecl *D,
1341  ForDefinition_t IsForDefinition
1342  = NotForDefinition);
1343 
1344  bool GetCPUAndFeaturesAttributes(GlobalDecl GD,
1345  llvm::AttrBuilder &AttrBuilder);
1346  void setNonAliasAttributes(GlobalDecl GD, llvm::GlobalObject *GO);
1347 
1348  /// Set function attributes for a function declaration.
1349  void SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
1350  bool IsIncompleteFunction, bool IsThunk);
1351 
1352  void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = nullptr);
1353 
1354  void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
1355  void EmitMultiVersionFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
1356 
1357  void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false);
1358  void EmitAliasDefinition(GlobalDecl GD);
1359  void emitIFuncDefinition(GlobalDecl GD);
1360  void emitCPUDispatchDefinition(GlobalDecl GD);
1361  void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
1362  void EmitObjCIvarInitializations(ObjCImplementationDecl *D);
1363 
1364  // C++ related functions.
1365 
1366  void EmitDeclContext(const DeclContext *DC);
1367  void EmitLinkageSpec(const LinkageSpecDecl *D);
1368 
1369  /// Emit the function that initializes C++ thread_local variables.
1370  void EmitCXXThreadLocalInitFunc();
1371 
1372  /// Emit the function that initializes C++ globals.
1373  void EmitCXXGlobalInitFunc();
1374 
1375  /// Emit the function that destroys C++ globals.
1376  void EmitCXXGlobalDtorFunc();
1377 
1378  /// Emit the function that initializes the specified global (if PerformInit is
1379  /// true) and registers its destructor.
1380  void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
1381  llvm::GlobalVariable *Addr,
1382  bool PerformInit);
1383 
1384  void EmitPointerToInitFunc(const VarDecl *VD, llvm::GlobalVariable *Addr,
1385  llvm::Function *InitFunc, InitSegAttr *ISA);
1386 
1387  // FIXME: Hardcoding priority here is gross.
1388  void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535,
1389  llvm::Constant *AssociatedData = nullptr);
1390  void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535);
1391 
1392  /// EmitCtorList - Generates a global array of functions and priorities using
1393  /// the given list and name. This array will have appending linkage and is
1394  /// suitable for use as a LLVM constructor or destructor array. Clears Fns.
1395  void EmitCtorList(CtorList &Fns, const char *GlobalName);
1396 
1397  /// Emit any needed decls for which code generation was deferred.
1398  void EmitDeferred();
1399 
1400  /// Try to emit external vtables as available_externally if they have emitted
1401  /// all inlined virtual functions. It runs after EmitDeferred() and therefore
1402  /// is not allowed to create new references to things that need to be emitted
1403  /// lazily.
1404  void EmitVTablesOpportunistically();
1405 
1406  /// Call replaceAllUsesWith on all pairs in Replacements.
1407  void applyReplacements();
1408 
1409  /// Call replaceAllUsesWith on all pairs in GlobalValReplacements.
1410  void applyGlobalValReplacements();
1411 
1412  void checkAliases();
1413 
1414  std::map<int, llvm::TinyPtrVector<llvm::Function *>> DtorsUsingAtExit;
1415 
1416  /// Register functions annotated with __attribute__((destructor)) using
1417  /// __cxa_atexit, if it is available, or atexit otherwise.
1418  void registerGlobalDtorsWithAtExit();
1419 
1420  void emitMultiVersionFunctions();
1421 
1422  /// Emit any vtables which we deferred and still have a use for.
1423  void EmitDeferredVTables();
1424 
1425  /// Emit a dummy function that reference a CoreFoundation symbol when
1426  /// @available is used on Darwin.
1427  void emitAtAvailableLinkGuard();
1428 
1429  /// Emit the llvm.used and llvm.compiler.used metadata.
1430  void emitLLVMUsed();
1431 
1432  /// Emit the link options introduced by imported modules.
1433  void EmitModuleLinkOptions();
1434 
1435  /// Emit aliases for internal-linkage declarations inside "C" language
1436  /// linkage specifications, giving them the "expected" name where possible.
1437  void EmitStaticExternCAliases();
1438 
1439  void EmitDeclMetadata();
1440 
1441  /// Emit the Clang version as llvm.ident metadata.
1442  void EmitVersionIdentMetadata();
1443 
1444  /// Emit the Clang commandline as llvm.commandline metadata.
1445  void EmitCommandLineMetadata();
1446 
1447  /// Emits target specific Metadata for global declarations.
1448  void EmitTargetMetadata();
1449 
1450  /// Emits OpenCL specific Metadata e.g. OpenCL version.
1451  void EmitOpenCLMetadata();
1452 
1453  /// Emit the llvm.gcov metadata used to tell LLVM where to emit the .gcno and
1454  /// .gcda files in a way that persists in .bc files.
1455  void EmitCoverageFile();
1456 
1457  /// Emits the initializer for a uuidof string.
1458  llvm::Constant *EmitUuidofInitializer(StringRef uuidstr);
1459 
1460  /// Determine whether the definition must be emitted; if this returns \c
1461  /// false, the definition can be emitted lazily if it's used.
1462  bool MustBeEmitted(const ValueDecl *D);
1463 
1464  /// Determine whether the definition can be emitted eagerly, or should be
1465  /// delayed until the end of the translation unit. This is relevant for
1466  /// definitions whose linkage can change, e.g. implicit function instantions
1467  /// which may later be explicitly instantiated.
1468  bool MayBeEmittedEagerly(const ValueDecl *D);
1469 
1470  /// Check whether we can use a "simpler", more core exceptions personality
1471  /// function.
1472  void SimplifyPersonality();
1473 
1474  /// Helper function for ConstructAttributeList and AddDefaultFnAttrs.
1475  /// Constructs an AttrList for a function with the given properties.
1476  void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone,
1477  bool AttrOnCallSite,
1478  llvm::AttrBuilder &FuncAttrs);
1479 
1480  llvm::Metadata *CreateMetadataIdentifierImpl(QualType T, MetadataTypeMap &Map,
1481  StringRef Suffix);
1482 };
1483 
1484 } // end namespace CodeGen
1485 } // end namespace clang
1486 
1487 #endif // LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
const llvm::DataLayout & getDataLayout() const
TBAAAccessInfo getTBAAInfoForSubobject(LValue Base, QualType AccessType)
getTBAAInfoForSubobject - Get TBAA information for an access with a given base lvalue.
CGOpenCLRuntime & getOpenCLRuntime()
Return a reference to the configured OpenCL runtime.
llvm::Function * objc_retainAutoreleaseReturnValue
id objc_retainAutoreleaseReturnValue(id);
llvm::FunctionCallee objc_releaseRuntimeFunction
void objc_release(id); Note this is the runtime method not the intrinsic.
Represents a function declaration or definition.
Definition: Decl.h:1737
bool operator==(const OrderGlobalInits &RHS) const
llvm::Function * objc_copyWeak
void objc_copyWeak(id *dest, id *src);
void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C)
A (possibly-)qualified type.
Definition: Type.h:639
const CodeGenOptions & getCodeGenOpts() const
bool hasObjCRuntime()
Return true iff an Objective-C runtime has been configured.
llvm::LLVMContext & getLLVMContext()
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:29
Stmt - This represents one statement.
Definition: Stmt.h:65
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:966
Implements runtime-specific code generation functions.
Definition: CGObjCRuntime.h:63
Defines the clang::Module class, which describes a module in the source code.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
BlockByrefHelpers(CharUnits alignment)
The base class of the type hierarchy.
Definition: Type.h:1414
void setFunctionLinkage(GlobalDecl GD, llvm::Function *F)
Stores additional source code information like skipped ranges which is required by the coverage mappi...
virtual void clear()
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
constexpr XRayInstrMask Function
Definition: XRayInstr.h:38
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4155
static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V)
const CXXBaseSpecifier *const * path_const_iterator
Definition: Expr.h:3105
Represents a variable declaration or definition.
Definition: Decl.h:812
Objects with "hidden" visibility are not seen by the dynamic linker.
Definition: Visibility.h:36
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:2963
CGDebugInfo * getModuleDebugInfo()
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Definition: AddressSpaces.h:25
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition: CGDebugInfo.h:53
DiagnosticsEngine & getDiags() const
llvm::Constant * getAtomicSetterHelperFnMap(QualType Ty)
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Definition: Linkage.h:23
llvm::Function * objc_retainAutorelease
id objc_retainAutorelease(id);
llvm::GlobalVariable * getStaticLocalDeclGuardAddress(const VarDecl *D)
llvm::Constant * getAtomicGetterHelperFnMap(QualType Ty)
One of these records is kept for each identifier that is lexed.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
llvm::Function * objc_initWeak
id objc_initWeak(id*, id);
void AddCXXDtorEntry(llvm::FunctionCallee DtorFn, llvm::Constant *Object)
Add a destructor and object to add to the C++ global destructor function.
llvm::FunctionCallee objc_autoreleaseRuntimeFunction
id objc_autorelease(id); Note this is the runtime method not the intrinsic.
int Category
Definition: Format.cpp:1641
llvm::IndexedInstrProfReader * getPGOReader() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:49
Objects with "default" visibility are seen by the dynamic linker and act like normal objects...
Definition: Visibility.h:45
llvm::FunctionCallee objc_alloc_init
void objc_alloc_init(id);
llvm::Function * objc_release
void objc_release(id);
CGCUDARuntime & getCUDARuntime()
Return a reference to the configured CUDA runtime.
bool operator<(const OrderGlobalInits &RHS) const
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:37
Structor(int Priority, llvm::Constant *Initializer, llvm::Constant *AssociatedData)
Visibility
Describes the different kinds of visibility that a declaration may have.
Definition: Visibility.h:33
void setStaticLocalDeclAddress(const VarDecl *D, llvm::Constant *C)
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:148
llvm::Constant * getAddrOfGlobalBlockIfEmitted(const BlockExpr *BE)
Returns the address of a block which requires no caputres, or null if we&#39;ve yet to emit the block for...
void addDeferredVTable(const CXXRecordDecl *RD)
void setAtomicGetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
void addMissing(bool MainFile)
Record that a function we&#39;ve visited has no profile data.
Enums/classes describing ABI related information about constructors, destructors and thunks...
ItaniumVTableContext & getItaniumVTableContext()
Definition: CGVTables.h:78
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
const PreprocessorOptions & getPreprocessorOpts() const
void Profile(llvm::FoldingSetNodeID &id) const
llvm::Function * objc_moveWeak
void objc_moveWeak(id *dest, id *src);
Represents a linkage specification.
Definition: DeclCXX.h:2833
InstrProfStats & getPGOStats()
llvm::Constant * getStaticLocalDeclAddress(const VarDecl *D)
llvm::Function * objc_unsafeClaimAutoreleasedReturnValue
id objc_unsafeClaimAutoreleasedReturnValue(id);
llvm::Function * objc_retainAutoreleasedReturnValue
id objc_retainAutoreleasedReturnValue(id);
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:688
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:178
This represents &#39;#pragma omp requires...&#39; directive.
Definition: DeclOpenMP.h:345
unsigned Offset
Definition: Format.cpp:1640
Exposes information about the current target.
Definition: TargetInfo.h:161
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
CharUnits Alignment
The alignment of the field.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3857
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:636
This represents one expression.
Definition: Expr.h:108
Defines the clang::LangOptions interface.
SourceLocation End
Organizes the cross-function state that is used while generating code coverage mapping data...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5384
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2713
llvm::FunctionCallee objc_alloc
void objc_alloc(id);
void setStaticLocalDeclGuardAddress(const VarDecl *D, llvm::GlobalVariable *C)
MicrosoftVTableContext & getMicrosoftVTableContext()
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
Definition: Visibility.h:41
void addMismatched(bool MainFile)
Record that a function we&#39;ve visited has mismatched profile data.
TBAAAccessInfo getTBAAInfo() const
Definition: CGValue.h:307
UnaryOperator - This represents the unary-expression&#39;s (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:1929
const TargetInfo & getTarget() const
const LangOptions & getLangOpts() const
ASTContext & getContext() const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:235
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:34
virtual bool needsCopy() const
void addVisited(bool MainFile)
Record that we&#39;ve visited a function and whether or not that function was in the main source file...
llvm::Function * objc_loadWeakRetained
id objc_loadWeakRetained(id*);
Kind
llvm::FunctionCallee objc_autoreleasePoolPop
void objc_autoreleasePoolPop(void*);
Encodes a location in the source.
llvm::Function * clang_arc_use
void clang.arc.use(...);
llvm::Constant * getTypeDescriptorFromMap(QualType Ty)
This represents &#39;#pragma omp declare reduction ...&#39; directive.
Definition: DeclOpenMP.h:102
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3063
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2048
llvm::Function * objc_destroyWeak
void objc_destroyWeak(id*);
ObjCEntrypoints & getObjCEntrypoints() const
This file defines OpenMP nodes for declarative directives.
llvm::Function * objc_storeWeak
id objc_storeWeak(id*, id);
llvm::FunctionCallee objc_retainRuntimeFunction
id objc_retain(id); Note this is the runtime method not the intrinsic.
llvm::InlineAsm * retainAutoreleasedReturnValueMarker
A void(void) inline asm to use to mark that the return value of a call will be immediately retain...
const HeaderSearchOptions & getHeaderSearchOpts() const
An aligned address.
Definition: Address.h:24
virtual bool needsDispose() const
ItaniumVTableContext & getItaniumVTableContext()
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues, like target-specific attributes, builtins and so on.
Definition: TargetInfo.h:45
std::vector< Structor > CtorList
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
Dataflow Directional Tag Classes.
llvm::FoldingSet< BlockByrefHelpers > ByrefHelpersCache
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1265
int getUniqueBlockCount()
Fetches the global unique block count.
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:27
static llvm::Constant * EmitNullConstantForBase(CodeGenModule &CGM, llvm::Type *baseType, const CXXRecordDecl *base)
Emit the null constant for a base subobject.
CoverageMappingModuleGen * getCoverageMapping() const
llvm::Module & getModule() const
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3216
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2551
llvm::FunctionCallee objc_autoreleasePoolPopInvoke
void objc_autoreleasePoolPop(void*); Note this method is used when we are using exception handling ...
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:43
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:385
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
Definition: CodeGenTypes.h:118
bool hasDiagnostics()
Whether or not the stats we&#39;ve gathered indicate any potential problems.
This class records statistics on instrumentation based profiling.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
llvm::Function * objc_autoreleaseReturnValue
id objc_autoreleaseReturnValue(id);
void setAtomicSetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
llvm::Function * objc_autorelease
id objc_autorelease(id);
llvm::MDNode * getNoObjCARCExceptionsMetadata()
A pair of helper functions for a __block variable.
static llvm::Constant * EmitNullConstant(CodeGenModule &CGM, const RecordDecl *record, bool asCompleteObject)
llvm::FunctionCallee objc_allocWithZone
void objc_allocWithZone(id);
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
MicrosoftVTableContext & getMicrosoftVTableContext()
Definition: CGVTables.h:82
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
llvm::Function * objc_storeStrong
void objc_storeStrong(id*, id);
A specialization of Address that requires the address to be an LLVM Constant.
Definition: Address.h:74
llvm::Function * objc_loadWeak
id objc_loadWeak(id*);
OrderGlobalInits(unsigned int p, unsigned int l)
This represents &#39;#pragma omp declare mapper ...&#39; directive.
Definition: DeclOpenMP.h:217
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1599
llvm::Constant * getAddrOfCXXStructor(const CXXMethodDecl *MD, StructorType Type, const CGFunctionInfo *FnInfo=nullptr, llvm::FunctionType *FnType=nullptr, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
Return the address of the constructor/destructor of the given type.
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
CGCXXABI & getCXXABI() const
llvm::Function * objc_retain
id objc_retain(id);
GVALinkage
A more specific kind of linkage than enum Linkage.
Definition: Linkage.h:73
llvm::Function * objc_autoreleasePoolPush
void *objc_autoreleasePoolPush(void);
This structure provides a set of types that are commonly used during IR emission. ...
CodeGenVTables & getVTables()
LValue - This represents an lvalue references.
Definition: CGValue.h:166
This represents a decl that may have a name.
Definition: Decl.h:248
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:886
SanitizerMetadata * getSanitizerMetadata()
This represents &#39;#pragma omp threadprivate ...&#39; directive.
Definition: DeclOpenMP.h:39
Abstract information about a function or function prototype.
Definition: CGCall.h:44
llvm::Function * objc_retainBlock
id objc_retainBlock(id);
const llvm::Triple & getTriple() const