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