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 for linker options.
469  SmallVector<llvm::MDNode *, 16> LinkerOptionsMetadata;
470 
471  /// A vector of metadata strings for dependent libraries for ELF.
472  SmallVector<llvm::MDNode *, 16> ELFDependentLibraries;
473 
474  /// @name Cache for Objective-C runtime types
475  /// @{
476 
477  /// Cached reference to the class for constant strings. This value has type
478  /// int * but is actually an Obj-C class pointer.
479  llvm::WeakTrackingVH CFConstantStringClassRef;
480 
481  /// The type used to describe the state of a fast enumeration in
482  /// Objective-C's for..in loop.
483  QualType ObjCFastEnumerationStateType;
484 
485  /// @}
486 
487  /// Lazily create the Objective-C runtime
488  void createObjCRuntime();
489 
490  void createOpenCLRuntime();
491  void createOpenMPRuntime();
492  void createCUDARuntime();
493 
494  bool isTriviallyRecursive(const FunctionDecl *F);
495  bool shouldEmitFunction(GlobalDecl GD);
496  bool shouldOpportunisticallyEmitVTables();
497  /// Map used to be sure we don't emit the same CompoundLiteral twice.
498  llvm::DenseMap<const CompoundLiteralExpr *, llvm::GlobalVariable *>
499  EmittedCompoundLiterals;
500 
501  /// Map of the global blocks we've emitted, so that we don't have to re-emit
502  /// them if the constexpr evaluator gets aggressive.
503  llvm::DenseMap<const BlockExpr *, llvm::Constant *> EmittedGlobalBlocks;
504 
505  /// @name Cache for Blocks Runtime Globals
506  /// @{
507 
508  llvm::Constant *NSConcreteGlobalBlock = nullptr;
509  llvm::Constant *NSConcreteStackBlock = nullptr;
510 
511  llvm::FunctionCallee BlockObjectAssign = nullptr;
512  llvm::FunctionCallee BlockObjectDispose = nullptr;
513 
514  llvm::Type *BlockDescriptorType = nullptr;
515  llvm::Type *GenericBlockLiteralType = nullptr;
516 
517  struct {
519  } Block;
520 
521  /// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>)
522  llvm::Function *LifetimeStartFn = nullptr;
523 
524  /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>)
525  llvm::Function *LifetimeEndFn = nullptr;
526 
527  GlobalDecl initializedGlobalDecl;
528 
529  std::unique_ptr<SanitizerMetadata> SanitizerMD;
530 
531  /// @}
532 
533  llvm::MapVector<const Decl *, bool> DeferredEmptyCoverageMappingDecls;
534 
535  std::unique_ptr<CoverageMappingModuleGen> CoverageMapping;
536 
537  /// Mapping from canonical types to their metadata identifiers. We need to
538  /// maintain this mapping because identifiers may be formed from distinct
539  /// MDNodes.
540  typedef llvm::DenseMap<QualType, llvm::Metadata *> MetadataTypeMap;
541  MetadataTypeMap MetadataIdMap;
542  MetadataTypeMap VirtualMetadataIdMap;
543  MetadataTypeMap GeneralizedMetadataIdMap;
544 
545 public:
546  CodeGenModule(ASTContext &C, const HeaderSearchOptions &headersearchopts,
547  const PreprocessorOptions &ppopts,
548  const CodeGenOptions &CodeGenOpts, llvm::Module &M,
549  DiagnosticsEngine &Diags,
550  CoverageSourceInfo *CoverageInfo = nullptr);
551 
552  ~CodeGenModule();
553 
554  void clear();
555 
556  /// Finalize LLVM code generation.
557  void Release();
558 
559  /// Return true if we should emit location information for expressions.
560  bool getExpressionLocationsEnabled() const;
561 
562  /// Return a reference to the configured Objective-C runtime.
564  if (!ObjCRuntime) createObjCRuntime();
565  return *ObjCRuntime;
566  }
567 
568  /// Return true iff an Objective-C runtime has been configured.
569  bool hasObjCRuntime() { return !!ObjCRuntime; }
570 
571  /// Return a reference to the configured OpenCL runtime.
573  assert(OpenCLRuntime != nullptr);
574  return *OpenCLRuntime;
575  }
576 
577  /// Return a reference to the configured OpenMP runtime.
579  assert(OpenMPRuntime != nullptr);
580  return *OpenMPRuntime;
581  }
582 
583  /// Return a reference to the configured CUDA runtime.
585  assert(CUDARuntime != nullptr);
586  return *CUDARuntime;
587  }
588 
590  assert(ObjCData != nullptr);
591  return *ObjCData;
592  }
593 
594  // Version checking function, used to implement ObjC's @available:
595  // i32 @__isOSVersionAtLeast(i32, i32, i32)
596  llvm::FunctionCallee IsOSVersionAtLeastFn = nullptr;
597 
598  InstrProfStats &getPGOStats() { return PGOStats; }
599  llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); }
600 
602  return CoverageMapping.get();
603  }
604 
605  llvm::Constant *getStaticLocalDeclAddress(const VarDecl *D) {
606  return StaticLocalDeclMap[D];
607  }
609  llvm::Constant *C) {
610  StaticLocalDeclMap[D] = C;
611  }
612 
613  llvm::Constant *
614  getOrCreateStaticVarDecl(const VarDecl &D,
615  llvm::GlobalValue::LinkageTypes Linkage);
616 
617  llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) {
618  return StaticLocalDeclGuardMap[D];
619  }
621  llvm::GlobalVariable *C) {
622  StaticLocalDeclGuardMap[D] = C;
623  }
624 
625  bool lookupRepresentativeDecl(StringRef MangledName,
626  GlobalDecl &Result) const;
627 
628  llvm::Constant *getAtomicSetterHelperFnMap(QualType Ty) {
629  return AtomicSetterHelperFnMap[Ty];
630  }
632  llvm::Constant *Fn) {
633  AtomicSetterHelperFnMap[Ty] = Fn;
634  }
635 
636  llvm::Constant *getAtomicGetterHelperFnMap(QualType Ty) {
637  return AtomicGetterHelperFnMap[Ty];
638  }
640  llvm::Constant *Fn) {
641  AtomicGetterHelperFnMap[Ty] = Fn;
642  }
643 
644  llvm::Constant *getTypeDescriptorFromMap(QualType Ty) {
645  return TypeDescriptorMap[Ty];
646  }
647  void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C) {
648  TypeDescriptorMap[Ty] = C;
649  }
650 
651  CGDebugInfo *getModuleDebugInfo() { return DebugInfo.get(); }
652 
654  if (!NoObjCARCExceptionsMetadata)
655  NoObjCARCExceptionsMetadata = llvm::MDNode::get(getLLVMContext(), None);
656  return NoObjCARCExceptionsMetadata;
657  }
658 
659  ASTContext &getContext() const { return Context; }
660  const LangOptions &getLangOpts() const { return LangOpts; }
662  const { return HeaderSearchOpts; }
664  const { return PreprocessorOpts; }
665  const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
666  llvm::Module &getModule() const { return TheModule; }
667  DiagnosticsEngine &getDiags() const { return Diags; }
668  const llvm::DataLayout &getDataLayout() const {
669  return TheModule.getDataLayout();
670  }
671  const TargetInfo &getTarget() const { return Target; }
672  const llvm::Triple &getTriple() const { return Target.getTriple(); }
673  bool supportsCOMDAT() const;
674  void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO);
675 
676  CGCXXABI &getCXXABI() const { return *ABI; }
677  llvm::LLVMContext &getLLVMContext() { return VMContext; }
678 
679  bool shouldUseTBAA() const { return TBAA != nullptr; }
680 
681  const TargetCodeGenInfo &getTargetCodeGenInfo();
682 
683  CodeGenTypes &getTypes() { return Types; }
684 
685  CodeGenVTables &getVTables() { return VTables; }
686 
688  return VTables.getItaniumVTableContext();
689  }
690 
692  return VTables.getMicrosoftVTableContext();
693  }
694 
695  CtorList &getGlobalCtors() { return GlobalCtors; }
696  CtorList &getGlobalDtors() { return GlobalDtors; }
697 
698  /// getTBAATypeInfo - Get metadata used to describe accesses to objects of
699  /// the given type.
700  llvm::MDNode *getTBAATypeInfo(QualType QTy);
701 
702  /// getTBAAAccessInfo - Get TBAA information that describes an access to
703  /// an object of the given type.
704  TBAAAccessInfo getTBAAAccessInfo(QualType AccessType);
705 
706  /// getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an
707  /// access to a virtual table pointer.
708  TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType);
709 
710  llvm::MDNode *getTBAAStructInfo(QualType QTy);
711 
712  /// getTBAABaseTypeInfo - Get metadata that describes the given base access
713  /// type. Return null if the type is not suitable for use in TBAA access tags.
714  llvm::MDNode *getTBAABaseTypeInfo(QualType QTy);
715 
716  /// getTBAAAccessTagInfo - Get TBAA tag for a given memory access.
717  llvm::MDNode *getTBAAAccessTagInfo(TBAAAccessInfo Info);
718 
719  /// mergeTBAAInfoForCast - Get merged TBAA information for the purposes of
720  /// type casts.
721  TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
723 
724  /// mergeTBAAInfoForConditionalOperator - Get merged TBAA information for the
725  /// purposes of conditional operator.
726  TBAAAccessInfo mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA,
727  TBAAAccessInfo InfoB);
728 
729  /// mergeTBAAInfoForMemoryTransfer - Get merged TBAA information for the
730  /// purposes of memory transfer calls.
731  TBAAAccessInfo mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo,
732  TBAAAccessInfo SrcInfo);
733 
734  /// getTBAAInfoForSubobject - Get TBAA information for an access with a given
735  /// base lvalue.
737  if (Base.getTBAAInfo().isMayAlias())
738  return TBAAAccessInfo::getMayAliasInfo();
739  return getTBAAAccessInfo(AccessType);
740  }
741 
742  bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor);
743 
744  bool isPaddedAtomicType(QualType type);
745  bool isPaddedAtomicType(const AtomicType *type);
746 
747  /// DecorateInstructionWithTBAA - Decorate the instruction with a TBAA tag.
748  void DecorateInstructionWithTBAA(llvm::Instruction *Inst,
749  TBAAAccessInfo TBAAInfo);
750 
751  /// Adds !invariant.barrier !tag to instruction
752  void DecorateInstructionWithInvariantGroup(llvm::Instruction *I,
753  const CXXRecordDecl *RD);
754 
755  /// Emit the given number of characters as a value of type size_t.
756  llvm::ConstantInt *getSize(CharUnits numChars);
757 
758  /// Set the visibility for the given LLVM GlobalValue.
759  void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
760 
761  void setGlobalVisibilityAndLocal(llvm::GlobalValue *GV,
762  const NamedDecl *D) const;
763 
764  void setDSOLocal(llvm::GlobalValue *GV) const;
765 
766  void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const;
767  void setDLLImportDLLExport(llvm::GlobalValue *GV, const NamedDecl *D) const;
768  /// Set visibility, dllimport/dllexport and dso_local.
769  /// This must be called after dllimport/dllexport is set.
770  void setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const;
771  void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;
772 
773  /// Set the TLS mode for the given LLVM GlobalValue for the thread-local
774  /// variable declaration D.
775  void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const;
776 
777  static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V) {
778  switch (V) {
782  }
783  llvm_unreachable("unknown visibility!");
784  }
785 
786  llvm::Constant *GetAddrOfGlobal(GlobalDecl GD,
787  ForDefinition_t IsForDefinition
788  = NotForDefinition);
789 
790  /// Will return a global variable of the given type. If a variable with a
791  /// different type already exists then a new variable with the right type
792  /// will be created and all uses of the old variable will be replaced with a
793  /// bitcast to the new variable.
794  llvm::GlobalVariable *
795  CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty,
796  llvm::GlobalValue::LinkageTypes Linkage,
797  unsigned Alignment);
798 
799  llvm::Function *
800  CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty, const Twine &name,
801  const CGFunctionInfo &FI,
803  bool TLS = false);
804 
805  /// Return the AST address space of the underlying global variable for D, as
806  /// determined by its declaration. Normally this is the same as the address
807  /// space of D's type, but in CUDA, address spaces are associated with
808  /// declarations, not types. If D is nullptr, return the default address
809  /// space for global variable.
810  ///
811  /// For languages without explicit address spaces, if D has default address
812  /// space, target-specific global or constant address space may be returned.
813  LangAS GetGlobalVarAddressSpace(const VarDecl *D);
814 
815  /// Return the llvm::Constant for the address of the given global variable.
816  /// If Ty is non-null and if the global doesn't exist, then it will be created
817  /// with the specified type instead of whatever the normal requested type
818  /// would be. If IsForDefinition is true, it is guaranteed that an actual
819  /// global with type Ty will be returned, not conversion of a variable with
820  /// the same mangled name but some other type.
821  llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,
822  llvm::Type *Ty = nullptr,
823  ForDefinition_t IsForDefinition
824  = NotForDefinition);
825 
826  /// Return the AST address space of string literal, which is used to emit
827  /// the string literal as global variable in LLVM IR.
828  /// Note: This is not necessarily the address space of the string literal
829  /// in AST. For address space agnostic language, e.g. C++, string literal
830  /// in AST is always in default address space.
831  LangAS getStringLiteralAddressSpace() const;
832 
833  /// Return the address of the given function. If Ty is non-null, then this
834  /// function will use the specified type if it has to create it.
835  llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = nullptr,
836  bool ForVTable = false,
837  bool DontDefer = false,
838  ForDefinition_t IsForDefinition
839  = NotForDefinition);
840 
841  /// Get the address of the RTTI descriptor for the given type.
842  llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
843 
844  /// Get the address of a uuid descriptor .
845  ConstantAddress GetAddrOfUuidDescriptor(const CXXUuidofExpr* E);
846 
847  /// Get the address of the thunk for the given global decl.
848  llvm::Constant *GetAddrOfThunk(StringRef Name, llvm::Type *FnTy,
849  GlobalDecl GD);
850 
851  /// Get a reference to the target of VD.
852  ConstantAddress GetWeakRefReference(const ValueDecl *VD);
853 
854  /// Returns the assumed alignment of an opaque pointer to the given class.
855  CharUnits getClassPointerAlignment(const CXXRecordDecl *CD);
856 
857  /// Returns the assumed alignment of a virtual base of a class.
858  CharUnits getVBaseAlignment(CharUnits DerivedAlign,
859  const CXXRecordDecl *Derived,
860  const CXXRecordDecl *VBase);
861 
862  /// Given a class pointer with an actual known alignment, and the
863  /// expected alignment of an object at a dynamic offset w.r.t that
864  /// pointer, return the alignment to assume at the offset.
865  CharUnits getDynamicOffsetAlignment(CharUnits ActualAlign,
866  const CXXRecordDecl *Class,
867  CharUnits ExpectedTargetAlign);
868 
869  CharUnits
870  computeNonVirtualBaseClassOffset(const CXXRecordDecl *DerivedClass,
873 
874  /// Returns the offset from a derived class to a class. Returns null if the
875  /// offset is 0.
876  llvm::Constant *
877  GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
880 
881  llvm::FoldingSet<BlockByrefHelpers> ByrefHelpersCache;
882 
883  /// Fetches the global unique block count.
884  int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; }
885 
886  /// Fetches the type of a generic block descriptor.
887  llvm::Type *getBlockDescriptorType();
888 
889  /// The type of a generic block literal.
890  llvm::Type *getGenericBlockLiteralType();
891 
892  /// Gets the address of a block which requires no captures.
893  llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name);
894 
895  /// Returns the address of a block which requires no caputres, or null if
896  /// we've yet to emit the block for BE.
897  llvm::Constant *getAddrOfGlobalBlockIfEmitted(const BlockExpr *BE) {
898  return EmittedGlobalBlocks.lookup(BE);
899  }
900 
901  /// Notes that BE's global block is available via Addr. Asserts that BE
902  /// isn't already emitted.
903  void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr);
904 
905  /// Return a pointer to a constant CFString object for the given string.
906  ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal);
907 
908  /// Return a pointer to a constant NSString object for the given string. Or a
909  /// user defined String object as defined via
910  /// -fconstant-string-class=class_name option.
911  ConstantAddress GetAddrOfConstantString(const StringLiteral *Literal);
912 
913  /// Return a constant array for the given string.
914  llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E);
915 
916  /// Return a pointer to a constant array for the given string literal.
918  GetAddrOfConstantStringFromLiteral(const StringLiteral *S,
919  StringRef Name = ".str");
920 
921  /// Return a pointer to a constant array for the given ObjCEncodeExpr node.
923  GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *);
924 
925  /// Returns a pointer to a character array containing the literal and a
926  /// terminating '\0' character. The result has pointer to array type.
927  ///
928  /// \param GlobalName If provided, the name to use for the global (if one is
929  /// created).
931  GetAddrOfConstantCString(const std::string &Str,
932  const char *GlobalName = nullptr);
933 
934  /// Returns a pointer to a constant global variable for the given file-scope
935  /// compound literal expression.
936  ConstantAddress GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr*E);
937 
938  /// If it's been emitted already, returns the GlobalVariable corresponding to
939  /// a compound literal. Otherwise, returns null.
940  llvm::GlobalVariable *
941  getAddrOfConstantCompoundLiteralIfEmitted(const CompoundLiteralExpr *E);
942 
943  /// Notes that CLE's GlobalVariable is GV. Asserts that CLE isn't already
944  /// emitted.
945  void setAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *CLE,
946  llvm::GlobalVariable *GV);
947 
948  /// Returns a pointer to a global variable representing a temporary
949  /// with static or thread storage duration.
950  ConstantAddress GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E,
951  const Expr *Inner);
952 
953  /// Retrieve the record type that describes the state of an
954  /// Objective-C fast enumeration loop (for..in).
955  QualType getObjCFastEnumerationStateType();
956 
957  // Produce code for this constructor/destructor. This method doesn't try
958  // to apply any ABI rules about which other constructors/destructors
959  // are needed or if they are alias to each other.
960  llvm::Function *codegenCXXStructor(GlobalDecl GD);
961 
962  /// Return the address of the constructor/destructor of the given type.
963  llvm::Constant *
964  getAddrOfCXXStructor(GlobalDecl GD, const CGFunctionInfo *FnInfo = nullptr,
965  llvm::FunctionType *FnType = nullptr,
966  bool DontDefer = false,
967  ForDefinition_t IsForDefinition = NotForDefinition) {
968  return cast<llvm::Constant>(getAddrAndTypeOfCXXStructor(GD, FnInfo, FnType,
969  DontDefer,
970  IsForDefinition)
971  .getCallee());
972  }
973 
974  llvm::FunctionCallee getAddrAndTypeOfCXXStructor(
975  GlobalDecl GD, 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 appropriate metadata value.
1159  void AddDependentLib(StringRef Lib);
1160 
1161 
1162  llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD);
1163 
1164  void setFunctionLinkage(GlobalDecl GD, llvm::Function *F) {
1165  F->setLinkage(getFunctionLinkage(GD));
1166  }
1167 
1168  /// Return the appropriate linkage for the vtable, VTT, and type information
1169  /// of the given class.
1170  llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD);
1171 
1172  /// Return the store size, in character units, of the given LLVM type.
1173  CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const;
1174 
1175  /// Returns LLVM linkage for a declarator.
1176  llvm::GlobalValue::LinkageTypes
1177  getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage,
1178  bool IsConstantVariable);
1179 
1180  /// Returns LLVM linkage for a declarator.
1181  llvm::GlobalValue::LinkageTypes
1182  getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant);
1183 
1184  /// Emit all the global annotations.
1185  void EmitGlobalAnnotations();
1186 
1187  /// Emit an annotation string.
1188  llvm::Constant *EmitAnnotationString(StringRef Str);
1189 
1190  /// Emit the annotation's translation unit.
1191  llvm::Constant *EmitAnnotationUnit(SourceLocation Loc);
1192 
1193  /// Emit the annotation line number.
1194  llvm::Constant *EmitAnnotationLineNo(SourceLocation L);
1195 
1196  /// Generate the llvm::ConstantStruct which contains the annotation
1197  /// information for a given GlobalValue. The annotation struct is
1198  /// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the
1199  /// GlobalValue being annotated. The second field is the constant string
1200  /// created from the AnnotateAttr's annotation. The third field is a constant
1201  /// string containing the name of the translation unit. The fourth field is
1202  /// the line number in the file of the annotated value declaration.
1203  llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV,
1204  const AnnotateAttr *AA,
1205  SourceLocation L);
1206 
1207  /// Add global annotations that are set on D, for the global GV. Those
1208  /// annotations are emitted during finalization of the LLVM code.
1209  void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV);
1210 
1211  bool isInSanitizerBlacklist(SanitizerMask Kind, llvm::Function *Fn,
1212  SourceLocation Loc) const;
1213 
1214  bool isInSanitizerBlacklist(llvm::GlobalVariable *GV, SourceLocation Loc,
1215  QualType Ty,
1216  StringRef Category = StringRef()) const;
1217 
1218  /// Imbue XRay attributes to a function, applying the always/never attribute
1219  /// lists in the process. Returns true if we did imbue attributes this way,
1220  /// false otherwise.
1221  bool imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc,
1222  StringRef Category = StringRef()) const;
1223 
1225  return SanitizerMD.get();
1226  }
1227 
1229  DeferredVTables.push_back(RD);
1230  }
1231 
1232  /// Emit code for a single global function or var decl. Forward declarations
1233  /// are emitted lazily.
1234  void EmitGlobal(GlobalDecl D);
1235 
1236  bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
1237 
1238  llvm::GlobalValue *GetGlobalValue(StringRef Ref);
1239 
1240  /// Set attributes which are common to any form of a global definition (alias,
1241  /// Objective-C method, function, global variable).
1242  ///
1243  /// NOTE: This should only be called for definitions.
1244  void SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV);
1245 
1246  void addReplacement(StringRef Name, llvm::Constant *C);
1247 
1248  void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C);
1249 
1250  /// Emit a code for threadprivate directive.
1251  /// \param D Threadprivate declaration.
1252  void EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D);
1253 
1254  /// Emit a code for declare reduction construct.
1255  void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D,
1256  CodeGenFunction *CGF = nullptr);
1257 
1258  /// Emit a code for declare mapper construct.
1259  void EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D,
1260  CodeGenFunction *CGF = nullptr);
1261 
1262  /// Emit a code for requires directive.
1263  /// \param D Requires declaration
1264  void EmitOMPRequiresDecl(const OMPRequiresDecl *D);
1265 
1266  /// Returns whether the given record has hidden LTO visibility and therefore
1267  /// may participate in (single-module) CFI and whole-program vtable
1268  /// optimization.
1269  bool HasHiddenLTOVisibility(const CXXRecordDecl *RD);
1270 
1271  /// Emit type metadata for the given vtable using the given layout.
1272  void EmitVTableTypeMetadata(llvm::GlobalVariable *VTable,
1273  const VTableLayout &VTLayout);
1274 
1275  /// Generate a cross-DSO type identifier for MD.
1276  llvm::ConstantInt *CreateCrossDsoCfiTypeId(llvm::Metadata *MD);
1277 
1278  /// Create a metadata identifier for the given type. This may either be an
1279  /// MDString (for external identifiers) or a distinct unnamed MDNode (for
1280  /// internal identifiers).
1281  llvm::Metadata *CreateMetadataIdentifierForType(QualType T);
1282 
1283  /// Create a metadata identifier that is intended to be used to check virtual
1284  /// calls via a member function pointer.
1285  llvm::Metadata *CreateMetadataIdentifierForVirtualMemPtrType(QualType T);
1286 
1287  /// Create a metadata identifier for the generalization of the given type.
1288  /// This may either be an MDString (for external identifiers) or a distinct
1289  /// unnamed MDNode (for internal identifiers).
1290  llvm::Metadata *CreateMetadataIdentifierGeneralized(QualType T);
1291 
1292  /// Create and attach type metadata to the given function.
1293  void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
1294  llvm::Function *F);
1295 
1296  /// Returns whether this module needs the "all-vtables" type identifier.
1297  bool NeedAllVtablesTypeId() const;
1298 
1299  /// Create and attach type metadata for the given vtable.
1300  void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset,
1301  const CXXRecordDecl *RD);
1302 
1303  /// Return a vector of most-base classes for RD. This is used to implement
1304  /// control flow integrity checks for member function pointers.
1305  ///
1306  /// A most-base class of a class C is defined as a recursive base class of C,
1307  /// including C itself, that does not have any bases.
1308  std::vector<const CXXRecordDecl *>
1309  getMostBaseClasses(const CXXRecordDecl *RD);
1310 
1311  /// Get the declaration of std::terminate for the platform.
1312  llvm::FunctionCallee getTerminateFn();
1313 
1314  llvm::SanitizerStatReport &getSanStats();
1315 
1316  llvm::Value *
1317  createOpenCLIntToSamplerConversion(const Expr *E, CodeGenFunction &CGF);
1318 
1319  /// OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument
1320  /// information in the program executable. The argument information stored
1321  /// includes the argument name, its type, the address and access qualifiers
1322  /// used. This helper can be used to generate metadata for source code kernel
1323  /// function as well as generated implicitly kernels. If a kernel is generated
1324  /// implicitly null value has to be passed to the last two parameters,
1325  /// otherwise all parameters must have valid non-null values.
1326  /// \param FN is a pointer to IR function being generated.
1327  /// \param FD is a pointer to function declaration if any.
1328  /// \param CGF is a pointer to CodeGenFunction that generates this function.
1329  void GenOpenCLArgMetadata(llvm::Function *FN,
1330  const FunctionDecl *FD = nullptr,
1331  CodeGenFunction *CGF = nullptr);
1332 
1333  /// Get target specific null pointer.
1334  /// \param T is the LLVM type of the null pointer.
1335  /// \param QT is the clang QualType of the null pointer.
1336  llvm::Constant *getNullPointer(llvm::PointerType *T, QualType QT);
1337 
1338 private:
1339  llvm::Constant *GetOrCreateLLVMFunction(
1340  StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,
1341  bool DontDefer = false, bool IsThunk = false,
1342  llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1343  ForDefinition_t IsForDefinition = NotForDefinition);
1344 
1345  llvm::Constant *GetOrCreateMultiVersionResolver(GlobalDecl GD,
1346  llvm::Type *DeclTy,
1347  const FunctionDecl *FD);
1348  void UpdateMultiVersionNames(GlobalDecl GD, const FunctionDecl *FD);
1349 
1350  llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName,
1351  llvm::PointerType *PTy,
1352  const VarDecl *D,
1353  ForDefinition_t IsForDefinition
1354  = NotForDefinition);
1355 
1356  bool GetCPUAndFeaturesAttributes(GlobalDecl GD,
1357  llvm::AttrBuilder &AttrBuilder);
1358  void setNonAliasAttributes(GlobalDecl GD, llvm::GlobalObject *GO);
1359 
1360  /// Set function attributes for a function declaration.
1361  void SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
1362  bool IsIncompleteFunction, bool IsThunk);
1363 
1364  void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = nullptr);
1365 
1366  void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
1367  void EmitMultiVersionFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
1368 
1369  void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false);
1370  void EmitAliasDefinition(GlobalDecl GD);
1371  void emitIFuncDefinition(GlobalDecl GD);
1372  void emitCPUDispatchDefinition(GlobalDecl GD);
1373  void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
1374  void EmitObjCIvarInitializations(ObjCImplementationDecl *D);
1375 
1376  // C++ related functions.
1377 
1378  void EmitDeclContext(const DeclContext *DC);
1379  void EmitLinkageSpec(const LinkageSpecDecl *D);
1380 
1381  /// Emit the function that initializes C++ thread_local variables.
1382  void EmitCXXThreadLocalInitFunc();
1383 
1384  /// Emit the function that initializes C++ globals.
1385  void EmitCXXGlobalInitFunc();
1386 
1387  /// Emit the function that destroys C++ globals.
1388  void EmitCXXGlobalDtorFunc();
1389 
1390  /// Emit the function that initializes the specified global (if PerformInit is
1391  /// true) and registers its destructor.
1392  void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
1393  llvm::GlobalVariable *Addr,
1394  bool PerformInit);
1395 
1396  void EmitPointerToInitFunc(const VarDecl *VD, llvm::GlobalVariable *Addr,
1397  llvm::Function *InitFunc, InitSegAttr *ISA);
1398 
1399  // FIXME: Hardcoding priority here is gross.
1400  void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535,
1401  llvm::Constant *AssociatedData = nullptr);
1402  void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535);
1403 
1404  /// EmitCtorList - Generates a global array of functions and priorities using
1405  /// the given list and name. This array will have appending linkage and is
1406  /// suitable for use as a LLVM constructor or destructor array. Clears Fns.
1407  void EmitCtorList(CtorList &Fns, const char *GlobalName);
1408 
1409  /// Emit any needed decls for which code generation was deferred.
1410  void EmitDeferred();
1411 
1412  /// Try to emit external vtables as available_externally if they have emitted
1413  /// all inlined virtual functions. It runs after EmitDeferred() and therefore
1414  /// is not allowed to create new references to things that need to be emitted
1415  /// lazily.
1416  void EmitVTablesOpportunistically();
1417 
1418  /// Call replaceAllUsesWith on all pairs in Replacements.
1419  void applyReplacements();
1420 
1421  /// Call replaceAllUsesWith on all pairs in GlobalValReplacements.
1422  void applyGlobalValReplacements();
1423 
1424  void checkAliases();
1425 
1426  std::map<int, llvm::TinyPtrVector<llvm::Function *>> DtorsUsingAtExit;
1427 
1428  /// Register functions annotated with __attribute__((destructor)) using
1429  /// __cxa_atexit, if it is available, or atexit otherwise.
1430  void registerGlobalDtorsWithAtExit();
1431 
1432  void emitMultiVersionFunctions();
1433 
1434  /// Emit any vtables which we deferred and still have a use for.
1435  void EmitDeferredVTables();
1436 
1437  /// Emit a dummy function that reference a CoreFoundation symbol when
1438  /// @available is used on Darwin.
1439  void emitAtAvailableLinkGuard();
1440 
1441  /// Emit the llvm.used and llvm.compiler.used metadata.
1442  void emitLLVMUsed();
1443 
1444  /// Emit the link options introduced by imported modules.
1445  void EmitModuleLinkOptions();
1446 
1447  /// Emit aliases for internal-linkage declarations inside "C" language
1448  /// linkage specifications, giving them the "expected" name where possible.
1449  void EmitStaticExternCAliases();
1450 
1451  void EmitDeclMetadata();
1452 
1453  /// Emit the Clang version as llvm.ident metadata.
1454  void EmitVersionIdentMetadata();
1455 
1456  /// Emit the Clang commandline as llvm.commandline metadata.
1457  void EmitCommandLineMetadata();
1458 
1459  /// Emits target specific Metadata for global declarations.
1460  void EmitTargetMetadata();
1461 
1462  /// Emits OpenCL specific Metadata e.g. OpenCL version.
1463  void EmitOpenCLMetadata();
1464 
1465  /// Emit the llvm.gcov metadata used to tell LLVM where to emit the .gcno and
1466  /// .gcda files in a way that persists in .bc files.
1467  void EmitCoverageFile();
1468 
1469  /// Emits the initializer for a uuidof string.
1470  llvm::Constant *EmitUuidofInitializer(StringRef uuidstr);
1471 
1472  /// Determine whether the definition must be emitted; if this returns \c
1473  /// false, the definition can be emitted lazily if it's used.
1474  bool MustBeEmitted(const ValueDecl *D);
1475 
1476  /// Determine whether the definition can be emitted eagerly, or should be
1477  /// delayed until the end of the translation unit. This is relevant for
1478  /// definitions whose linkage can change, e.g. implicit function instantions
1479  /// which may later be explicitly instantiated.
1480  bool MayBeEmittedEagerly(const ValueDecl *D);
1481 
1482  /// Check whether we can use a "simpler", more core exceptions personality
1483  /// function.
1484  void SimplifyPersonality();
1485 
1486  /// Helper function for ConstructAttributeList and AddDefaultFnAttrs.
1487  /// Constructs an AttrList for a function with the given properties.
1488  void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone,
1489  bool AttrOnCallSite,
1490  llvm::AttrBuilder &FuncAttrs);
1491 
1492  llvm::Metadata *CreateMetadataIdentifierImpl(QualType T, MetadataTypeMap &Map,
1493  StringRef Suffix);
1494 };
1495 
1496 } // end namespace CodeGen
1497 } // end namespace clang
1498 
1499 #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:1743
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:983
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:88
llvm::Constant * getAddrOfCXXStructor(GlobalDecl GD, 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.
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:4332
static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V)
const CXXBaseSpecifier *const * path_const_iterator
Definition: Expr.h:3110
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:2968
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:54
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:1710
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:2951
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:1709
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:3863
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...
#define V(N, I)
Definition: ASTContext.h:2905
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5454
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2826
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:1934
const TargetInfo & getTarget() const
const LangOptions & getLangOpts() const
ASTContext & getContext() const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:243
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:40
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:3069
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:1264
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:3221
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:407
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
Definition: CodeGenTypes.h:59
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
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:916
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