Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
clang 20.0.0git
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/DeclCXX.h"
21#include "clang/AST/DeclObjC.h"
24#include "clang/AST/Mangle.h"
25#include "clang/Basic/ABI.h"
33#include "llvm/ADT/DenseMap.h"
34#include "llvm/ADT/MapVector.h"
35#include "llvm/ADT/SetVector.h"
36#include "llvm/ADT/SmallPtrSet.h"
37#include "llvm/ADT/StringMap.h"
38#include "llvm/IR/Module.h"
39#include "llvm/IR/ValueHandle.h"
40#include "llvm/Transforms/Utils/SanitizerStats.h"
41#include <optional>
42
43namespace llvm {
44class Module;
45class Constant;
46class ConstantInt;
47class Function;
48class GlobalValue;
49class DataLayout;
50class FunctionType;
51class LLVMContext;
52class IndexedInstrProfReader;
53
54namespace vfs {
55class FileSystem;
56}
57}
58
59namespace clang {
60class ASTContext;
61class AtomicType;
62class FunctionDecl;
63class IdentifierInfo;
64class ObjCImplementationDecl;
65class ObjCEncodeExpr;
66class BlockExpr;
67class CharUnits;
68class Decl;
69class Expr;
70class Stmt;
71class StringLiteral;
72class NamedDecl;
73class PointerAuthSchema;
74class ValueDecl;
75class VarDecl;
76class LangOptions;
77class CodeGenOptions;
78class HeaderSearchOptions;
79class DiagnosticsEngine;
80class AnnotateAttr;
81class CXXDestructorDecl;
82class Module;
83class CoverageSourceInfo;
84class InitSegAttr;
85
86namespace CodeGen {
87
88class CodeGenFunction;
89class CodeGenTBAA;
90class CGCXXABI;
91class CGDebugInfo;
92class CGObjCRuntime;
93class CGOpenCLRuntime;
94class CGOpenMPRuntime;
95class CGCUDARuntime;
96class CGHLSLRuntime;
97class CoverageMappingModuleGen;
98class TargetCodeGenInfo;
99
100enum ForDefinition_t : bool {
102 ForDefinition = true
104
105/// The Counter with an optional additional Counter for
106/// branches. `Skipped` counter can be calculated with `Executed` and
107/// a common Counter (like `Parent`) as `(Parent-Executed)`.
108///
109/// In SingleByte mode, Counters are binary. Subtraction is not
110/// applicable (but addition is capable). In this case, both
111/// `Executed` and `Skipped` counters are required. `Skipped` is
112/// `None` by default. It is allocated in the coverage mapping.
113///
114/// There might be cases that `Parent` could be induced with
115/// `(Executed+Skipped)`. This is not always applicable.
117public:
118 /// Optional value.
119 class ValueOpt {
120 private:
121 static constexpr uint32_t None = (1u << 31); /// None is allocated.
122 static constexpr uint32_t Mask = None - 1;
123
124 uint32_t Val;
125
126 public:
127 ValueOpt() : Val(None) {}
128
129 ValueOpt(unsigned InitVal) {
130 assert(!(InitVal & ~Mask));
131 Val = InitVal;
132 }
133
134 bool hasValue() const { return !(Val & None); }
135
136 operator uint32_t() const { return Val; }
137 };
138
140 ValueOpt Skipped; /// May be None.
141
142 /// Initialized with Skipped=None.
143 CounterPair(unsigned Val) : Executed(Val) {}
144
145 // FIXME: Should work with {None, None}
147};
148
150 unsigned int priority;
151 unsigned int lex_order;
152 OrderGlobalInitsOrStermFinalizers(unsigned int p, unsigned int l)
153 : priority(p), lex_order(l) {}
154
156 return priority == RHS.priority && lex_order == RHS.lex_order;
157 }
158
160 return std::tie(priority, lex_order) <
161 std::tie(RHS.priority, RHS.lex_order);
162 }
163};
164
166 ObjCEntrypoints() { memset(this, 0, sizeof(*this)); }
167
168 /// void objc_alloc(id);
169 llvm::FunctionCallee objc_alloc;
170
171 /// void objc_allocWithZone(id);
172 llvm::FunctionCallee objc_allocWithZone;
173
174 /// void objc_alloc_init(id);
175 llvm::FunctionCallee objc_alloc_init;
176
177 /// void objc_autoreleasePoolPop(void*);
178 llvm::FunctionCallee objc_autoreleasePoolPop;
179
180 /// void objc_autoreleasePoolPop(void*);
181 /// Note this method is used when we are using exception handling
182 llvm::FunctionCallee objc_autoreleasePoolPopInvoke;
183
184 /// void *objc_autoreleasePoolPush(void);
186
187 /// id objc_autorelease(id);
188 llvm::Function *objc_autorelease;
189
190 /// id objc_autorelease(id);
191 /// Note this is the runtime method not the intrinsic.
193
194 /// id objc_autoreleaseReturnValue(id);
196
197 /// void objc_copyWeak(id *dest, id *src);
198 llvm::Function *objc_copyWeak;
199
200 /// void objc_destroyWeak(id*);
201 llvm::Function *objc_destroyWeak;
202
203 /// id objc_initWeak(id*, id);
204 llvm::Function *objc_initWeak;
205
206 /// id objc_loadWeak(id*);
207 llvm::Function *objc_loadWeak;
208
209 /// id objc_loadWeakRetained(id*);
210 llvm::Function *objc_loadWeakRetained;
211
212 /// void objc_moveWeak(id *dest, id *src);
213 llvm::Function *objc_moveWeak;
214
215 /// id objc_retain(id);
216 llvm::Function *objc_retain;
217
218 /// id objc_retain(id);
219 /// Note this is the runtime method not the intrinsic.
220 llvm::FunctionCallee objc_retainRuntimeFunction;
221
222 /// id objc_retainAutorelease(id);
223 llvm::Function *objc_retainAutorelease;
224
225 /// id objc_retainAutoreleaseReturnValue(id);
227
228 /// id objc_retainAutoreleasedReturnValue(id);
230
231 /// id objc_retainBlock(id);
232 llvm::Function *objc_retainBlock;
233
234 /// void objc_release(id);
235 llvm::Function *objc_release;
236
237 /// void objc_release(id);
238 /// Note this is the runtime method not the intrinsic.
239 llvm::FunctionCallee objc_releaseRuntimeFunction;
240
241 /// void objc_storeStrong(id*, id);
242 llvm::Function *objc_storeStrong;
243
244 /// id objc_storeWeak(id*, id);
245 llvm::Function *objc_storeWeak;
246
247 /// id objc_unsafeClaimAutoreleasedReturnValue(id);
249
250 /// A void(void) inline asm to use to mark that the return value of
251 /// a call will be immediately retain.
253
254 /// void clang.arc.use(...);
255 llvm::Function *clang_arc_use;
256
257 /// void clang.arc.noop.use(...);
258 llvm::Function *clang_arc_noop_use;
259};
260
261/// This class records statistics on instrumentation based profiling.
263 uint32_t VisitedInMainFile = 0;
264 uint32_t MissingInMainFile = 0;
265 uint32_t Visited = 0;
266 uint32_t Missing = 0;
267 uint32_t Mismatched = 0;
268
269public:
270 InstrProfStats() = default;
271 /// Record that we've visited a function and whether or not that function was
272 /// in the main source file.
273 void addVisited(bool MainFile) {
274 if (MainFile)
275 ++VisitedInMainFile;
276 ++Visited;
277 }
278 /// Record that a function we've visited has no profile data.
279 void addMissing(bool MainFile) {
280 if (MainFile)
281 ++MissingInMainFile;
282 ++Missing;
283 }
284 /// Record that a function we've visited has mismatched profile data.
285 void addMismatched(bool MainFile) { ++Mismatched; }
286 /// Whether or not the stats we've gathered indicate any potential problems.
287 bool hasDiagnostics() { return Missing || Mismatched; }
288 /// Report potential problems we've found to \c Diags.
289 void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile);
290};
291
292/// A pair of helper functions for a __block variable.
293class BlockByrefHelpers : public llvm::FoldingSetNode {
294 // MSVC requires this type to be complete in order to process this
295 // header.
296public:
297 llvm::Constant *CopyHelper;
298 llvm::Constant *DisposeHelper;
299
300 /// The alignment of the field. This is important because
301 /// different offsets to the field within the byref struct need to
302 /// have different helper functions.
304
306 : CopyHelper(nullptr), DisposeHelper(nullptr), Alignment(alignment) {}
308 virtual ~BlockByrefHelpers();
309
310 void Profile(llvm::FoldingSetNodeID &id) const {
311 id.AddInteger(Alignment.getQuantity());
312 profileImpl(id);
313 }
314 virtual void profileImpl(llvm::FoldingSetNodeID &id) const = 0;
315
316 virtual bool needsCopy() const { return true; }
317 virtual void emitCopy(CodeGenFunction &CGF, Address dest, Address src) = 0;
318
319 virtual bool needsDispose() const { return true; }
320 virtual void emitDispose(CodeGenFunction &CGF, Address field) = 0;
321};
322
323/// This class organizes the cross-function state that is used while generating
324/// LLVM code.
326 CodeGenModule(const CodeGenModule &) = delete;
327 void operator=(const CodeGenModule &) = delete;
328
329public:
330 struct Structor {
332 : Priority(0), LexOrder(~0u), Initializer(nullptr),
333 AssociatedData(nullptr) {}
334 Structor(int Priority, unsigned LexOrder, llvm::Constant *Initializer,
335 llvm::Constant *AssociatedData)
339 unsigned LexOrder;
340 llvm::Constant *Initializer;
341 llvm::Constant *AssociatedData;
342 };
343
344 typedef std::vector<Structor> CtorList;
345
346private:
347 ASTContext &Context;
348 const LangOptions &LangOpts;
349 IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS; // Only used for debug info.
350 const HeaderSearchOptions &HeaderSearchOpts; // Only used for debug info.
351 const PreprocessorOptions &PreprocessorOpts; // Only used for debug info.
352 const CodeGenOptions &CodeGenOpts;
353 unsigned NumAutoVarInit = 0;
354 llvm::Module &TheModule;
355 DiagnosticsEngine &Diags;
356 const TargetInfo &Target;
357 std::unique_ptr<CGCXXABI> ABI;
358 llvm::LLVMContext &VMContext;
359 std::string ModuleNameHash;
360 bool CXX20ModuleInits = false;
361 std::unique_ptr<CodeGenTBAA> TBAA;
362
363 mutable std::unique_ptr<TargetCodeGenInfo> TheTargetCodeGenInfo;
364
365 // This should not be moved earlier, since its initialization depends on some
366 // of the previous reference members being already initialized and also checks
367 // if TheTargetCodeGenInfo is NULL
368 std::unique_ptr<CodeGenTypes> Types;
369
370 /// Holds information about C++ vtables.
371 CodeGenVTables VTables;
372
373 std::unique_ptr<CGObjCRuntime> ObjCRuntime;
374 std::unique_ptr<CGOpenCLRuntime> OpenCLRuntime;
375 std::unique_ptr<CGOpenMPRuntime> OpenMPRuntime;
376 std::unique_ptr<CGCUDARuntime> CUDARuntime;
377 std::unique_ptr<CGHLSLRuntime> HLSLRuntime;
378 std::unique_ptr<CGDebugInfo> DebugInfo;
379 std::unique_ptr<ObjCEntrypoints> ObjCData;
380 llvm::MDNode *NoObjCARCExceptionsMetadata = nullptr;
381 std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader;
382 InstrProfStats PGOStats;
383 std::unique_ptr<llvm::SanitizerStatReport> SanStats;
384 StackExhaustionHandler StackHandler;
385
386 // A set of references that have only been seen via a weakref so far. This is
387 // used to remove the weak of the reference if we ever see a direct reference
388 // or a definition.
390
391 /// This contains all the decls which have definitions but/ which are deferred
392 /// for emission and therefore should only be output if they are actually
393 /// used. If a decl is in this, then it is known to have not been referenced
394 /// yet.
395 llvm::DenseMap<StringRef, GlobalDecl> DeferredDecls;
396
397 llvm::StringSet<llvm::BumpPtrAllocator> DeferredResolversToEmit;
398
399 /// This is a list of deferred decls which we have seen that *are* actually
400 /// referenced. These get code generated when the module is done.
401 std::vector<GlobalDecl> DeferredDeclsToEmit;
402 void addDeferredDeclToEmit(GlobalDecl GD) {
403 DeferredDeclsToEmit.emplace_back(GD);
404 addEmittedDeferredDecl(GD);
405 }
406
407 /// Decls that were DeferredDecls and have now been emitted.
408 llvm::DenseMap<llvm::StringRef, GlobalDecl> EmittedDeferredDecls;
409
410 void addEmittedDeferredDecl(GlobalDecl GD) {
411 // Reemission is only needed in incremental mode.
412 if (!Context.getLangOpts().IncrementalExtensions)
413 return;
414
415 // Assume a linkage by default that does not need reemission.
416 auto L = llvm::GlobalValue::ExternalLinkage;
417 if (llvm::isa<FunctionDecl>(GD.getDecl()))
418 L = getFunctionLinkage(GD);
419 else if (auto *VD = llvm::dyn_cast<VarDecl>(GD.getDecl()))
421
422 if (llvm::GlobalValue::isInternalLinkage(L) ||
423 llvm::GlobalValue::isLinkOnceLinkage(L) ||
424 llvm::GlobalValue::isWeakLinkage(L)) {
425 EmittedDeferredDecls[getMangledName(GD)] = GD;
426 }
427 }
428
429 /// List of alias we have emitted. Used to make sure that what they point to
430 /// is defined once we get to the end of the of the translation unit.
431 std::vector<GlobalDecl> Aliases;
432
433 /// List of multiversion functions to be emitted. This list is processed in
434 /// conjunction with other deferred symbols and is used to ensure that
435 /// multiversion function resolvers and ifuncs are defined and emitted.
436 std::vector<GlobalDecl> MultiVersionFuncs;
437
438 llvm::MapVector<StringRef, llvm::TrackingVH<llvm::Constant>> Replacements;
439
440 /// List of global values to be replaced with something else. Used when we
441 /// want to replace a GlobalValue but can't identify it by its mangled name
442 /// anymore (because the name is already taken).
444 GlobalValReplacements;
445
446 /// Variables for which we've emitted globals containing their constant
447 /// values along with the corresponding globals, for opportunistic reuse.
448 llvm::DenseMap<const VarDecl*, llvm::GlobalVariable*> InitializerConstants;
449
450 /// Set of global decls for which we already diagnosed mangled name conflict.
451 /// Required to not issue a warning (on a mangling conflict) multiple times
452 /// for the same decl.
453 llvm::DenseSet<GlobalDecl> DiagnosedConflictingDefinitions;
454
455 /// A queue of (optional) vtables to consider emitting.
456 std::vector<const CXXRecordDecl*> DeferredVTables;
457
458 /// A queue of (optional) vtables that may be emitted opportunistically.
459 std::vector<const CXXRecordDecl *> OpportunisticVTables;
460
461 /// List of global values which are required to be present in the object file;
462 /// bitcast to i8*. This is used for forcing visibility of symbols which may
463 /// otherwise be optimized out.
464 std::vector<llvm::WeakTrackingVH> LLVMUsed;
465 std::vector<llvm::WeakTrackingVH> LLVMCompilerUsed;
466
467 /// Store the list of global constructors and their respective priorities to
468 /// be emitted when the translation unit is complete.
469 CtorList GlobalCtors;
470
471 /// Store the list of global destructors and their respective priorities to be
472 /// emitted when the translation unit is complete.
473 CtorList GlobalDtors;
474
475 /// An ordered map of canonical GlobalDecls to their mangled names.
476 llvm::MapVector<GlobalDecl, StringRef> MangledDeclNames;
477 llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> Manglings;
478
479 /// Global annotations.
480 std::vector<llvm::Constant*> Annotations;
481
482 // Store deferred function annotations so they can be emitted at the end with
483 // most up to date ValueDecl that will have all the inherited annotations.
484 llvm::MapVector<StringRef, const ValueDecl *> DeferredAnnotations;
485
486 /// Map used to get unique annotation strings.
487 llvm::StringMap<llvm::Constant*> AnnotationStrings;
488
489 /// Used for uniquing of annotation arguments.
490 llvm::DenseMap<unsigned, llvm::Constant *> AnnotationArgs;
491
492 llvm::StringMap<llvm::GlobalVariable *> CFConstantStringMap;
493
494 llvm::DenseMap<llvm::Constant *, llvm::GlobalVariable *> ConstantStringMap;
495 llvm::DenseMap<const UnnamedGlobalConstantDecl *, llvm::GlobalVariable *>
496 UnnamedGlobalConstantDeclMap;
497 llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap;
498 llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap;
499 llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap;
500
501 llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap;
502 llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap;
503
504 /// Map used to get unique type descriptor constants for sanitizers.
505 llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap;
506
507 /// Map used to track internal linkage functions declared within
508 /// extern "C" regions.
509 typedef llvm::MapVector<IdentifierInfo *,
510 llvm::GlobalValue *> StaticExternCMap;
511 StaticExternCMap StaticExternCValues;
512
513 /// thread_local variables defined or used in this TU.
514 std::vector<const VarDecl *> CXXThreadLocals;
515
516 /// thread_local variables with initializers that need to run
517 /// before any thread_local variable in this TU is odr-used.
518 std::vector<llvm::Function *> CXXThreadLocalInits;
519 std::vector<const VarDecl *> CXXThreadLocalInitVars;
520
521 /// Global variables with initializers that need to run before main.
522 std::vector<llvm::Function *> CXXGlobalInits;
523
524 /// When a C++ decl with an initializer is deferred, null is
525 /// appended to CXXGlobalInits, and the index of that null is placed
526 /// here so that the initializer will be performed in the correct
527 /// order. Once the decl is emitted, the index is replaced with ~0U to ensure
528 /// that we don't re-emit the initializer.
529 llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition;
530
531 typedef std::pair<OrderGlobalInitsOrStermFinalizers, llvm::Function *>
532 GlobalInitData;
533
534 // When a tail call is performed on an "undefined" symbol, on PPC without pc
535 // relative feature, the tail call is not allowed. In "EmitCall" for such
536 // tail calls, the "undefined" symbols may be forward declarations, their
537 // definitions are provided in the module after the callsites. For such tail
538 // calls, diagnose message should not be emitted.
540 MustTailCallUndefinedGlobals;
541
542 struct GlobalInitPriorityCmp {
543 bool operator()(const GlobalInitData &LHS,
544 const GlobalInitData &RHS) const {
545 return LHS.first.priority < RHS.first.priority;
546 }
547 };
548
549 /// Global variables with initializers whose order of initialization is set by
550 /// init_priority attribute.
551 SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits;
552
553 /// Global destructor functions and arguments that need to run on termination.
554 /// When UseSinitAndSterm is set, it instead contains sterm finalizer
555 /// functions, which also run on unloading a shared library.
556 typedef std::tuple<llvm::FunctionType *, llvm::WeakTrackingVH,
557 llvm::Constant *>
558 CXXGlobalDtorsOrStermFinalizer_t;
559 SmallVector<CXXGlobalDtorsOrStermFinalizer_t, 8>
560 CXXGlobalDtorsOrStermFinalizers;
561
562 typedef std::pair<OrderGlobalInitsOrStermFinalizers, llvm::Function *>
563 StermFinalizerData;
564
565 struct StermFinalizerPriorityCmp {
566 bool operator()(const StermFinalizerData &LHS,
567 const StermFinalizerData &RHS) const {
568 return LHS.first.priority < RHS.first.priority;
569 }
570 };
571
572 /// Global variables with sterm finalizers whose order of initialization is
573 /// set by init_priority attribute.
574 SmallVector<StermFinalizerData, 8> PrioritizedCXXStermFinalizers;
575
576 /// The complete set of modules that has been imported.
577 llvm::SetVector<clang::Module *> ImportedModules;
578
579 /// The set of modules for which the module initializers
580 /// have been emitted.
581 llvm::SmallPtrSet<clang::Module *, 16> EmittedModuleInitializers;
582
583 /// A vector of metadata strings for linker options.
584 SmallVector<llvm::MDNode *, 16> LinkerOptionsMetadata;
585
586 /// A vector of metadata strings for dependent libraries for ELF.
587 SmallVector<llvm::MDNode *, 16> ELFDependentLibraries;
588
589 /// @name Cache for Objective-C runtime types
590 /// @{
591
592 /// Cached reference to the class for constant strings. This value has type
593 /// int * but is actually an Obj-C class pointer.
594 llvm::WeakTrackingVH CFConstantStringClassRef;
595
596 /// The type used to describe the state of a fast enumeration in
597 /// Objective-C's for..in loop.
598 QualType ObjCFastEnumerationStateType;
599
600 /// @}
601
602 /// Lazily create the Objective-C runtime
603 void createObjCRuntime();
604
605 void createOpenCLRuntime();
606 void createOpenMPRuntime();
607 void createCUDARuntime();
608 void createHLSLRuntime();
609
610 bool isTriviallyRecursive(const FunctionDecl *F);
611 bool shouldEmitFunction(GlobalDecl GD);
612 // Whether a global variable should be emitted by CUDA/HIP host/device
613 // related attributes.
614 bool shouldEmitCUDAGlobalVar(const VarDecl *VD) const;
615 bool shouldOpportunisticallyEmitVTables();
616 /// Map used to be sure we don't emit the same CompoundLiteral twice.
617 llvm::DenseMap<const CompoundLiteralExpr *, llvm::GlobalVariable *>
618 EmittedCompoundLiterals;
619
620 /// Map of the global blocks we've emitted, so that we don't have to re-emit
621 /// them if the constexpr evaluator gets aggressive.
622 llvm::DenseMap<const BlockExpr *, llvm::Constant *> EmittedGlobalBlocks;
623
624 /// @name Cache for Blocks Runtime Globals
625 /// @{
626
627 llvm::Constant *NSConcreteGlobalBlock = nullptr;
628 llvm::Constant *NSConcreteStackBlock = nullptr;
629
630 llvm::FunctionCallee BlockObjectAssign = nullptr;
631 llvm::FunctionCallee BlockObjectDispose = nullptr;
632
633 llvm::Type *BlockDescriptorType = nullptr;
634 llvm::Type *GenericBlockLiteralType = nullptr;
635
636 struct {
638 } Block;
639
640 GlobalDecl initializedGlobalDecl;
641
642 /// @}
643
644 /// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>)
645 llvm::Function *LifetimeStartFn = nullptr;
646
647 /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>)
648 llvm::Function *LifetimeEndFn = nullptr;
649
650 std::unique_ptr<SanitizerMetadata> SanitizerMD;
651
652 llvm::MapVector<const Decl *, bool> DeferredEmptyCoverageMappingDecls;
653
654 std::unique_ptr<CoverageMappingModuleGen> CoverageMapping;
655
656 /// Mapping from canonical types to their metadata identifiers. We need to
657 /// maintain this mapping because identifiers may be formed from distinct
658 /// MDNodes.
659 typedef llvm::DenseMap<QualType, llvm::Metadata *> MetadataTypeMap;
660 MetadataTypeMap MetadataIdMap;
661 MetadataTypeMap VirtualMetadataIdMap;
662 MetadataTypeMap GeneralizedMetadataIdMap;
663
664 // Helps squashing blocks of TopLevelStmtDecl into a single llvm::Function
665 // when used with -fincremental-extensions.
666 std::pair<std::unique_ptr<CodeGenFunction>, const TopLevelStmtDecl *>
667 GlobalTopLevelStmtBlockInFlight;
668
669 llvm::DenseMap<GlobalDecl, uint16_t> PtrAuthDiscriminatorHashes;
670
671 llvm::DenseMap<const CXXRecordDecl *, std::optional<PointerAuthQualifier>>
672 VTablePtrAuthInfos;
673 std::optional<PointerAuthQualifier>
674 computeVTPointerAuthentication(const CXXRecordDecl *ThisClass);
675
676public:
678 const HeaderSearchOptions &headersearchopts,
679 const PreprocessorOptions &ppopts,
680 const CodeGenOptions &CodeGenOpts, llvm::Module &M,
681 DiagnosticsEngine &Diags,
682 CoverageSourceInfo *CoverageInfo = nullptr);
683
685
686 void clear();
687
688 /// Finalize LLVM code generation.
689 void Release();
690
691 /// Return true if we should emit location information for expressions.
693
694 /// Return a reference to the configured Objective-C runtime.
696 if (!ObjCRuntime) createObjCRuntime();
697 return *ObjCRuntime;
698 }
699
700 /// Return true iff an Objective-C runtime has been configured.
701 bool hasObjCRuntime() { return !!ObjCRuntime; }
702
703 const std::string &getModuleNameHash() const { return ModuleNameHash; }
704
705 /// Return a reference to the configured OpenCL runtime.
707 assert(OpenCLRuntime != nullptr);
708 return *OpenCLRuntime;
709 }
710
711 /// Return a reference to the configured OpenMP runtime.
713 assert(OpenMPRuntime != nullptr);
714 return *OpenMPRuntime;
715 }
716
717 /// Return a reference to the configured CUDA runtime.
719 assert(CUDARuntime != nullptr);
720 return *CUDARuntime;
721 }
722
723 /// Return a reference to the configured HLSL runtime.
725 assert(HLSLRuntime != nullptr);
726 return *HLSLRuntime;
727 }
728
730 assert(ObjCData != nullptr);
731 return *ObjCData;
732 }
733
734 // Version checking functions, used to implement ObjC's @available:
735 // i32 @__isOSVersionAtLeast(i32, i32, i32)
736 llvm::FunctionCallee IsOSVersionAtLeastFn = nullptr;
737 // i32 @__isPlatformVersionAtLeast(i32, i32, i32, i32)
738 llvm::FunctionCallee IsPlatformVersionAtLeastFn = nullptr;
739
740 InstrProfStats &getPGOStats() { return PGOStats; }
741 llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); }
742
744 return CoverageMapping.get();
745 }
746
747 llvm::Constant *getStaticLocalDeclAddress(const VarDecl *D) {
748 return StaticLocalDeclMap[D];
749 }
751 llvm::Constant *C) {
752 StaticLocalDeclMap[D] = C;
753 }
754
755 llvm::Constant *
757 llvm::GlobalValue::LinkageTypes Linkage);
758
759 llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) {
760 return StaticLocalDeclGuardMap[D];
761 }
763 llvm::GlobalVariable *C) {
764 StaticLocalDeclGuardMap[D] = C;
765 }
766
767 Address createUnnamedGlobalFrom(const VarDecl &D, llvm::Constant *Constant,
768 CharUnits Align);
769
770 bool lookupRepresentativeDecl(StringRef MangledName,
771 GlobalDecl &Result) const;
772
774 return AtomicSetterHelperFnMap[Ty];
775 }
777 llvm::Constant *Fn) {
778 AtomicSetterHelperFnMap[Ty] = Fn;
779 }
780
782 return AtomicGetterHelperFnMap[Ty];
783 }
785 llvm::Constant *Fn) {
786 AtomicGetterHelperFnMap[Ty] = Fn;
787 }
788
789 llvm::Constant *getTypeDescriptorFromMap(QualType Ty) {
790 return TypeDescriptorMap[Ty];
791 }
792 void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C) {
793 TypeDescriptorMap[Ty] = C;
794 }
795
796 CGDebugInfo *getModuleDebugInfo() { return DebugInfo.get(); }
797
799 if (!NoObjCARCExceptionsMetadata)
800 NoObjCARCExceptionsMetadata = llvm::MDNode::get(getLLVMContext(), {});
801 return NoObjCARCExceptionsMetadata;
802 }
803
804 ASTContext &getContext() const { return Context; }
805 const LangOptions &getLangOpts() const { return LangOpts; }
807 return FS;
808 }
810 const { return HeaderSearchOpts; }
812 const { return PreprocessorOpts; }
813 const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
814 llvm::Module &getModule() const { return TheModule; }
815 DiagnosticsEngine &getDiags() const { return Diags; }
816 const llvm::DataLayout &getDataLayout() const {
817 return TheModule.getDataLayout();
818 }
819 const TargetInfo &getTarget() const { return Target; }
820 const llvm::Triple &getTriple() const { return Target.getTriple(); }
821 bool supportsCOMDAT() const;
822 void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO);
823
824 const ABIInfo &getABIInfo();
825 CGCXXABI &getCXXABI() const { return *ABI; }
826 llvm::LLVMContext &getLLVMContext() { return VMContext; }
827
828 bool shouldUseTBAA() const { return TBAA != nullptr; }
829
831
832 CodeGenTypes &getTypes() { return *Types; }
833
834 CodeGenVTables &getVTables() { return VTables; }
835
837 return VTables.getItaniumVTableContext();
838 }
839
841 return VTables.getItaniumVTableContext();
842 }
843
845 return VTables.getMicrosoftVTableContext();
846 }
847
848 CtorList &getGlobalCtors() { return GlobalCtors; }
849 CtorList &getGlobalDtors() { return GlobalDtors; }
850
851 /// getTBAATypeInfo - Get metadata used to describe accesses to objects of
852 /// the given type.
853 llvm::MDNode *getTBAATypeInfo(QualType QTy);
854
855 /// getTBAAAccessInfo - Get TBAA information that describes an access to
856 /// an object of the given type.
858
859 /// getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an
860 /// access to a virtual table pointer.
861 TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType);
862
863 llvm::MDNode *getTBAAStructInfo(QualType QTy);
864
865 /// getTBAABaseTypeInfo - Get metadata that describes the given base access
866 /// type. Return null if the type is not suitable for use in TBAA access tags.
867 llvm::MDNode *getTBAABaseTypeInfo(QualType QTy);
868
869 /// getTBAAAccessTagInfo - Get TBAA tag for a given memory access.
870 llvm::MDNode *getTBAAAccessTagInfo(TBAAAccessInfo Info);
871
872 /// mergeTBAAInfoForCast - Get merged TBAA information for the purposes of
873 /// type casts.
876
877 /// mergeTBAAInfoForConditionalOperator - Get merged TBAA information for the
878 /// purposes of conditional operator.
880 TBAAAccessInfo InfoB);
881
882 /// mergeTBAAInfoForMemoryTransfer - Get merged TBAA information for the
883 /// purposes of memory transfer calls.
885 TBAAAccessInfo SrcInfo);
886
887 /// getTBAAInfoForSubobject - Get TBAA information for an access with a given
888 /// base lvalue.
890 if (Base.getTBAAInfo().isMayAlias())
892 return getTBAAAccessInfo(AccessType);
893 }
894
897
898 /// DecorateInstructionWithTBAA - Decorate the instruction with a TBAA tag.
899 void DecorateInstructionWithTBAA(llvm::Instruction *Inst,
900 TBAAAccessInfo TBAAInfo);
901
902 /// Adds !invariant.barrier !tag to instruction
903 void DecorateInstructionWithInvariantGroup(llvm::Instruction *I,
904 const CXXRecordDecl *RD);
905
906 /// Emit the given number of characters as a value of type size_t.
907 llvm::ConstantInt *getSize(CharUnits numChars);
908
909 /// Set the visibility for the given LLVM GlobalValue.
910 void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
911
912 void setDSOLocal(llvm::GlobalValue *GV) const;
913
916 (D->getLinkageAndVisibility().getVisibility() ==
920 D->getLinkageAndVisibility().isVisibilityExplicit()));
921 }
922 void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const;
923 void setDLLImportDLLExport(llvm::GlobalValue *GV, const NamedDecl *D) const;
924 /// Set visibility, dllimport/dllexport and dso_local.
925 /// This must be called after dllimport/dllexport is set.
926 void setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const;
927 void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;
928
929 void setGVPropertiesAux(llvm::GlobalValue *GV, const NamedDecl *D) const;
930
931 /// Set the TLS mode for the given LLVM GlobalValue for the thread-local
932 /// variable declaration D.
933 void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const;
934
935 /// Get LLVM TLS mode from CodeGenOptions.
936 llvm::GlobalVariable::ThreadLocalMode GetDefaultLLVMTLSModel() const;
937
938 static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V) {
939 switch (V) {
940 case DefaultVisibility: return llvm::GlobalValue::DefaultVisibility;
941 case HiddenVisibility: return llvm::GlobalValue::HiddenVisibility;
942 case ProtectedVisibility: return llvm::GlobalValue::ProtectedVisibility;
943 }
944 llvm_unreachable("unknown visibility!");
945 }
946
947 llvm::Constant *GetAddrOfGlobal(GlobalDecl GD,
948 ForDefinition_t IsForDefinition
950
951 /// Will return a global variable of the given type. If a variable with a
952 /// different type already exists then a new variable with the right type
953 /// will be created and all uses of the old variable will be replaced with a
954 /// bitcast to the new variable.
955 llvm::GlobalVariable *
956 CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty,
957 llvm::GlobalValue::LinkageTypes Linkage,
958 llvm::Align Alignment);
959
960 llvm::Function *CreateGlobalInitOrCleanUpFunction(
961 llvm::FunctionType *ty, const Twine &name, const CGFunctionInfo &FI,
962 SourceLocation Loc = SourceLocation(), bool TLS = false,
963 llvm::GlobalVariable::LinkageTypes Linkage =
964 llvm::GlobalVariable::InternalLinkage);
965
966 /// Return the AST address space of the underlying global variable for D, as
967 /// determined by its declaration. Normally this is the same as the address
968 /// space of D's type, but in CUDA, address spaces are associated with
969 /// declarations, not types. If D is nullptr, return the default address
970 /// space for global variable.
971 ///
972 /// For languages without explicit address spaces, if D has default address
973 /// space, target-specific global or constant address space may be returned.
975
976 /// Return the AST address space of constant literal, which is used to emit
977 /// the constant literal as global variable in LLVM IR.
978 /// Note: This is not necessarily the address space of the constant literal
979 /// in AST. For address space agnostic language, e.g. C++, constant literal
980 /// in AST is always in default address space.
982
983 /// Return the llvm::Constant for the address of the given global variable.
984 /// If Ty is non-null and if the global doesn't exist, then it will be created
985 /// with the specified type instead of whatever the normal requested type
986 /// would be. If IsForDefinition is true, it is guaranteed that an actual
987 /// global with type Ty will be returned, not conversion of a variable with
988 /// the same mangled name but some other type.
989 llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,
990 llvm::Type *Ty = nullptr,
991 ForDefinition_t IsForDefinition
993
994 /// Return the address of the given function. If Ty is non-null, then this
995 /// function will use the specified type if it has to create it.
996 llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = nullptr,
997 bool ForVTable = false,
998 bool DontDefer = false,
999 ForDefinition_t IsForDefinition
1001
1002 // Return the function body address of the given function.
1003 llvm::Constant *GetFunctionStart(const ValueDecl *Decl);
1004
1005 /// Return a function pointer for a reference to the given function.
1006 /// This correctly handles weak references, but does not apply a
1007 /// pointer signature.
1008 llvm::Constant *getRawFunctionPointer(GlobalDecl GD,
1009 llvm::Type *Ty = nullptr);
1010
1011 /// Return the ABI-correct function pointer value for a reference
1012 /// to the given function. This will apply a pointer signature if
1013 /// necessary, caching the result for the given function.
1014 llvm::Constant *getFunctionPointer(GlobalDecl GD, llvm::Type *Ty = nullptr);
1015
1016 /// Return the ABI-correct function pointer value for a reference
1017 /// to the given function. This will apply a pointer signature if
1018 /// necessary.
1019 llvm::Constant *getFunctionPointer(llvm::Constant *Pointer,
1021
1022 llvm::Constant *getMemberFunctionPointer(const FunctionDecl *FD,
1023 llvm::Type *Ty = nullptr);
1024
1025 llvm::Constant *getMemberFunctionPointer(llvm::Constant *Pointer,
1026 QualType FT);
1027
1029
1031
1033
1035
1036 bool shouldSignPointer(const PointerAuthSchema &Schema);
1037 llvm::Constant *getConstantSignedPointer(llvm::Constant *Pointer,
1038 const PointerAuthSchema &Schema,
1039 llvm::Constant *StorageAddress,
1040 GlobalDecl SchemaDecl,
1041 QualType SchemaType);
1042
1043 llvm::Constant *
1044 getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key,
1045 llvm::Constant *StorageAddress,
1046 llvm::ConstantInt *OtherDiscriminator);
1047
1048 llvm::ConstantInt *
1050 GlobalDecl SchemaDecl, QualType SchemaType);
1051
1053 std::optional<CGPointerAuthInfo>
1055 const CXXRecordDecl *Record,
1056 llvm::Value *StorageAddress);
1057
1058 std::optional<PointerAuthQualifier>
1060
1062
1063 // Return whether RTTI information should be emitted for this target.
1064 bool shouldEmitRTTI(bool ForEH = false) {
1065 return (ForEH || getLangOpts().RTTI) && !getLangOpts().CUDAIsDevice &&
1066 !(getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice &&
1067 (getTriple().isNVPTX() || getTriple().isAMDGPU()));
1068 }
1069
1070 /// Get the address of the RTTI descriptor for the given type.
1071 llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
1072
1073 /// Get the address of a GUID.
1075
1076 /// Get the address of a UnnamedGlobalConstant
1079
1080 /// Get the address of a template parameter object.
1083
1084 /// Get the address of the thunk for the given global decl.
1085 llvm::Constant *GetAddrOfThunk(StringRef Name, llvm::Type *FnTy,
1086 GlobalDecl GD);
1087
1088 /// Get a reference to the target of VD.
1090
1091 /// Returns the assumed alignment of an opaque pointer to the given class.
1093
1094 /// Returns the minimum object size for an object of the given class type
1095 /// (or a class derived from it).
1097
1098 /// Returns the minimum object size for an object of the given type.
1100 if (CXXRecordDecl *RD = Ty->getAsCXXRecordDecl())
1101 return getMinimumClassObjectSize(RD);
1102 return getContext().getTypeSizeInChars(Ty);
1103 }
1104
1105 /// Returns the assumed alignment of a virtual base of a class.
1107 const CXXRecordDecl *Derived,
1108 const CXXRecordDecl *VBase);
1109
1110 /// Given a class pointer with an actual known alignment, and the
1111 /// expected alignment of an object at a dynamic offset w.r.t that
1112 /// pointer, return the alignment to assume at the offset.
1114 const CXXRecordDecl *Class,
1115 CharUnits ExpectedTargetAlign);
1116
1117 CharUnits
1121
1122 /// Returns the offset from a derived class to a class. Returns null if the
1123 /// offset is 0.
1124 llvm::Constant *
1128
1129 llvm::FoldingSet<BlockByrefHelpers> ByrefHelpersCache;
1130
1131 /// Fetches the global unique block count.
1132 int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; }
1133
1134 /// Fetches the type of a generic block descriptor.
1135 llvm::Type *getBlockDescriptorType();
1136
1137 /// The type of a generic block literal.
1138 llvm::Type *getGenericBlockLiteralType();
1139
1140 /// Gets the address of a block which requires no captures.
1141 llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name);
1142
1143 /// Returns the address of a block which requires no caputres, or null if
1144 /// we've yet to emit the block for BE.
1145 llvm::Constant *getAddrOfGlobalBlockIfEmitted(const BlockExpr *BE) {
1146 return EmittedGlobalBlocks.lookup(BE);
1147 }
1148
1149 /// Notes that BE's global block is available via Addr. Asserts that BE
1150 /// isn't already emitted.
1151 void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr);
1152
1153 /// Return a pointer to a constant CFString object for the given string.
1155
1156 /// Return a constant array for the given string.
1157 llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E);
1158
1159 /// Return a pointer to a constant array for the given string literal.
1162 StringRef Name = ".str");
1163
1164 /// Return a pointer to a constant array for the given ObjCEncodeExpr node.
1167
1168 /// Returns a pointer to a character array containing the literal and a
1169 /// terminating '\0' character. The result has pointer to array type.
1170 ///
1171 /// \param GlobalName If provided, the name to use for the global (if one is
1172 /// created).
1174 GetAddrOfConstantCString(const std::string &Str,
1175 const char *GlobalName = nullptr);
1176
1177 /// Returns a pointer to a constant global variable for the given file-scope
1178 /// compound literal expression.
1180
1181 /// If it's been emitted already, returns the GlobalVariable corresponding to
1182 /// a compound literal. Otherwise, returns null.
1183 llvm::GlobalVariable *
1185
1186 /// Notes that CLE's GlobalVariable is GV. Asserts that CLE isn't already
1187 /// emitted.
1189 llvm::GlobalVariable *GV);
1190
1191 /// Returns a pointer to a global variable representing a temporary
1192 /// with static or thread storage duration.
1194 const Expr *Inner);
1195
1196 /// Retrieve the record type that describes the state of an
1197 /// Objective-C fast enumeration loop (for..in).
1199
1200 // Produce code for this constructor/destructor. This method doesn't try
1201 // to apply any ABI rules about which other constructors/destructors
1202 // are needed or if they are alias to each other.
1203 llvm::Function *codegenCXXStructor(GlobalDecl GD);
1204
1205 /// Return the address of the constructor/destructor of the given type.
1206 llvm::Constant *
1208 llvm::FunctionType *FnType = nullptr,
1209 bool DontDefer = false,
1210 ForDefinition_t IsForDefinition = NotForDefinition) {
1211 return cast<llvm::Constant>(getAddrAndTypeOfCXXStructor(GD, FnInfo, FnType,
1212 DontDefer,
1213 IsForDefinition)
1214 .getCallee());
1215 }
1216
1217 llvm::FunctionCallee getAddrAndTypeOfCXXStructor(
1218 GlobalDecl GD, const CGFunctionInfo *FnInfo = nullptr,
1219 llvm::FunctionType *FnType = nullptr, bool DontDefer = false,
1220 ForDefinition_t IsForDefinition = NotForDefinition);
1221
1222 /// Given a builtin id for a function like "__builtin_fabsf", return a
1223 /// Function* for "fabsf".
1224 llvm::Constant *getBuiltinLibFunction(const FunctionDecl *FD,
1225 unsigned BuiltinID);
1226
1227 llvm::Function *getIntrinsic(unsigned IID, ArrayRef<llvm::Type *> Tys = {});
1228
1229 void AddCXXGlobalInit(llvm::Function *F) { CXXGlobalInits.push_back(F); }
1230
1231 /// Emit code for a single top level declaration.
1232 void EmitTopLevelDecl(Decl *D);
1233
1234 /// Stored a deferred empty coverage mapping for an unused
1235 /// and thus uninstrumented top level declaration.
1237
1238 /// Remove the deferred empty coverage mapping as this
1239 /// declaration is actually instrumented.
1240 void ClearUnusedCoverageMapping(const Decl *D);
1241
1242 /// Emit all the deferred coverage mappings
1243 /// for the uninstrumented functions.
1245
1246 /// Emit an alias for "main" if it has no arguments (needed for wasm).
1247 void EmitMainVoidAlias();
1248
1249 /// Tell the consumer that this variable has been instantiated.
1251
1252 /// If the declaration has internal linkage but is inside an
1253 /// extern "C" linkage specification, prepare to emit an alias for it
1254 /// to the expected name.
1255 template<typename SomeDecl>
1256 void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV);
1257
1258 /// Add a global to a list to be added to the llvm.used metadata.
1259 void addUsedGlobal(llvm::GlobalValue *GV);
1260
1261 /// Add a global to a list to be added to the llvm.compiler.used metadata.
1262 void addCompilerUsedGlobal(llvm::GlobalValue *GV);
1263
1264 /// Add a global to a list to be added to the llvm.compiler.used metadata.
1265 void addUsedOrCompilerUsedGlobal(llvm::GlobalValue *GV);
1266
1267 /// Add a destructor and object to add to the C++ global destructor function.
1268 void AddCXXDtorEntry(llvm::FunctionCallee DtorFn, llvm::Constant *Object) {
1269 CXXGlobalDtorsOrStermFinalizers.emplace_back(DtorFn.getFunctionType(),
1270 DtorFn.getCallee(), Object);
1271 }
1272
1273 /// Add an sterm finalizer to the C++ global cleanup function.
1274 void AddCXXStermFinalizerEntry(llvm::FunctionCallee DtorFn) {
1275 CXXGlobalDtorsOrStermFinalizers.emplace_back(DtorFn.getFunctionType(),
1276 DtorFn.getCallee(), nullptr);
1277 }
1278
1279 /// Add an sterm finalizer to its own llvm.global_dtors entry.
1280 void AddCXXStermFinalizerToGlobalDtor(llvm::Function *StermFinalizer,
1281 int Priority) {
1282 AddGlobalDtor(StermFinalizer, Priority);
1283 }
1284
1285 void AddCXXPrioritizedStermFinalizerEntry(llvm::Function *StermFinalizer,
1286 int Priority) {
1288 PrioritizedCXXStermFinalizers.size());
1289 PrioritizedCXXStermFinalizers.push_back(
1290 std::make_pair(Key, StermFinalizer));
1291 }
1292
1293 /// Create or return a runtime function declaration with the specified type
1294 /// and name. If \p AssumeConvergent is true, the call will have the
1295 /// convergent attribute added.
1296 ///
1297 /// For new code, please use the overload that takes a QualType; it sets
1298 /// function attributes more accurately.
1299 llvm::FunctionCallee
1300 CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name,
1301 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1302 bool Local = false, bool AssumeConvergent = false);
1303
1304 /// Create or return a runtime function declaration with the specified type
1305 /// and name. If \p AssumeConvergent is true, the call will have the
1306 /// convergent attribute added.
1307 llvm::FunctionCallee
1309 StringRef Name,
1310 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1311 bool Local = false, bool AssumeConvergent = false);
1312
1313 /// Create a new runtime global variable with the specified type and name.
1314 llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty,
1315 StringRef Name);
1316
1317 ///@name Custom Blocks Runtime Interfaces
1318 ///@{
1319
1320 llvm::Constant *getNSConcreteGlobalBlock();
1321 llvm::Constant *getNSConcreteStackBlock();
1322 llvm::FunctionCallee getBlockObjectAssign();
1323 llvm::FunctionCallee getBlockObjectDispose();
1324
1325 ///@}
1326
1327 llvm::Function *getLLVMLifetimeStartFn();
1328 llvm::Function *getLLVMLifetimeEndFn();
1329
1330 // Make sure that this type is translated.
1331 void UpdateCompletedType(const TagDecl *TD);
1332
1333 llvm::Constant *getMemberPointerConstant(const UnaryOperator *e);
1334
1335 /// Emit type info if type of an expression is a variably modified
1336 /// type. Also emit proper debug info for cast types.
1338 CodeGenFunction *CGF = nullptr);
1339
1340 /// Return the result of value-initializing the given type, i.e. a null
1341 /// expression of the given type. This is usually, but not always, an LLVM
1342 /// null constant.
1343 llvm::Constant *EmitNullConstant(QualType T);
1344
1345 /// Return a null constant appropriate for zero-initializing a base class with
1346 /// the given type. This is usually, but not always, an LLVM null constant.
1347 llvm::Constant *EmitNullConstantForBase(const CXXRecordDecl *Record);
1348
1349 /// Emit a general error that something can't be done.
1350 void Error(SourceLocation loc, StringRef error);
1351
1352 /// Print out an error that codegen doesn't support the specified stmt yet.
1353 void ErrorUnsupported(const Stmt *S, const char *Type);
1354
1355 /// Print out an error that codegen doesn't support the specified decl yet.
1356 void ErrorUnsupported(const Decl *D, const char *Type);
1357
1358 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
1359 /// guaranteed). Produces a warning if we're low on stack space and allocates
1360 /// more in that case. Use this in code that may recurse deeply to avoid stack
1361 /// overflow.
1363 llvm::function_ref<void()> Fn);
1364
1365 /// Set the attributes on the LLVM function for the given decl and function
1366 /// info. This applies attributes necessary for handling the ABI as well as
1367 /// user specified attributes like section.
1368 void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F,
1369 const CGFunctionInfo &FI);
1370
1371 /// Set the LLVM function attributes (sext, zext, etc).
1373 llvm::Function *F, bool IsThunk);
1374
1375 /// Set the LLVM function attributes which only apply to a function
1376 /// definition.
1377 void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F);
1378
1379 /// Set the LLVM function attributes that represent floating point
1380 /// environment.
1381 void setLLVMFunctionFEnvAttributes(const FunctionDecl *D, llvm::Function *F);
1382
1383 /// Return true iff the given type uses 'sret' when used as a return type.
1384 bool ReturnTypeUsesSRet(const CGFunctionInfo &FI);
1385
1386 /// Return true iff the given type has `inreg` set.
1387 bool ReturnTypeHasInReg(const CGFunctionInfo &FI);
1388
1389 /// Return true iff the given type uses an argument slot when 'sret' is used
1390 /// as a return type.
1392
1393 /// Return true iff the given type uses 'fpret' when used as a return type.
1394 bool ReturnTypeUsesFPRet(QualType ResultType);
1395
1396 /// Return true iff the given type uses 'fp2ret' when used as a return type.
1397 bool ReturnTypeUsesFP2Ret(QualType ResultType);
1398
1399 /// Get the LLVM attributes and calling convention to use for a particular
1400 /// function type.
1401 ///
1402 /// \param Name - The function name.
1403 /// \param Info - The function type information.
1404 /// \param CalleeInfo - The callee information these attributes are being
1405 /// constructed for. If valid, the attributes applied to this decl may
1406 /// contribute to the function attributes and calling convention.
1407 /// \param Attrs [out] - On return, the attribute list to use.
1408 /// \param CallingConv [out] - On return, the LLVM calling convention to use.
1409 void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info,
1410 CGCalleeInfo CalleeInfo,
1411 llvm::AttributeList &Attrs, unsigned &CallingConv,
1412 bool AttrOnCallSite, bool IsThunk);
1413
1414 /// Adjust Memory attribute to ensure that the BE gets the right attribute
1415 // in order to generate the library call or the intrinsic for the function
1416 // name 'Name'.
1417 void AdjustMemoryAttribute(StringRef Name, CGCalleeInfo CalleeInfo,
1418 llvm::AttributeList &Attrs);
1419
1420 /// Like the overload taking a `Function &`, but intended specifically
1421 /// for frontends that want to build on Clang's target-configuration logic.
1422 void addDefaultFunctionDefinitionAttributes(llvm::AttrBuilder &attrs);
1423
1424 StringRef getMangledName(GlobalDecl GD);
1425 StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD);
1426 const GlobalDecl getMangledNameDecl(StringRef);
1427
1428 void EmitTentativeDefinition(const VarDecl *D);
1429
1431
1433
1435
1436 /// Appends Opts to the "llvm.linker.options" metadata value.
1437 void AppendLinkerOptions(StringRef Opts);
1438
1439 /// Appends a detect mismatch command to the linker options.
1440 void AddDetectMismatch(StringRef Name, StringRef Value);
1441
1442 /// Appends a dependent lib to the appropriate metadata value.
1443 void AddDependentLib(StringRef Lib);
1444
1445
1446 llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD);
1447
1448 void setFunctionLinkage(GlobalDecl GD, llvm::Function *F) {
1449 F->setLinkage(getFunctionLinkage(GD));
1450 }
1451
1452 /// Return the appropriate linkage for the vtable, VTT, and type information
1453 /// of the given class.
1454 llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD);
1455
1456 /// Return the store size, in character units, of the given LLVM type.
1457 CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const;
1458
1459 /// Returns LLVM linkage for a declarator.
1460 llvm::GlobalValue::LinkageTypes
1462
1463 /// Returns LLVM linkage for a declarator.
1464 llvm::GlobalValue::LinkageTypes
1466
1467 /// Emit all the global annotations.
1468 void EmitGlobalAnnotations();
1469
1470 /// Emit an annotation string.
1471 llvm::Constant *EmitAnnotationString(StringRef Str);
1472
1473 /// Emit the annotation's translation unit.
1474 llvm::Constant *EmitAnnotationUnit(SourceLocation Loc);
1475
1476 /// Emit the annotation line number.
1477 llvm::Constant *EmitAnnotationLineNo(SourceLocation L);
1478
1479 /// Emit additional args of the annotation.
1480 llvm::Constant *EmitAnnotationArgs(const AnnotateAttr *Attr);
1481
1482 /// Generate the llvm::ConstantStruct which contains the annotation
1483 /// information for a given GlobalValue. The annotation struct is
1484 /// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the
1485 /// GlobalValue being annotated. The second field is the constant string
1486 /// created from the AnnotateAttr's annotation. The third field is a constant
1487 /// string containing the name of the translation unit. The fourth field is
1488 /// the line number in the file of the annotated value declaration.
1489 llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV,
1490 const AnnotateAttr *AA,
1491 SourceLocation L);
1492
1493 /// Add global annotations that are set on D, for the global GV. Those
1494 /// annotations are emitted during finalization of the LLVM code.
1495 void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV);
1496
1497 bool isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn,
1498 SourceLocation Loc) const;
1499
1500 bool isInNoSanitizeList(SanitizerMask Kind, llvm::GlobalVariable *GV,
1502 StringRef Category = StringRef()) const;
1503
1504 /// Imbue XRay attributes to a function, applying the always/never attribute
1505 /// lists in the process. Returns true if we did imbue attributes this way,
1506 /// false otherwise.
1507 bool imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc,
1508 StringRef Category = StringRef()) const;
1509
1510 /// \returns true if \p Fn at \p Loc should be excluded from profile
1511 /// instrumentation by the SCL passed by \p -fprofile-list.
1513 isFunctionBlockedByProfileList(llvm::Function *Fn, SourceLocation Loc) const;
1514
1515 /// \returns true if \p Fn at \p Loc should be excluded from profile
1516 /// instrumentation.
1518 isFunctionBlockedFromProfileInstr(llvm::Function *Fn,
1519 SourceLocation Loc) const;
1520
1522 return SanitizerMD.get();
1523 }
1524
1526 DeferredVTables.push_back(RD);
1527 }
1528
1529 /// Emit code for a single global function or var decl. Forward declarations
1530 /// are emitted lazily.
1531 void EmitGlobal(GlobalDecl D);
1532
1534
1535 llvm::GlobalValue *GetGlobalValue(StringRef Ref);
1536
1537 /// Set attributes which are common to any form of a global definition (alias,
1538 /// Objective-C method, function, global variable).
1539 ///
1540 /// NOTE: This should only be called for definitions.
1541 void SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV);
1542
1543 void addReplacement(StringRef Name, llvm::Constant *C);
1544
1545 void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C);
1546
1547 /// Emit a code for threadprivate directive.
1548 /// \param D Threadprivate declaration.
1550
1551 /// Emit a code for declare reduction construct.
1553 CodeGenFunction *CGF = nullptr);
1554
1555 /// Emit a code for declare mapper construct.
1557 CodeGenFunction *CGF = nullptr);
1558
1559 /// Emit a code for requires directive.
1560 /// \param D Requires declaration
1562
1563 /// Emit a code for the allocate directive.
1564 /// \param D The allocate declaration
1566
1567 /// Return the alignment specified in an allocate directive, if present.
1568 std::optional<CharUnits> getOMPAllocateAlignment(const VarDecl *VD);
1569
1570 /// Returns whether the given record has hidden LTO visibility and therefore
1571 /// may participate in (single-module) CFI and whole-program vtable
1572 /// optimization.
1573 bool HasHiddenLTOVisibility(const CXXRecordDecl *RD);
1574
1575 /// Returns whether the given record has public LTO visibility (regardless of
1576 /// -lto-whole-program-visibility) and therefore may not participate in
1577 /// (single-module) CFI and whole-program vtable optimization.
1579
1580 /// Returns the vcall visibility of the given type. This is the scope in which
1581 /// a virtual function call could be made which ends up being dispatched to a
1582 /// member function of this class. This scope can be wider than the visibility
1583 /// of the class itself when the class has a more-visible dynamic base class.
1584 /// The client should pass in an empty Visited set, which is used to prevent
1585 /// redundant recursive processing.
1586 llvm::GlobalObject::VCallVisibility
1588 llvm::DenseSet<const CXXRecordDecl *> &Visited);
1589
1590 /// Emit type metadata for the given vtable using the given layout.
1592 llvm::GlobalVariable *VTable,
1593 const VTableLayout &VTLayout);
1594
1595 llvm::Type *getVTableComponentType() const;
1596
1597 /// Generate a cross-DSO type identifier for MD.
1598 llvm::ConstantInt *CreateCrossDsoCfiTypeId(llvm::Metadata *MD);
1599
1600 /// Generate a KCFI type identifier for T.
1601 llvm::ConstantInt *CreateKCFITypeId(QualType T);
1602
1603 /// Create a metadata identifier for the given type. This may either be an
1604 /// MDString (for external identifiers) or a distinct unnamed MDNode (for
1605 /// internal identifiers).
1607
1608 /// Create a metadata identifier that is intended to be used to check virtual
1609 /// calls via a member function pointer.
1611
1612 /// Create a metadata identifier for the generalization of the given type.
1613 /// This may either be an MDString (for external identifiers) or a distinct
1614 /// unnamed MDNode (for internal identifiers).
1616
1617 /// Create and attach type metadata to the given function.
1619 llvm::Function *F);
1620
1621 /// Set type metadata to the given function.
1622 void setKCFIType(const FunctionDecl *FD, llvm::Function *F);
1623
1624 /// Emit KCFI type identifier constants and remove unused identifiers.
1625 void finalizeKCFITypes();
1626
1627 /// Whether this function's return type has no side effects, and thus may
1628 /// be trivially discarded if it is unused.
1629 bool MayDropFunctionReturn(const ASTContext &Context,
1630 QualType ReturnType) const;
1631
1632 /// Returns whether this module needs the "all-vtables" type identifier.
1633 bool NeedAllVtablesTypeId() const;
1634
1635 /// Create and attach type metadata for the given vtable.
1636 void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset,
1637 const CXXRecordDecl *RD);
1638
1639 /// Return a vector of most-base classes for RD. This is used to implement
1640 /// control flow integrity checks for member function pointers.
1641 ///
1642 /// A most-base class of a class C is defined as a recursive base class of C,
1643 /// including C itself, that does not have any bases.
1646
1647 /// Get the declaration of std::terminate for the platform.
1648 llvm::FunctionCallee getTerminateFn();
1649
1650 llvm::SanitizerStatReport &getSanStats();
1651
1652 llvm::Value *
1654
1655 /// OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument
1656 /// information in the program executable. The argument information stored
1657 /// includes the argument name, its type, the address and access qualifiers
1658 /// used. This helper can be used to generate metadata for source code kernel
1659 /// function as well as generated implicitly kernels. If a kernel is generated
1660 /// implicitly null value has to be passed to the last two parameters,
1661 /// otherwise all parameters must have valid non-null values.
1662 /// \param FN is a pointer to IR function being generated.
1663 /// \param FD is a pointer to function declaration if any.
1664 /// \param CGF is a pointer to CodeGenFunction that generates this function.
1665 void GenKernelArgMetadata(llvm::Function *FN,
1666 const FunctionDecl *FD = nullptr,
1667 CodeGenFunction *CGF = nullptr);
1668
1669 /// Get target specific null pointer.
1670 /// \param T is the LLVM type of the null pointer.
1671 /// \param QT is the clang QualType of the null pointer.
1672 llvm::Constant *getNullPointer(llvm::PointerType *T, QualType QT);
1673
1675 LValueBaseInfo *BaseInfo = nullptr,
1676 TBAAAccessInfo *TBAAInfo = nullptr,
1677 bool forPointeeType = false);
1679 LValueBaseInfo *BaseInfo = nullptr,
1680 TBAAAccessInfo *TBAAInfo = nullptr);
1681 bool stopAutoInit();
1682
1683 /// Print the postfix for externalized static variable or kernels for single
1684 /// source offloading languages CUDA and HIP. The unique postfix is created
1685 /// using either the CUID argument, or the file's UniqueID and active macros.
1686 /// The fallback method without a CUID requires that the offloading toolchain
1687 /// does not define separate macros via the -cc1 options.
1688 void printPostfixForExternalizedDecl(llvm::raw_ostream &OS,
1689 const Decl *D) const;
1690
1691 /// Move some lazily-emitted states to the NewBuilder. This is especially
1692 /// essential for the incremental parsing environment like Clang Interpreter,
1693 /// because we'll lose all important information after each repl.
1694 void moveLazyEmissionStates(CodeGenModule *NewBuilder);
1695
1696 /// Emit the IR encoding to attach the CUDA launch bounds attribute to \p F.
1697 /// If \p MaxThreadsVal is not nullptr, the max threads value is stored in it,
1698 /// if a valid one was found.
1699 void handleCUDALaunchBoundsAttr(llvm::Function *F,
1700 const CUDALaunchBoundsAttr *A,
1701 int32_t *MaxThreadsVal = nullptr,
1702 int32_t *MinBlocksVal = nullptr,
1703 int32_t *MaxClusterRankVal = nullptr);
1704
1705 /// Emit the IR encoding to attach the AMD GPU flat-work-group-size attribute
1706 /// to \p F. Alternatively, the work group size can be taken from a \p
1707 /// ReqdWGS. If \p MinThreadsVal is not nullptr, the min threads value is
1708 /// stored in it, if a valid one was found. If \p MaxThreadsVal is not
1709 /// nullptr, the max threads value is stored in it, if a valid one was found.
1711 llvm::Function *F, const AMDGPUFlatWorkGroupSizeAttr *A,
1712 const ReqdWorkGroupSizeAttr *ReqdWGS = nullptr,
1713 int32_t *MinThreadsVal = nullptr, int32_t *MaxThreadsVal = nullptr);
1714
1715 /// Emit the IR encoding to attach the AMD GPU waves-per-eu attribute to \p F.
1716 void handleAMDGPUWavesPerEUAttr(llvm::Function *F,
1717 const AMDGPUWavesPerEUAttr *A);
1718
1719 llvm::Constant *
1720 GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty, LangAS AddrSpace,
1721 const VarDecl *D,
1722 ForDefinition_t IsForDefinition = NotForDefinition);
1723
1724 // FIXME: Hardcoding priority here is gross.
1725 void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535,
1726 unsigned LexOrder = ~0U,
1727 llvm::Constant *AssociatedData = nullptr);
1728 void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535,
1729 bool IsDtorAttrFunc = false);
1730
1731 // Return whether structured convergence intrinsics should be generated for
1732 // this target.
1734 // TODO: this should probably become unconditional once the controlled
1735 // convergence becomes the norm.
1736 return getTriple().isSPIRVLogical();
1737 }
1738
1740 std::pair<const FunctionDecl *, SourceLocation> Global) {
1741 MustTailCallUndefinedGlobals.insert(Global);
1742 }
1743
1745 // In C23 (N3096) $6.7.10:
1746 // """
1747 // If any object is initialized with an empty iniitializer, then it is
1748 // subject to default initialization:
1749 // - if it is an aggregate, every member is initialized (recursively)
1750 // according to these rules, and any padding is initialized to zero bits;
1751 // - if it is a union, the first named member is initialized (recursively)
1752 // according to these rules, and any padding is initialized to zero bits.
1753 //
1754 // If the aggregate or union contains elements or members that are
1755 // aggregates or unions, these rules apply recursively to the subaggregates
1756 // or contained unions.
1757 //
1758 // If there are fewer initializers in a brace-enclosed list than there are
1759 // elements or members of an aggregate, or fewer characters in a string
1760 // literal used to initialize an array of known size than there are elements
1761 // in the array, the remainder of the aggregate is subject to default
1762 // initialization.
1763 // """
1764 //
1765 // From my understanding, the standard is ambiguous in the following two
1766 // areas:
1767 // 1. For a union type with empty initializer, if the first named member is
1768 // not the largest member, then the bytes comes after the first named member
1769 // but before padding are left unspecified. An example is:
1770 // union U { int a; long long b;};
1771 // union U u = {}; // The first 4 bytes are 0, but 4-8 bytes are left
1772 // unspecified.
1773 //
1774 // 2. It only mentions padding for empty initializer, but doesn't mention
1775 // padding for a non empty initialization list. And if the aggregation or
1776 // union contains elements or members that are aggregates or unions, and
1777 // some are non empty initializers, while others are empty initiailizers,
1778 // the padding initialization is unclear. An example is:
1779 // struct S1 { int a; long long b; };
1780 // struct S2 { char c; struct S1 s1; };
1781 // // The values for paddings between s2.c and s2.s1.a, between s2.s1.a
1782 // and s2.s1.b are unclear.
1783 // struct S2 s2 = { 'c' };
1784 //
1785 // Here we choose to zero initiailize left bytes of a union type. Because
1786 // projects like the Linux kernel are relying on this behavior. If we don't
1787 // explicitly zero initialize them, the undef values can be optimized to
1788 // return gabage data. We also choose to zero initialize paddings for
1789 // aggregates and unions, no matter they are initialized by empty
1790 // initializers or non empty initializers. This can provide a consistent
1791 // behavior. So projects like the Linux kernel can rely on it.
1792 return !getLangOpts().CPlusPlus;
1793 }
1794
1795private:
1796 bool shouldDropDLLAttribute(const Decl *D, const llvm::GlobalValue *GV) const;
1797
1798 llvm::Constant *GetOrCreateLLVMFunction(
1799 StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,
1800 bool DontDefer = false, bool IsThunk = false,
1801 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1802 ForDefinition_t IsForDefinition = NotForDefinition);
1803
1804 // Adds a declaration to the list of multi version functions if not present.
1805 void AddDeferredMultiVersionResolverToEmit(GlobalDecl GD);
1806
1807 // References to multiversion functions are resolved through an implicitly
1808 // defined resolver function. This function is responsible for creating
1809 // the resolver symbol for the provided declaration. The value returned
1810 // will be for an ifunc (llvm::GlobalIFunc) if the current target supports
1811 // that feature and for a regular function (llvm::GlobalValue) otherwise.
1812 llvm::Constant *GetOrCreateMultiVersionResolver(GlobalDecl GD);
1813
1814 // In scenarios where a function is not known to be a multiversion function
1815 // until a later declaration, it is sometimes necessary to change the
1816 // previously created mangled name to align with requirements of whatever
1817 // multiversion function kind the function is now known to be. This function
1818 // is responsible for performing such mangled name updates.
1819 void UpdateMultiVersionNames(GlobalDecl GD, const FunctionDecl *FD,
1820 StringRef &CurName);
1821
1822 bool GetCPUAndFeaturesAttributes(GlobalDecl GD,
1823 llvm::AttrBuilder &AttrBuilder,
1824 bool SetTargetFeatures = true);
1825 void setNonAliasAttributes(GlobalDecl GD, llvm::GlobalObject *GO);
1826
1827 /// Set function attributes for a function declaration.
1828 void SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
1829 bool IsIncompleteFunction, bool IsThunk);
1830
1831 void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = nullptr);
1832
1833 void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
1834 void EmitMultiVersionFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
1835
1836 void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false);
1837 void EmitExternalVarDeclaration(const VarDecl *D);
1838 void EmitExternalFunctionDeclaration(const FunctionDecl *D);
1839 void EmitAliasDefinition(GlobalDecl GD);
1840 void emitIFuncDefinition(GlobalDecl GD);
1841 void emitCPUDispatchDefinition(GlobalDecl GD);
1842 void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
1843 void EmitObjCIvarInitializations(ObjCImplementationDecl *D);
1844
1845 // C++ related functions.
1846
1847 void EmitDeclContext(const DeclContext *DC);
1848 void EmitLinkageSpec(const LinkageSpecDecl *D);
1849 void EmitTopLevelStmt(const TopLevelStmtDecl *D);
1850
1851 /// Emit the function that initializes C++ thread_local variables.
1852 void EmitCXXThreadLocalInitFunc();
1853
1854 /// Emit the function that initializes global variables for a C++ Module.
1855 void EmitCXXModuleInitFunc(clang::Module *Primary);
1856
1857 /// Emit the function that initializes C++ globals.
1858 void EmitCXXGlobalInitFunc();
1859
1860 /// Emit the function that performs cleanup associated with C++ globals.
1861 void EmitCXXGlobalCleanUpFunc();
1862
1863 /// Emit the function that initializes the specified global (if PerformInit is
1864 /// true) and registers its destructor.
1865 void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
1866 llvm::GlobalVariable *Addr,
1867 bool PerformInit);
1868
1869 void EmitPointerToInitFunc(const VarDecl *VD, llvm::GlobalVariable *Addr,
1870 llvm::Function *InitFunc, InitSegAttr *ISA);
1871
1872 /// EmitCtorList - Generates a global array of functions and priorities using
1873 /// the given list and name. This array will have appending linkage and is
1874 /// suitable for use as a LLVM constructor or destructor array. Clears Fns.
1875 void EmitCtorList(CtorList &Fns, const char *GlobalName);
1876
1877 /// Emit any needed decls for which code generation was deferred.
1878 void EmitDeferred();
1879
1880 /// Try to emit external vtables as available_externally if they have emitted
1881 /// all inlined virtual functions. It runs after EmitDeferred() and therefore
1882 /// is not allowed to create new references to things that need to be emitted
1883 /// lazily.
1884 void EmitVTablesOpportunistically();
1885
1886 /// Call replaceAllUsesWith on all pairs in Replacements.
1887 void applyReplacements();
1888
1889 /// Call replaceAllUsesWith on all pairs in GlobalValReplacements.
1890 void applyGlobalValReplacements();
1891
1892 void checkAliases();
1893
1894 std::map<int, llvm::TinyPtrVector<llvm::Function *>> DtorsUsingAtExit;
1895
1896 /// Register functions annotated with __attribute__((destructor)) using
1897 /// __cxa_atexit, if it is available, or atexit otherwise.
1898 void registerGlobalDtorsWithAtExit();
1899
1900 // When using sinit and sterm functions, unregister
1901 // __attribute__((destructor)) annotated functions which were previously
1902 // registered by the atexit subroutine using unatexit.
1903 void unregisterGlobalDtorsWithUnAtExit();
1904
1905 /// Emit deferred multiversion function resolvers and associated variants.
1906 void emitMultiVersionFunctions();
1907
1908 /// Emit any vtables which we deferred and still have a use for.
1909 void EmitDeferredVTables();
1910
1911 /// Emit a dummy function that reference a CoreFoundation symbol when
1912 /// @available is used on Darwin.
1913 void emitAtAvailableLinkGuard();
1914
1915 /// Emit the llvm.used and llvm.compiler.used metadata.
1916 void emitLLVMUsed();
1917
1918 /// For C++20 Itanium ABI, emit the initializers for the module.
1919 void EmitModuleInitializers(clang::Module *Primary);
1920
1921 /// Emit the link options introduced by imported modules.
1922 void EmitModuleLinkOptions();
1923
1924 /// Helper function for EmitStaticExternCAliases() to redirect ifuncs that
1925 /// have a resolver name that matches 'Elem' to instead resolve to the name of
1926 /// 'CppFunc'. This redirection is necessary in cases where 'Elem' has a name
1927 /// that will be emitted as an alias of the name bound to 'CppFunc'; ifuncs
1928 /// may not reference aliases. Redirection is only performed if 'Elem' is only
1929 /// used by ifuncs in which case, 'Elem' is destroyed. 'true' is returned if
1930 /// redirection is successful, and 'false' is returned otherwise.
1931 bool CheckAndReplaceExternCIFuncs(llvm::GlobalValue *Elem,
1932 llvm::GlobalValue *CppFunc);
1933
1934 /// Emit aliases for internal-linkage declarations inside "C" language
1935 /// linkage specifications, giving them the "expected" name where possible.
1936 void EmitStaticExternCAliases();
1937
1938 void EmitDeclMetadata();
1939
1940 /// Emit the Clang version as llvm.ident metadata.
1941 void EmitVersionIdentMetadata();
1942
1943 /// Emit the Clang commandline as llvm.commandline metadata.
1944 void EmitCommandLineMetadata();
1945
1946 /// Emit the module flag metadata used to pass options controlling the
1947 /// the backend to LLVM.
1948 void EmitBackendOptionsMetadata(const CodeGenOptions &CodeGenOpts);
1949
1950 /// Emits OpenCL specific Metadata e.g. OpenCL version.
1951 void EmitOpenCLMetadata();
1952
1953 /// Emit the llvm.gcov metadata used to tell LLVM where to emit the .gcno and
1954 /// .gcda files in a way that persists in .bc files.
1955 void EmitCoverageFile();
1956
1957 /// Determine whether the definition must be emitted; if this returns \c
1958 /// false, the definition can be emitted lazily if it's used.
1959 bool MustBeEmitted(const ValueDecl *D);
1960
1961 /// Determine whether the definition can be emitted eagerly, or should be
1962 /// delayed until the end of the translation unit. This is relevant for
1963 /// definitions whose linkage can change, e.g. implicit function instantions
1964 /// which may later be explicitly instantiated.
1965 bool MayBeEmittedEagerly(const ValueDecl *D);
1966
1967 /// Check whether we can use a "simpler", more core exceptions personality
1968 /// function.
1969 void SimplifyPersonality();
1970
1971 /// Helper function for getDefaultFunctionAttributes. Builds a set of function
1972 /// attributes which can be simply added to a function.
1973 void getTrivialDefaultFunctionAttributes(StringRef Name, bool HasOptnone,
1974 bool AttrOnCallSite,
1975 llvm::AttrBuilder &FuncAttrs);
1976
1977 /// Helper function for ConstructAttributeList and
1978 /// addDefaultFunctionDefinitionAttributes. Builds a set of function
1979 /// attributes to add to a function with the given properties.
1980 void getDefaultFunctionAttributes(StringRef Name, bool HasOptnone,
1981 bool AttrOnCallSite,
1982 llvm::AttrBuilder &FuncAttrs);
1983
1984 llvm::Metadata *CreateMetadataIdentifierImpl(QualType T, MetadataTypeMap &Map,
1985 StringRef Suffix);
1986};
1987
1988} // end namespace CodeGen
1989} // end namespace clang
1990
1991#endif // LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
Enums/classes describing ABI related information about constructors, destructors and thunks.
#define V(N, I)
Definition: ASTContext.h:3460
const Decl * D
enum clang::sema::@1727::IndirectLocalPathEntry::EntryKind Kind
Expr * E
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
int Priority
Definition: Format.cpp:3057
int Category
Definition: Format.cpp:3056
llvm::DenseSet< const void * > Visited
Definition: HTMLLogger.cpp:145
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
Definition: MachO.h:51
llvm::MachO::Record Record
Definition: MachO.h:31
SourceLocation Loc
Definition: SemaObjC.cpp:759
Defines a utilitiy for warning once when close to out of stack space.
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Attr - This represents one attribute.
Definition: Attr.h:43
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4496
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:6414
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2817
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
const CXXBaseSpecifier *const * path_const_iterator
Definition: Expr.h:3614
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:185
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
ABIInfo - Target specific hooks for defining how a type should be passed or returned from functions.
Definition: ABIInfo.h:48
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Definition: Address.h:128
A pair of helper functions for a __block variable.
void Profile(llvm::FoldingSetNodeID &id) const
virtual void emitCopy(CodeGenFunction &CGF, Address dest, Address src)=0
BlockByrefHelpers(CharUnits alignment)
virtual bool needsCopy() const
CharUnits Alignment
The alignment of the field.
virtual void emitDispose(CodeGenFunction &CGF, Address field)=0
BlockByrefHelpers(const BlockByrefHelpers &)=default
virtual bool needsDispose() const
virtual void profileImpl(llvm::FoldingSetNodeID &id) const =0
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:43
Abstract information about a function or function prototype.
Definition: CGCall.h:41
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition: CGDebugInfo.h:58
CGFunctionInfo - Class to encapsulate the information about a function definition.
Implements runtime-specific code generation functions.
Definition: CGObjCRuntime.h:65
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD)
llvm::FunctionCallee getBlockObjectAssign()
Definition: CGBlocks.cpp:2847
const PreprocessorOptions & getPreprocessorOpts() const
ConstantAddress GetAddrOfMSGuidDecl(const MSGuidDecl *GD)
Get the address of a GUID.
void AddCXXPrioritizedStermFinalizerEntry(llvm::Function *StermFinalizer, int Priority)
void setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const
Set visibility, dllimport/dllexport and dso_local.
void AddCXXDtorEntry(llvm::FunctionCallee DtorFn, llvm::Constant *Object)
Add a destructor and object to add to the C++ global destructor function.
llvm::FoldingSet< BlockByrefHelpers > ByrefHelpersCache
void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset, const CXXRecordDecl *RD)
Create and attach type metadata for the given vtable.
void UpdateCompletedType(const TagDecl *TD)
void handleCUDALaunchBoundsAttr(llvm::Function *F, const CUDALaunchBoundsAttr *A, int32_t *MaxThreadsVal=nullptr, int32_t *MinBlocksVal=nullptr, int32_t *MaxClusterRankVal=nullptr)
Emit the IR encoding to attach the CUDA launch bounds attribute to F.
Definition: NVPTX.cpp:351
llvm::MDNode * getTBAAAccessTagInfo(TBAAAccessInfo Info)
getTBAAAccessTagInfo - Get TBAA tag for a given memory access.
llvm::MDNode * getNoObjCARCExceptionsMetadata()
void AddCXXStermFinalizerToGlobalDtor(llvm::Function *StermFinalizer, int Priority)
Add an sterm finalizer to its own llvm.global_dtors entry.
llvm::GlobalVariable::ThreadLocalMode GetDefaultLLVMTLSModel() const
Get LLVM TLS mode from CodeGenOptions.
void EmitExplicitCastExprType(const ExplicitCastExpr *E, CodeGenFunction *CGF=nullptr)
Emit type info if type of an expression is a variably modified type.
Definition: CGExpr.cpp:1268
void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
void setDSOLocal(llvm::GlobalValue *GV) const
llvm::GlobalObject::VCallVisibility GetVCallVisibilityLevel(const CXXRecordDecl *RD, llvm::DenseSet< const CXXRecordDecl * > &Visited)
Returns the vcall visibility of the given type.
Definition: CGVTables.cpp:1316
llvm::MDNode * getTBAAStructInfo(QualType QTy)
CGHLSLRuntime & getHLSLRuntime()
Return a reference to the configured HLSL runtime.
llvm::Constant * EmitAnnotationArgs(const AnnotateAttr *Attr)
Emit additional args of the annotation.
llvm::Module & getModule() const
llvm::FunctionCallee CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false, bool AssumeConvergent=false)
Create or return a runtime function declaration with the specified type and name.
CGDebugInfo * getModuleDebugInfo()
ConstantAddress GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *E)
Returns a pointer to a constant global variable for the given file-scope compound literal expression.
void setLLVMFunctionFEnvAttributes(const FunctionDecl *D, llvm::Function *F)
Set the LLVM function attributes that represent floating point environment.
bool NeedAllVtablesTypeId() const
Returns whether this module needs the "all-vtables" type identifier.
void addCompilerUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.compiler.used metadata.
CodeGenVTables & getVTables()
llvm::ConstantInt * CreateCrossDsoCfiTypeId(llvm::Metadata *MD)
Generate a cross-DSO type identifier for MD.
void setStaticLocalDeclAddress(const VarDecl *D, llvm::Constant *C)
llvm::Constant * EmitNullConstantForBase(const CXXRecordDecl *Record)
Return a null constant appropriate for zero-initializing a base class with the given type.
llvm::Function * getLLVMLifetimeStartFn()
Lazily declare the @llvm.lifetime.start intrinsic.
Definition: CGDecl.cpp:2518
CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const
Return the store size, in character units, of the given LLVM type.
void handleAMDGPUWavesPerEUAttr(llvm::Function *F, const AMDGPUWavesPerEUAttr *A)
Emit the IR encoding to attach the AMD GPU waves-per-eu attribute to F.
Definition: AMDGPU.cpp:724
void AddCXXStermFinalizerEntry(llvm::FunctionCallee DtorFn)
Add an sterm finalizer to the C++ global cleanup function.
void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C)
bool getExpressionLocationsEnabled() const
Return true if we should emit location information for expressions.
CharUnits getMinimumClassObjectSize(const CXXRecordDecl *CD)
Returns the minimum object size for an object of the given class type (or a class derived from it).
Definition: CGClass.cpp:59
void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C)
llvm::Constant * getRawFunctionPointer(GlobalDecl GD, llvm::Type *Ty=nullptr)
Return a function pointer for a reference to the given function.
Definition: CGExpr.cpp:2913
llvm::FunctionCallee getAddrAndTypeOfCXXStructor(GlobalDecl GD, const CGFunctionInfo *FnInfo=nullptr, llvm::FunctionType *FnType=nullptr, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
Definition: CGCXX.cpp:218
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
llvm::Constant * GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty=nullptr, bool ForVTable=false, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
Return the address of the given function.
Address createUnnamedGlobalFrom(const VarDecl &D, llvm::Constant *Constant, CharUnits Align)
Definition: CGDecl.cpp:1108
void setGVPropertiesAux(llvm::GlobalValue *GV, const NamedDecl *D) const
llvm::Constant * getFunctionPointer(GlobalDecl GD, llvm::Type *Ty=nullptr)
Return the ABI-correct function pointer value for a reference to the given function.
const IntrusiveRefCntPtr< llvm::vfs::FileSystem > & getFileSystem() const
void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr)
Notes that BE's global block is available via Addr.
Definition: CGBlocks.cpp:1258
void setStaticLocalDeclGuardAddress(const VarDecl *D, llvm::GlobalVariable *C)
bool ReturnTypeUsesFPRet(QualType ResultType)
Return true iff the given type uses 'fpret' when used as a return type.
Definition: CGCall.cpp:1596
void EmitMainVoidAlias()
Emit an alias for "main" if it has no arguments (needed for wasm).
void DecorateInstructionWithInvariantGroup(llvm::Instruction *I, const CXXRecordDecl *RD)
Adds !invariant.barrier !tag to instruction.
llvm::Constant * getBuiltinLibFunction(const FunctionDecl *FD, unsigned BuiltinID)
Given a builtin id for a function like "__builtin_fabsf", return a Function* for "fabsf".
Definition: CGBuiltin.cpp:263
DiagnosticsEngine & getDiags() const
bool isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn, SourceLocation Loc) const
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
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.
bool isPaddedAtomicType(QualType type)
llvm::Constant * getNullPointer(llvm::PointerType *T, QualType QT)
Get target specific null pointer.
void AddCXXGlobalInit(llvm::Function *F)
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
llvm::Constant * EmitAnnotateAttr(llvm::GlobalValue *GV, const AnnotateAttr *AA, SourceLocation L)
Generate the llvm::ConstantStruct which contains the annotation information for a given GlobalValue.
llvm::GlobalValue::LinkageTypes getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage)
Returns LLVM linkage for a declarator.
TBAAAccessInfo mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo, TBAAAccessInfo SrcInfo)
mergeTBAAInfoForMemoryTransfer - Get merged TBAA information for the purposes of memory transfer call...
llvm::Type * getBlockDescriptorType()
Fetches the type of a generic block descriptor.
Definition: CGBlocks.cpp:1096
llvm::Constant * GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name)
Gets the address of a block which requires no captures.
Definition: CGBlocks.cpp:1266
llvm::Constant * getAtomicGetterHelperFnMap(QualType Ty)
CGPointerAuthInfo getMemberFunctionPointerAuthInfo(QualType FT)
const LangOptions & getLangOpts() const
CGCUDARuntime & getCUDARuntime()
Return a reference to the configured CUDA runtime.
int getUniqueBlockCount()
Fetches the global unique block count.
llvm::Constant * EmitAnnotationLineNo(SourceLocation L)
Emit the annotation line number.
QualType getObjCFastEnumerationStateType()
Retrieve the record type that describes the state of an Objective-C fast enumeration loop (for....
CharUnits getNaturalTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, bool forPointeeType=false)
bool shouldMapVisibilityToDLLExport(const NamedDecl *D) const
CGOpenCLRuntime & getOpenCLRuntime()
Return a reference to the configured OpenCL runtime.
const std::string & getModuleNameHash() const
const TargetInfo & getTarget() const
bool shouldEmitRTTI(bool ForEH=false)
void EmitGlobal(GlobalDecl D)
Emit code for a single global function or var decl.
llvm::GlobalVariable * getStaticLocalDeclGuardAddress(const VarDecl *D)
llvm::ConstantInt * getPointerAuthOtherDiscriminator(const PointerAuthSchema &Schema, GlobalDecl SchemaDecl, QualType SchemaType)
Given a pointer-authentication schema, return a concrete "other" discriminator for it.
llvm::Metadata * CreateMetadataIdentifierForType(QualType T)
Create a metadata identifier for the given type.
llvm::Constant * getTypeDescriptorFromMap(QualType Ty)
llvm::IndexedInstrProfReader * getPGOReader() const
void addUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.used metadata.
void handleAMDGPUFlatWorkGroupSizeAttr(llvm::Function *F, const AMDGPUFlatWorkGroupSizeAttr *A, const ReqdWorkGroupSizeAttr *ReqdWGS=nullptr, int32_t *MinThreadsVal=nullptr, int32_t *MaxThreadsVal=nullptr)
Emit the IR encoding to attach the AMD GPU flat-work-group-size attribute to F.
Definition: AMDGPU.cpp:697
void AppendLinkerOptions(StringRef Opts)
Appends Opts to the "llvm.linker.options" metadata value.
bool hasObjCRuntime()
Return true iff an Objective-C runtime has been configured.
void EmitExternalDeclaration(const DeclaratorDecl *D)
void AddDependentLib(StringRef Lib)
Appends a dependent lib to the appropriate metadata value.
void Release()
Finalize LLVM code generation.
llvm::FunctionCallee IsOSVersionAtLeastFn
ProfileList::ExclusionType isFunctionBlockedByProfileList(llvm::Function *Fn, SourceLocation Loc) const
CGPointerAuthInfo getPointerAuthInfoForPointeeType(QualType type)
llvm::MDNode * getTBAABaseTypeInfo(QualType QTy)
getTBAABaseTypeInfo - Get metadata that describes the given base access type.
CGPointerAuthInfo EmitPointerAuthInfo(const RecordDecl *RD)
void EmitVTableTypeMetadata(const CXXRecordDecl *RD, llvm::GlobalVariable *VTable, const VTableLayout &VTLayout)
Emit type metadata for the given vtable using the given layout.
Definition: CGVTables.cpp:1350
bool lookupRepresentativeDecl(StringRef MangledName, GlobalDecl &Result) const
void EmitOMPAllocateDecl(const OMPAllocateDecl *D)
Emit a code for the allocate directive.
Definition: CGDecl.cpp:2775
void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const
Set the visibility for the given LLVM GlobalValue.
CoverageMappingModuleGen * getCoverageMapping() const
llvm::Constant * GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd)
Returns the offset from a derived class to a class.
Definition: CGClass.cpp:200
bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D)
Try to emit a base destructor as an alias to its primary base-class destructor.
Definition: CGCXX.cpp:32
llvm::GlobalValue::LinkageTypes getLLVMLinkageVarDefinition(const VarDecl *VD)
Returns LLVM linkage for a declarator.
llvm::Constant * getMemberPointerConstant(const UnaryOperator *e)
bool HasHiddenLTOVisibility(const CXXRecordDecl *RD)
Returns whether the given record has hidden LTO visibility and therefore may participate in (single-m...
Definition: CGVTables.cpp:1304
const llvm::DataLayout & getDataLayout() const
llvm::Constant * getNSConcreteGlobalBlock()
Definition: CGBlocks.cpp:2859
void addUndefinedGlobalForTailCall(std::pair< const FunctionDecl *, SourceLocation > Global)
CharUnits computeNonVirtualBaseClassOffset(const CXXRecordDecl *DerivedClass, CastExpr::path_const_iterator Start, CastExpr::path_const_iterator End)
Definition: CGClass.cpp:172
ObjCEntrypoints & getObjCEntrypoints() const
TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType)
getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an access to a virtual table poi...
bool shouldEmitConvergenceTokens() const
CGCXXABI & getCXXABI() const
ConstantAddress GetWeakRefReference(const ValueDecl *VD)
Get a reference to the target of VD.
CGPointerAuthInfo getFunctionPointerAuthInfo(QualType T)
Return the abstract pointer authentication schema for a pointer to the given function type.
CharUnits getVBaseAlignment(CharUnits DerivedAlign, const CXXRecordDecl *Derived, const CXXRecordDecl *VBase)
Returns the assumed alignment of a virtual base of a class.
Definition: CGClass.cpp:76
llvm::Constant * GetFunctionStart(const ValueDecl *Decl)
llvm::GlobalVariable * getAddrOfConstantCompoundLiteralIfEmitted(const CompoundLiteralExpr *E)
If it's been emitted already, returns the GlobalVariable corresponding to a compound literal.
static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V)
void EmitTentativeDefinition(const VarDecl *D)
bool ReturnTypeUsesFP2Ret(QualType ResultType)
Return true iff the given type uses 'fp2ret' when used as a return type.
Definition: CGCall.cpp:1613
void EmitDeferredUnusedCoverageMappings()
Emit all the deferred coverage mappings for the uninstrumented functions.
void addUsedOrCompilerUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.compiler.used metadata.
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
bool imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc, StringRef Category=StringRef()) const
Imbue XRay attributes to a function, applying the always/never attribute lists in the process.
llvm::Constant * getMemberFunctionPointer(const FunctionDecl *FD, llvm::Type *Ty=nullptr)
SanitizerMetadata * getSanitizerMetadata()
llvm::Metadata * CreateMetadataIdentifierGeneralized(QualType T)
Create a metadata identifier for the generalization of the given type.
void EmitGlobalAnnotations()
Emit all the global annotations.
llvm::Constant * getAddrOfGlobalBlockIfEmitted(const BlockExpr *BE)
Returns the address of a block which requires no caputres, or null if we've yet to emit the block for...
std::optional< PointerAuthQualifier > getVTablePointerAuthentication(const CXXRecordDecl *thisClass)
llvm::Function * codegenCXXStructor(GlobalDecl GD)
Definition: CGCXX.cpp:204
CharUnits getClassPointerAlignment(const CXXRecordDecl *CD)
Returns the assumed alignment of an opaque pointer to the given class.
Definition: CGClass.cpp:40
const llvm::Triple & getTriple() const
void setAtomicSetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
llvm::Constant * getOrCreateStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
Definition: CGDecl.cpp:246
SmallVector< const CXXRecordDecl *, 0 > getMostBaseClasses(const CXXRecordDecl *RD)
Return a vector of most-base classes for RD.
void AddDeferredUnusedCoverageMapping(Decl *D)
Stored a deferred empty coverage mapping for an unused and thus uninstrumented top level declaration.
bool AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD)
Returns whether the given record has public LTO visibility (regardless of -lto-whole-program-visibili...
Definition: CGVTables.cpp:1280
void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV)
If the declaration has internal linkage but is inside an extern "C" linkage specification,...
void DecorateInstructionWithTBAA(llvm::Instruction *Inst, TBAAAccessInfo TBAAInfo)
DecorateInstructionWithTBAA - Decorate the instruction with a TBAA tag.
uint16_t getPointerAuthDeclDiscriminator(GlobalDecl GD)
Return the "other" decl-specific discriminator for the given decl.
llvm::Constant * getAtomicSetterHelperFnMap(QualType Ty)
TBAAAccessInfo getTBAAInfoForSubobject(LValue Base, QualType AccessType)
getTBAAInfoForSubobject - Get TBAA information for an access with a given base lvalue.
llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD)
void AddGlobalDtor(llvm::Function *Dtor, int Priority=65535, bool IsDtorAttrFunc=false)
AddGlobalDtor - Add a function to the list that will be called when the module is unloaded.
bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI)
Return true iff the given type uses an argument slot when 'sret' is used as a return type.
Definition: CGCall.cpp:1591
bool ReturnTypeHasInReg(const CGFunctionInfo &FI)
Return true iff the given type has inreg set.
Definition: CGCall.cpp:1586
void EmitVTable(CXXRecordDecl *Class)
This is a callback from Sema to tell us that a particular vtable is required to be emitted in this tr...
Definition: CGVTables.cpp:1185
llvm::Constant * CreateRuntimeVariable(llvm::Type *Ty, StringRef Name)
Create a new runtime global variable with the specified type and name.
void AdjustMemoryAttribute(StringRef Name, CGCalleeInfo CalleeInfo, llvm::AttributeList &Attrs)
Adjust Memory attribute to ensure that the BE gets the right attribute.
Definition: CGCall.cpp:2308
void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info, CGCalleeInfo CalleeInfo, llvm::AttributeList &Attrs, unsigned &CallingConv, bool AttrOnCallSite, bool IsThunk)
Get the LLVM attributes and calling convention to use for a particular function type.
Definition: CGCall.cpp:2336
CharUnits getDynamicOffsetAlignment(CharUnits ActualAlign, const CXXRecordDecl *Class, CharUnits ExpectedTargetAlign)
Given a class pointer with an actual known alignment, and the expected alignment of an object at a dy...
Definition: CGClass.cpp:91
llvm::Constant * GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty, LangAS AddrSpace, const VarDecl *D, ForDefinition_t IsForDefinition=NotForDefinition)
GetOrCreateLLVMGlobal - If the specified mangled name is not in the module, create and return an llvm...
TBAAAccessInfo getTBAAAccessInfo(QualType AccessType)
getTBAAAccessInfo - Get TBAA information that describes an access to an object of the given type.
void setFunctionLinkage(GlobalDecl GD, llvm::Function *F)
llvm::Constant * GetAddrOfGlobal(GlobalDecl GD, ForDefinition_t IsForDefinition=NotForDefinition)
ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal)
Return a pointer to a constant CFString object for the given string.
InstrProfStats & getPGOStats()
ProfileList::ExclusionType isFunctionBlockedFromProfileInstr(llvm::Function *Fn, SourceLocation Loc) const
void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV)
Add global annotations that are set on D, for the global GV.
void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const
Set the TLS mode for the given LLVM GlobalValue for the thread-local variable declaration D.
ItaniumVTableContext & getItaniumVTableContext()
ConstantAddress GetAddrOfConstantStringFromLiteral(const StringLiteral *S, StringRef Name=".str")
Return a pointer to a constant array for the given string literal.
ASTContext & getContext() const
ConstantAddress GetAddrOfTemplateParamObject(const TemplateParamObjectDecl *TPO)
Get the address of a template parameter object.
void EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D)
Emit a code for threadprivate directive.
llvm::Constant * getNSConcreteStackBlock()
Definition: CGBlocks.cpp:2869
ConstantAddress GetAddrOfUnnamedGlobalConstantDecl(const UnnamedGlobalConstantDecl *GCD)
Get the address of a UnnamedGlobalConstant.
TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo, TBAAAccessInfo TargetInfo)
mergeTBAAInfoForCast - Get merged TBAA information for the purposes of type casts.
llvm::Constant * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr, ForDefinition_t IsForDefinition=NotForDefinition)
Return the llvm::Constant for the address of the given global variable.
MicrosoftVTableContext & getMicrosoftVTableContext()
const HeaderSearchOptions & getHeaderSearchOpts() const
llvm::SanitizerStatReport & getSanStats()
llvm::Constant * EmitAnnotationString(StringRef Str)
Emit an annotation string.
llvm::Type * getVTableComponentType() const
Definition: CGVTables.cpp:715
void EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare mapper construct.
Definition: CGDecl.cpp:2763
llvm::Function * getLLVMLifetimeEndFn()
Lazily declare the @llvm.lifetime.end intrinsic.
Definition: CGDecl.cpp:2527
void RefreshTypeCacheForClass(const CXXRecordDecl *Class)
llvm::MDNode * getTBAATypeInfo(QualType QTy)
getTBAATypeInfo - Get metadata used to describe accesses to objects of the given type.
void setAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *CLE, llvm::GlobalVariable *GV)
Notes that CLE's GlobalVariable is GV.
void EmitOMPRequiresDecl(const OMPRequiresDecl *D)
Emit a code for requires directive.
Definition: CGDecl.cpp:2771
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD)
Tell the consumer that this variable has been instantiated.
bool ReturnTypeUsesSRet(const CGFunctionInfo &FI)
Return true iff the given type uses 'sret' when used as a return type.
Definition: CGCall.cpp:1581
const TargetCodeGenInfo & getTargetCodeGenInfo()
const CodeGenOptions & getCodeGenOpts() const
StringRef getMangledName(GlobalDecl GD)
llvm::Constant * GetConstantArrayFromStringLiteral(const StringLiteral *E)
Return a constant array for the given string.
void SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV)
Set attributes which are common to any form of a global definition (alias, Objective-C method,...
void addDefaultFunctionDefinitionAttributes(llvm::AttrBuilder &attrs)
Like the overload taking a Function &, but intended specifically for frontends that want to build on ...
Definition: CGCall.cpp:2161
std::optional< CharUnits > getOMPAllocateAlignment(const VarDecl *VD)
Return the alignment specified in an allocate directive, if present.
Definition: CGDecl.cpp:2830
llvm::GlobalVariable * CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, llvm::GlobalValue::LinkageTypes Linkage, llvm::Align Alignment)
Will return a global variable of the given type.
llvm::FunctionCallee getTerminateFn()
Get the declaration of std::terminate for the platform.
Definition: CGException.cpp:62
CharUnits getNaturalPointeeTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
llvm::FunctionCallee getBlockObjectDispose()
Definition: CGBlocks.cpp:2835
TBAAAccessInfo mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA, TBAAAccessInfo InfoB)
mergeTBAAInfoForConditionalOperator - Get merged TBAA information for the purposes of conditional ope...
llvm::LLVMContext & getLLVMContext()
llvm::GlobalValue * GetGlobalValue(StringRef Ref)
void GenKernelArgMetadata(llvm::Function *FN, const FunctionDecl *FD=nullptr, CodeGenFunction *CGF=nullptr)
OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument information in the program executab...
void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD, llvm::Function *F)
Create and attach type metadata to the given function.
void setKCFIType(const FunctionDecl *FD, llvm::Function *F)
Set type metadata to the given function.
void setAtomicGetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO)
void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare reduction construct.
Definition: CGDecl.cpp:2756
const ItaniumVTableContext & getItaniumVTableContext() const
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys={})
void AddDetectMismatch(StringRef Name, StringRef Value)
Appends a detect mismatch command to the linker options.
void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
llvm::Value * createOpenCLIntToSamplerConversion(const Expr *E, CodeGenFunction &CGF)
ConstantAddress GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, const Expr *Inner)
Returns a pointer to a global variable representing a temporary with static or thread storage duratio...
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
LangAS GetGlobalConstantAddressSpace() const
Return the AST address space of constant literal, which is used to emit the constant literal as globa...
LangAS GetGlobalVarAddressSpace(const VarDecl *D)
Return the AST address space of the underlying global variable for D, as determined by its declaratio...
llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD)
Return the appropriate linkage for the vtable, VTT, and type information of the given class.
Definition: CGVTables.cpp:1080
void SetLLVMFunctionAttributes(GlobalDecl GD, const CGFunctionInfo &Info, llvm::Function *F, bool IsThunk)
Set the LLVM function attributes (sext, zext, etc).
void addDeferredVTable(const CXXRecordDecl *RD)
llvm::Type * getGenericBlockLiteralType()
The type of a generic block literal.
Definition: CGBlocks.cpp:1128
CharUnits getMinimumObjectSize(QualType Ty)
Returns the minimum object size for an object of the given type.
void addReplacement(StringRef Name, llvm::Constant *C)
llvm::ConstantInt * CreateKCFITypeId(QualType T)
Generate a KCFI type identifier for T.
std::optional< CGPointerAuthInfo > getVTablePointerAuthInfo(CodeGenFunction *Context, const CXXRecordDecl *Record, llvm::Value *StorageAddress)
llvm::Constant * getConstantSignedPointer(llvm::Constant *Pointer, const PointerAuthSchema &Schema, llvm::Constant *StorageAddress, GlobalDecl SchemaDecl, QualType SchemaType)
Sign a constant pointer using the given scheme, producing a constant with the same IR type.
llvm::FunctionCallee IsPlatformVersionAtLeastFn
void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535, unsigned LexOrder=~0U, llvm::Constant *AssociatedData=nullptr)
AddGlobalCtor - Add a function to the list that will be called before main() runs.
bool shouldSignPointer(const PointerAuthSchema &Schema)
Does a given PointerAuthScheme require us to sign a value.
void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F)
Set the LLVM function attributes which only apply to a function definition.
llvm::Metadata * CreateMetadataIdentifierForVirtualMemPtrType(QualType T)
Create a metadata identifier that is intended to be used to check virtual calls via a member function...
llvm::Constant * getStaticLocalDeclAddress(const VarDecl *D)
bool MayDropFunctionReturn(const ASTContext &Context, QualType ReturnType) const
Whether this function's return type has no side effects, and thus may be trivially discarded if it is...
Definition: CGCall.cpp:1821
ConstantAddress GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *)
Return a pointer to a constant array for the given ObjCEncodeExpr node.
const GlobalDecl getMangledNameDecl(StringRef)
void ClearUnusedCoverageMapping(const Decl *D)
Remove the deferred empty coverage mapping as this declaration is actually instrumented.
void EmitTopLevelDecl(Decl *D)
Emit code for a single top level declaration.
llvm::Function * CreateGlobalInitOrCleanUpFunction(llvm::FunctionType *ty, const Twine &name, const CGFunctionInfo &FI, SourceLocation Loc=SourceLocation(), bool TLS=false, llvm::GlobalVariable::LinkageTypes Linkage=llvm::GlobalVariable::InternalLinkage)
Definition: CGDeclCXX.cpp:443
llvm::Constant * EmitAnnotationUnit(SourceLocation Loc)
Emit the annotation's translation unit.
CGPointerAuthInfo getPointerAuthInfoForType(QualType type)
ConstantAddress GetAddrOfConstantCString(const std::string &Str, const char *GlobalName=nullptr)
Returns a pointer to a character array containing the literal and a terminating '\0' character.
std::vector< Structor > CtorList
void printPostfixForExternalizedDecl(llvm::raw_ostream &OS, const Decl *D) const
Print the postfix for externalized static variable or kernels for single source offloading languages ...
llvm::Constant * GetAddrOfThunk(StringRef Name, llvm::Type *FnTy, GlobalDecl GD)
Get the address of the thunk for the given global decl.
Definition: CGVTables.cpp:34
void moveLazyEmissionStates(CodeGenModule *NewBuilder)
Move some lazily-emitted states to the NewBuilder.
llvm::ConstantInt * getSize(CharUnits numChars)
Emit the given number of characters as a value of type size_t.
void finalizeKCFITypes()
Emit KCFI type identifier constants and remove unused identifiers.
This class organizes the cross-module state that is used while lowering AST types to LLVM types.
Definition: CodeGenTypes.h:54
ItaniumVTableContext & getItaniumVTableContext()
Definition: CGVTables.h:91
MicrosoftVTableContext & getMicrosoftVTableContext()
Definition: CGVTables.h:99
A specialization of Address that requires the address to be an LLVM Constant.
Definition: Address.h:294
The Counter with an optional additional Counter for branches.
CounterPair(unsigned Val)
May be None.
Organizes the cross-function state that is used while generating code coverage mapping data.
This class records statistics on instrumentation based profiling.
bool hasDiagnostics()
Whether or not the stats we've gathered indicate any potential problems.
void addMissing(bool MainFile)
Record that a function we've visited has no profile data.
void addMismatched(bool MainFile)
Record that a function we've visited has mismatched profile data.
void addVisited(bool MainFile)
Record that we've visited a function and whether or not that function was in the main source file.
void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile)
Report potential problems we've found to Diags.
LValue - This represents an lvalue references.
Definition: CGValue.h:182
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Definition: TargetInfo.h:47
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3477
Stores additional source code information like skipped ranges which is required by the coverage mappi...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1439
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:735
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:231
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3799
This represents one expression.
Definition: Expr.h:110
Represents a function declaration or definition.
Definition: Decl.h:1935
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:4321
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:56
const Decl * getDecl() const
Definition: GlobalDecl.h:103
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:499
bool hasDefaultVisibilityExportMapping() const
Definition: LangOptions.h:773
bool isExplicitDefaultVisibilityExportMapping() const
Definition: LangOptions.h:778
bool isAllDefaultVisibilityExportMapping() const
Definition: LangOptions.h:783
Represents a linkage specification.
Definition: DeclCXX.h:2957
A global _GUID constant.
Definition: DeclCXX.h:4312
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4734
Describes a module or submodule.
Definition: Module.h:115
This represents a decl that may have a name.
Definition: Decl.h:253
This represents '#pragma omp allocate ...' directive.
Definition: DeclOpenMP.h:474
This represents '#pragma omp declare mapper ...' directive.
Definition: DeclOpenMP.h:287
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:177
This represents '#pragma omp requires...' directive.
Definition: DeclOpenMP.h:417
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:110
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:410
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2596
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:28
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
ExclusionType
Represents if an how something should be excluded from profiling.
Definition: ProfileList.h:31
A (possibly-)qualified type.
Definition: Type.h:929
Represents a struct/union/class.
Definition: Decl.h:4162
Encodes a location in the source.
Stmt - This represents one statement.
Definition: Stmt.h:84
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1778
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3578
Exposes information about the current target.
Definition: TargetInfo.h:220
A template parameter object.
A declaration that models statements at global scope.
Definition: Decl.h:4459
The base class of the type hierarchy.
Definition: Type.h:1828
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1916
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2232
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition: DeclCXX.h:4369
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:671
Represents a variable declaration or definition.
Definition: Decl.h:882
Defines the clang::TargetInfo interface.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The JSON file list parser is used to communicate input to InstallAPI.
GVALinkage
A more specific kind of linkage than enum Linkage.
Definition: Linkage.h:72
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:24
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ Result
The result type of a method or function.
LangAS
Defines the address space values used by the address space qualifier of QualType.
Definition: AddressSpaces.h:25
const FunctionProtoType * T
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:278
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Visibility
Describes the different kinds of visibility that a declaration may have.
Definition: Visibility.h:34
@ HiddenVisibility
Objects with "hidden" visibility are not seen by the dynamic linker.
Definition: Visibility.h:37
@ ProtectedVisibility
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
Definition: Visibility.h:42
@ DefaultVisibility
Objects with "default" visibility are seen by the dynamic linker and act like normal objects.
Definition: Visibility.h:46
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
Structor(int Priority, unsigned LexOrder, llvm::Constant *Initializer, llvm::Constant *AssociatedData)
This structure provides a set of types that are commonly used during IR emission.
llvm::Function * objc_retainAutoreleasedReturnValue
id objc_retainAutoreleasedReturnValue(id);
llvm::Function * objc_retainAutoreleaseReturnValue
id objc_retainAutoreleaseReturnValue(id);
llvm::FunctionCallee objc_alloc
void objc_alloc(id);
llvm::Function * objc_retain
id objc_retain(id);
llvm::FunctionCallee objc_alloc_init
void objc_alloc_init(id);
llvm::Function * objc_autorelease
id objc_autorelease(id);
llvm::Function * objc_moveWeak
void objc_moveWeak(id *dest, id *src);
llvm::FunctionCallee objc_autoreleasePoolPopInvoke
void objc_autoreleasePoolPop(void*); Note this method is used when we are using exception handling
llvm::InlineAsm * retainAutoreleasedReturnValueMarker
A void(void) inline asm to use to mark that the return value of a call will be immediately retain.
llvm::Function * clang_arc_use
void clang.arc.use(...);
llvm::Function * objc_initWeak
id objc_initWeak(id*, id);
llvm::FunctionCallee objc_retainRuntimeFunction
id objc_retain(id); Note this is the runtime method not the intrinsic.
llvm::Function * objc_copyWeak
void objc_copyWeak(id *dest, id *src);
llvm::Function * objc_destroyWeak
void objc_destroyWeak(id*);
llvm::Function * objc_retainAutorelease
id objc_retainAutorelease(id);
llvm::Function * objc_autoreleasePoolPush
void *objc_autoreleasePoolPush(void);
llvm::Function * objc_retainBlock
id objc_retainBlock(id);
llvm::Function * objc_storeStrong
void objc_storeStrong(id*, id);
llvm::Function * objc_loadWeak
id objc_loadWeak(id*);
llvm::Function * clang_arc_noop_use
void clang.arc.noop.use(...);
llvm::Function * objc_loadWeakRetained
id objc_loadWeakRetained(id*);
llvm::Function * objc_release
void objc_release(id);
llvm::FunctionCallee objc_autoreleaseRuntimeFunction
id objc_autorelease(id); Note this is the runtime method not the intrinsic.
llvm::Function * objc_autoreleaseReturnValue
id objc_autoreleaseReturnValue(id);
llvm::FunctionCallee objc_releaseRuntimeFunction
void objc_release(id); Note this is the runtime method not the intrinsic.
llvm::FunctionCallee objc_allocWithZone
void objc_allocWithZone(id);
llvm::FunctionCallee objc_autoreleasePoolPop
void objc_autoreleasePoolPop(void*);
llvm::Function * objc_storeWeak
id objc_storeWeak(id*, id);
llvm::Function * objc_unsafeClaimAutoreleasedReturnValue
id objc_unsafeClaimAutoreleasedReturnValue(id);
bool operator<(const OrderGlobalInitsOrStermFinalizers &RHS) const
bool operator==(const OrderGlobalInitsOrStermFinalizers &RHS) const
OrderGlobalInitsOrStermFinalizers(unsigned int p, unsigned int l)
static TBAAAccessInfo getMayAliasInfo()
Definition: CodeGenTBAA.h:63