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;
65class ObjCImplementationDecl;
66class ObjCEncodeExpr;
67class BlockExpr;
68class CharUnits;
69class Decl;
70class Expr;
71class Stmt;
72class StringLiteral;
73class NamedDecl;
74class PointerAuthSchema;
75class ValueDecl;
76class VarDecl;
77class LangOptions;
78class CodeGenOptions;
79class HeaderSearchOptions;
80class DiagnosticsEngine;
81class AnnotateAttr;
82class CXXDestructorDecl;
83class Module;
84class CoverageSourceInfo;
85class InitSegAttr;
86
87namespace CodeGen {
88
89class CodeGenFunction;
90class CodeGenTBAA;
91class CGCXXABI;
92class CGDebugInfo;
93class CGObjCRuntime;
94class CGOpenCLRuntime;
95class CGOpenMPRuntime;
96class CGCUDARuntime;
97class CGHLSLRuntime;
98class CoverageMappingModuleGen;
99class TargetCodeGenInfo;
100
101enum ForDefinition_t : bool {
103 ForDefinition = true
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
307 : CopyHelper(nullptr), DisposeHelper(nullptr), Alignment(alignment) {}
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.
327 CodeGenModule(const CodeGenModule &) = delete;
328 void operator=(const CodeGenModule &) = delete;
329
330public:
331 struct Structor {
333 : Priority(0), LexOrder(~0u), Initializer(nullptr),
334 AssociatedData(nullptr) {}
335 Structor(int Priority, unsigned LexOrder, llvm::Constant *Initializer,
336 llvm::Constant *AssociatedData)
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 typedef std::pair<OrderGlobalInitsOrStermFinalizers, llvm::Function *>
533 GlobalInitData;
534
535 // When a tail call is performed on an "undefined" symbol, on PPC without pc
536 // relative feature, the tail call is not allowed. In "EmitCall" for such
537 // tail calls, the "undefined" symbols may be forward declarations, their
538 // definitions are provided in the module after the callsites. For such tail
539 // calls, diagnose message should not be emitted.
541 MustTailCallUndefinedGlobals;
542
543 struct GlobalInitPriorityCmp {
544 bool operator()(const GlobalInitData &LHS,
545 const GlobalInitData &RHS) const {
546 return LHS.first.priority < RHS.first.priority;
547 }
548 };
549
550 /// Global variables with initializers whose order of initialization is set by
551 /// init_priority attribute.
552 SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits;
553
554 /// Global destructor functions and arguments that need to run on termination.
555 /// When UseSinitAndSterm is set, it instead contains sterm finalizer
556 /// functions, which also run on unloading a shared library.
557 typedef std::tuple<llvm::FunctionType *, llvm::WeakTrackingVH,
558 llvm::Constant *>
559 CXXGlobalDtorsOrStermFinalizer_t;
560 SmallVector<CXXGlobalDtorsOrStermFinalizer_t, 8>
561 CXXGlobalDtorsOrStermFinalizers;
562
563 typedef std::pair<OrderGlobalInitsOrStermFinalizers, llvm::Function *>
564 StermFinalizerData;
565
566 struct StermFinalizerPriorityCmp {
567 bool operator()(const StermFinalizerData &LHS,
568 const StermFinalizerData &RHS) const {
569 return LHS.first.priority < RHS.first.priority;
570 }
571 };
572
573 /// Global variables with sterm finalizers whose order of initialization is
574 /// set by init_priority attribute.
575 SmallVector<StermFinalizerData, 8> PrioritizedCXXStermFinalizers;
576
577 /// The complete set of modules that has been imported.
578 llvm::SetVector<clang::Module *> ImportedModules;
579
580 /// The set of modules for which the module initializers
581 /// have been emitted.
582 llvm::SmallPtrSet<clang::Module *, 16> EmittedModuleInitializers;
583
584 /// A vector of metadata strings for linker options.
585 SmallVector<llvm::MDNode *, 16> LinkerOptionsMetadata;
586
587 /// A vector of metadata strings for dependent libraries for ELF.
588 SmallVector<llvm::MDNode *, 16> ELFDependentLibraries;
589
590 /// @name Cache for Objective-C runtime types
591 /// @{
592
593 /// Cached reference to the class for constant strings. This value has type
594 /// int * but is actually an Obj-C class pointer.
595 llvm::WeakTrackingVH CFConstantStringClassRef;
596
597 /// The type used to describe the state of a fast enumeration in
598 /// Objective-C's for..in loop.
599 QualType ObjCFastEnumerationStateType;
600
601 /// @}
602
603 /// Lazily create the Objective-C runtime
604 void createObjCRuntime();
605
606 void createOpenCLRuntime();
607 void createOpenMPRuntime();
608 void createCUDARuntime();
609 void createHLSLRuntime();
610
611 bool isTriviallyRecursive(const FunctionDecl *F);
612 bool shouldEmitFunction(GlobalDecl GD);
613 // Whether a global variable should be emitted by CUDA/HIP host/device
614 // related attributes.
615 bool shouldEmitCUDAGlobalVar(const VarDecl *VD) const;
616 bool shouldOpportunisticallyEmitVTables();
617 /// Map used to be sure we don't emit the same CompoundLiteral twice.
618 llvm::DenseMap<const CompoundLiteralExpr *, llvm::GlobalVariable *>
619 EmittedCompoundLiterals;
620
621 /// Map of the global blocks we've emitted, so that we don't have to re-emit
622 /// them if the constexpr evaluator gets aggressive.
623 llvm::DenseMap<const BlockExpr *, llvm::Constant *> EmittedGlobalBlocks;
624
625 /// @name Cache for Blocks Runtime Globals
626 /// @{
627
628 llvm::Constant *NSConcreteGlobalBlock = nullptr;
629 llvm::Constant *NSConcreteStackBlock = nullptr;
630
631 llvm::FunctionCallee BlockObjectAssign = nullptr;
632 llvm::FunctionCallee BlockObjectDispose = nullptr;
633
634 llvm::Type *BlockDescriptorType = nullptr;
635 llvm::Type *GenericBlockLiteralType = nullptr;
636
637 struct {
639 } Block;
640
641 GlobalDecl initializedGlobalDecl;
642
643 /// @}
644
645 /// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>)
646 llvm::Function *LifetimeStartFn = nullptr;
647
648 /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>)
649 llvm::Function *LifetimeEndFn = nullptr;
650
651 /// void @llvm.fake.use(...)
652 llvm::Function *FakeUseFn = nullptr;
653
654 std::unique_ptr<SanitizerMetadata> SanitizerMD;
655
656 llvm::MapVector<const Decl *, bool> DeferredEmptyCoverageMappingDecls;
657
658 std::unique_ptr<CoverageMappingModuleGen> CoverageMapping;
659
660 /// Mapping from canonical types to their metadata identifiers. We need to
661 /// maintain this mapping because identifiers may be formed from distinct
662 /// MDNodes.
663 typedef llvm::DenseMap<QualType, llvm::Metadata *> MetadataTypeMap;
664 MetadataTypeMap MetadataIdMap;
665 MetadataTypeMap VirtualMetadataIdMap;
666 MetadataTypeMap GeneralizedMetadataIdMap;
667
668 // Helps squashing blocks of TopLevelStmtDecl into a single llvm::Function
669 // when used with -fincremental-extensions.
670 std::pair<std::unique_ptr<CodeGenFunction>, const TopLevelStmtDecl *>
671 GlobalTopLevelStmtBlockInFlight;
672
673 llvm::DenseMap<GlobalDecl, uint16_t> PtrAuthDiscriminatorHashes;
674
675 llvm::DenseMap<const CXXRecordDecl *, std::optional<PointerAuthQualifier>>
676 VTablePtrAuthInfos;
677 std::optional<PointerAuthQualifier>
678 computeVTPointerAuthentication(const CXXRecordDecl *ThisClass);
679
680 AtomicOptions AtomicOpts;
681
682 // A set of functions which should be hot-patched; see
683 // -fms-hotpatch-functions-file (and -list). This will nearly always be empty.
684 // The list is sorted for binary-searching.
685 std::vector<std::string> MSHotPatchFunctions;
686
687public:
689 const HeaderSearchOptions &headersearchopts,
690 const PreprocessorOptions &ppopts,
691 const CodeGenOptions &CodeGenOpts, llvm::Module &M,
692 DiagnosticsEngine &Diags,
693 CoverageSourceInfo *CoverageInfo = nullptr);
694
696
697 void clear();
698
699 /// Finalize LLVM code generation.
700 void Release();
701
702 /// Get the current Atomic options.
703 AtomicOptions getAtomicOpts() { return AtomicOpts; }
704
705 /// Set the current Atomic options.
706 void setAtomicOpts(AtomicOptions AO) { AtomicOpts = AO; }
707
708 /// Return true if we should emit location information for expressions.
710
711 /// Return a reference to the configured Objective-C runtime.
713 if (!ObjCRuntime) createObjCRuntime();
714 return *ObjCRuntime;
715 }
716
717 /// Return true iff an Objective-C runtime has been configured.
718 bool hasObjCRuntime() { return !!ObjCRuntime; }
719
720 const std::string &getModuleNameHash() const { return ModuleNameHash; }
721
722 /// Return a reference to the configured OpenCL runtime.
724 assert(OpenCLRuntime != nullptr);
725 return *OpenCLRuntime;
726 }
727
728 /// Return a reference to the configured OpenMP runtime.
730 assert(OpenMPRuntime != nullptr);
731 return *OpenMPRuntime;
732 }
733
734 /// Return a reference to the configured CUDA runtime.
736 assert(CUDARuntime != nullptr);
737 return *CUDARuntime;
738 }
739
740 /// Return a reference to the configured HLSL runtime.
742 assert(HLSLRuntime != nullptr);
743 return *HLSLRuntime;
744 }
745
747 assert(ObjCData != nullptr);
748 return *ObjCData;
749 }
750
751 // Version checking functions, used to implement ObjC's @available:
752 // i32 @__isOSVersionAtLeast(i32, i32, i32)
753 llvm::FunctionCallee IsOSVersionAtLeastFn = nullptr;
754 // i32 @__isPlatformVersionAtLeast(i32, i32, i32, i32)
755 llvm::FunctionCallee IsPlatformVersionAtLeastFn = nullptr;
756
757 InstrProfStats &getPGOStats() { return PGOStats; }
758 llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); }
759
761 return CoverageMapping.get();
762 }
763
764 llvm::Constant *getStaticLocalDeclAddress(const VarDecl *D) {
765 return StaticLocalDeclMap[D];
766 }
768 llvm::Constant *C) {
769 StaticLocalDeclMap[D] = C;
770 }
771
772 llvm::Constant *
774 llvm::GlobalValue::LinkageTypes Linkage);
775
776 llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) {
777 return StaticLocalDeclGuardMap[D];
778 }
780 llvm::GlobalVariable *C) {
781 StaticLocalDeclGuardMap[D] = C;
782 }
783
784 Address createUnnamedGlobalFrom(const VarDecl &D, llvm::Constant *Constant,
785 CharUnits Align);
786
787 bool lookupRepresentativeDecl(StringRef MangledName,
788 GlobalDecl &Result) const;
789
791 return AtomicSetterHelperFnMap[Ty];
792 }
794 llvm::Constant *Fn) {
795 AtomicSetterHelperFnMap[Ty] = Fn;
796 }
797
799 return AtomicGetterHelperFnMap[Ty];
800 }
802 llvm::Constant *Fn) {
803 AtomicGetterHelperFnMap[Ty] = Fn;
804 }
805
806 llvm::Constant *getTypeDescriptorFromMap(QualType Ty) {
807 return TypeDescriptorMap[Ty];
808 }
809 void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C) {
810 TypeDescriptorMap[Ty] = C;
811 }
812
813 CGDebugInfo *getModuleDebugInfo() { return DebugInfo.get(); }
814
816 if (!NoObjCARCExceptionsMetadata)
817 NoObjCARCExceptionsMetadata = llvm::MDNode::get(getLLVMContext(), {});
818 return NoObjCARCExceptionsMetadata;
819 }
820
821 ASTContext &getContext() const { return Context; }
822 const LangOptions &getLangOpts() const { return LangOpts; }
824 return FS;
825 }
827 const { return HeaderSearchOpts; }
829 const { return PreprocessorOpts; }
830 const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
831 llvm::Module &getModule() const { return TheModule; }
832 DiagnosticsEngine &getDiags() const { return Diags; }
833 const llvm::DataLayout &getDataLayout() const {
834 return TheModule.getDataLayout();
835 }
836 const TargetInfo &getTarget() const { return Target; }
837 const llvm::Triple &getTriple() const { return Target.getTriple(); }
838 bool supportsCOMDAT() const;
839 void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO);
840
841 const ABIInfo &getABIInfo();
842 CGCXXABI &getCXXABI() const { return *ABI; }
843 llvm::LLVMContext &getLLVMContext() { return VMContext; }
844
845 bool shouldUseTBAA() const { return TBAA != nullptr; }
846
848
849 CodeGenTypes &getTypes() { return *Types; }
850
851 CodeGenVTables &getVTables() { return VTables; }
852
854 return VTables.getItaniumVTableContext();
855 }
856
858 return VTables.getItaniumVTableContext();
859 }
860
862 return VTables.getMicrosoftVTableContext();
863 }
864
865 CtorList &getGlobalCtors() { return GlobalCtors; }
866 CtorList &getGlobalDtors() { return GlobalDtors; }
867
868 /// getTBAATypeInfo - Get metadata used to describe accesses to objects of
869 /// the given type.
870 llvm::MDNode *getTBAATypeInfo(QualType QTy);
871
872 /// getTBAAAccessInfo - Get TBAA information that describes an access to
873 /// an object of the given type.
875
876 /// getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an
877 /// access to a virtual table pointer.
878 TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType);
879
880 llvm::MDNode *getTBAAStructInfo(QualType QTy);
881
882 /// getTBAABaseTypeInfo - Get metadata that describes the given base access
883 /// type. Return null if the type is not suitable for use in TBAA access tags.
884 llvm::MDNode *getTBAABaseTypeInfo(QualType QTy);
885
886 /// getTBAAAccessTagInfo - Get TBAA tag for a given memory access.
887 llvm::MDNode *getTBAAAccessTagInfo(TBAAAccessInfo Info);
888
889 /// mergeTBAAInfoForCast - Get merged TBAA information for the purposes of
890 /// type casts.
893
894 /// mergeTBAAInfoForConditionalOperator - Get merged TBAA information for the
895 /// purposes of conditional operator.
897 TBAAAccessInfo InfoB);
898
899 /// mergeTBAAInfoForMemoryTransfer - Get merged TBAA information for the
900 /// purposes of memory transfer calls.
902 TBAAAccessInfo SrcInfo);
903
904 /// getTBAAInfoForSubobject - Get TBAA information for an access with a given
905 /// base lvalue.
907 if (Base.getTBAAInfo().isMayAlias())
909 return getTBAAAccessInfo(AccessType);
910 }
911
914
915 /// DecorateInstructionWithTBAA - Decorate the instruction with a TBAA tag.
916 void DecorateInstructionWithTBAA(llvm::Instruction *Inst,
917 TBAAAccessInfo TBAAInfo);
918
919 /// Adds !invariant.barrier !tag to instruction
920 void DecorateInstructionWithInvariantGroup(llvm::Instruction *I,
921 const CXXRecordDecl *RD);
922
923 /// Emit the given number of characters as a value of type size_t.
924 llvm::ConstantInt *getSize(CharUnits numChars);
925
926 /// Set the visibility for the given LLVM GlobalValue.
927 void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
928
929 void setDSOLocal(llvm::GlobalValue *GV) const;
930
933 (D->getLinkageAndVisibility().getVisibility() ==
937 D->getLinkageAndVisibility().isVisibilityExplicit()));
938 }
939 void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const;
940 void setDLLImportDLLExport(llvm::GlobalValue *GV, const NamedDecl *D) const;
941 /// Set visibility, dllimport/dllexport and dso_local.
942 /// This must be called after dllimport/dllexport is set.
943 void setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const;
944 void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;
945
946 void setGVPropertiesAux(llvm::GlobalValue *GV, const NamedDecl *D) const;
947
948 /// Set the TLS mode for the given LLVM GlobalValue for the thread-local
949 /// variable declaration D.
950 void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const;
951
952 /// Get LLVM TLS mode from CodeGenOptions.
953 llvm::GlobalVariable::ThreadLocalMode GetDefaultLLVMTLSModel() const;
954
955 static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V) {
956 switch (V) {
957 case DefaultVisibility: return llvm::GlobalValue::DefaultVisibility;
958 case HiddenVisibility: return llvm::GlobalValue::HiddenVisibility;
959 case ProtectedVisibility: return llvm::GlobalValue::ProtectedVisibility;
960 }
961 llvm_unreachable("unknown visibility!");
962 }
963
964 llvm::Constant *GetAddrOfGlobal(GlobalDecl GD,
965 ForDefinition_t IsForDefinition
967
968 /// Will return a global variable of the given type. If a variable with a
969 /// different type already exists then a new variable with the right type
970 /// will be created and all uses of the old variable will be replaced with a
971 /// bitcast to the new variable.
972 llvm::GlobalVariable *
973 CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty,
974 llvm::GlobalValue::LinkageTypes Linkage,
975 llvm::Align Alignment);
976
977 llvm::Function *CreateGlobalInitOrCleanUpFunction(
978 llvm::FunctionType *ty, const Twine &name, const CGFunctionInfo &FI,
979 SourceLocation Loc = SourceLocation(), bool TLS = false,
980 llvm::GlobalVariable::LinkageTypes Linkage =
981 llvm::GlobalVariable::InternalLinkage);
982
983 /// Return the AST address space of the underlying global variable for D, as
984 /// determined by its declaration. Normally this is the same as the address
985 /// space of D's type, but in CUDA, address spaces are associated with
986 /// declarations, not types. If D is nullptr, return the default address
987 /// space for global variable.
988 ///
989 /// For languages without explicit address spaces, if D has default address
990 /// space, target-specific global or constant address space may be returned.
992
993 /// Return the AST address space of constant literal, which is used to emit
994 /// the constant literal as global variable in LLVM IR.
995 /// Note: This is not necessarily the address space of the constant literal
996 /// in AST. For address space agnostic language, e.g. C++, constant literal
997 /// in AST is always in default address space.
999
1000 /// Return the llvm::Constant for the address of the given global variable.
1001 /// If Ty is non-null and if the global doesn't exist, then it will be created
1002 /// with the specified type instead of whatever the normal requested type
1003 /// would be. If IsForDefinition is true, it is guaranteed that an actual
1004 /// global with type Ty will be returned, not conversion of a variable with
1005 /// the same mangled name but some other type.
1006 llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,
1007 llvm::Type *Ty = nullptr,
1008 ForDefinition_t IsForDefinition
1010
1011 /// Return the address of the given function. If Ty is non-null, then this
1012 /// function will use the specified type if it has to create it.
1013 llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = nullptr,
1014 bool ForVTable = false,
1015 bool DontDefer = false,
1016 ForDefinition_t IsForDefinition
1018
1019 // Return the function body address of the given function.
1020 llvm::Constant *GetFunctionStart(const ValueDecl *Decl);
1021
1022 /// Return a function pointer for a reference to the given function.
1023 /// This correctly handles weak references, but does not apply a
1024 /// pointer signature.
1025 llvm::Constant *getRawFunctionPointer(GlobalDecl GD,
1026 llvm::Type *Ty = nullptr);
1027
1028 /// Return the ABI-correct function pointer value for a reference
1029 /// to the given function. This will apply a pointer signature if
1030 /// necessary, caching the result for the given function.
1031 llvm::Constant *getFunctionPointer(GlobalDecl GD, llvm::Type *Ty = nullptr);
1032
1033 /// Return the ABI-correct function pointer value for a reference
1034 /// to the given function. This will apply a pointer signature if
1035 /// necessary.
1036 llvm::Constant *getFunctionPointer(llvm::Constant *Pointer,
1038
1039 llvm::Constant *getMemberFunctionPointer(const FunctionDecl *FD,
1040 llvm::Type *Ty = nullptr);
1041
1042 llvm::Constant *getMemberFunctionPointer(llvm::Constant *Pointer,
1043 QualType FT);
1044
1046
1048
1050
1052
1053 bool shouldSignPointer(const PointerAuthSchema &Schema);
1054 llvm::Constant *getConstantSignedPointer(llvm::Constant *Pointer,
1055 const PointerAuthSchema &Schema,
1056 llvm::Constant *StorageAddress,
1057 GlobalDecl SchemaDecl,
1058 QualType SchemaType);
1059
1060 llvm::Constant *
1061 getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key,
1062 llvm::Constant *StorageAddress,
1063 llvm::ConstantInt *OtherDiscriminator);
1064
1065 llvm::ConstantInt *
1067 GlobalDecl SchemaDecl, QualType SchemaType);
1068
1070 std::optional<CGPointerAuthInfo>
1072 const CXXRecordDecl *Record,
1073 llvm::Value *StorageAddress);
1074
1075 std::optional<PointerAuthQualifier>
1077
1079
1080 // Return whether RTTI information should be emitted for this target.
1081 bool shouldEmitRTTI(bool ForEH = false) {
1082 return (ForEH || getLangOpts().RTTI) &&
1083 (!getLangOpts().isTargetDevice() || !getTriple().isGPU());
1084 }
1085
1086 /// Get the address of the RTTI descriptor for the given type.
1087 llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
1088
1089 /// Get the address of a GUID.
1091
1092 /// Get the address of a UnnamedGlobalConstant
1095
1096 /// Get the address of a template parameter object.
1099
1100 /// Get the address of the thunk for the given global decl.
1101 llvm::Constant *GetAddrOfThunk(StringRef Name, llvm::Type *FnTy,
1102 GlobalDecl GD);
1103
1104 /// Get a reference to the target of VD.
1106
1107 /// Returns the assumed alignment of an opaque pointer to the given class.
1109
1110 /// Returns the minimum object size for an object of the given class type
1111 /// (or a class derived from it).
1113
1114 /// Returns the minimum object size for an object of the given type.
1116 if (CXXRecordDecl *RD = Ty->getAsCXXRecordDecl())
1117 return getMinimumClassObjectSize(RD);
1118 return getContext().getTypeSizeInChars(Ty);
1119 }
1120
1121 /// Returns the assumed alignment of a virtual base of a class.
1123 const CXXRecordDecl *Derived,
1124 const CXXRecordDecl *VBase);
1125
1126 /// Given a class pointer with an actual known alignment, and the
1127 /// expected alignment of an object at a dynamic offset w.r.t that
1128 /// pointer, return the alignment to assume at the offset.
1130 const CXXRecordDecl *Class,
1131 CharUnits ExpectedTargetAlign);
1132
1133 CharUnits
1137
1138 /// Returns the offset from a derived class to a class. Returns null if the
1139 /// offset is 0.
1140 llvm::Constant *
1144
1145 llvm::FoldingSet<BlockByrefHelpers> ByrefHelpersCache;
1146
1147 /// Fetches the global unique block count.
1148 int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; }
1149
1150 /// Fetches the type of a generic block descriptor.
1151 llvm::Type *getBlockDescriptorType();
1152
1153 /// The type of a generic block literal.
1154 llvm::Type *getGenericBlockLiteralType();
1155
1156 /// Gets the address of a block which requires no captures.
1157 llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name);
1158
1159 /// Returns the address of a block which requires no caputres, or null if
1160 /// we've yet to emit the block for BE.
1161 llvm::Constant *getAddrOfGlobalBlockIfEmitted(const BlockExpr *BE) {
1162 return EmittedGlobalBlocks.lookup(BE);
1163 }
1164
1165 /// Notes that BE's global block is available via Addr. Asserts that BE
1166 /// isn't already emitted.
1167 void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr);
1168
1169 /// Return a pointer to a constant CFString object for the given string.
1171
1172 /// Return a constant array for the given string.
1173 llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E);
1174
1175 /// Return a pointer to a constant array for the given string literal.
1178 StringRef Name = ".str");
1179
1180 /// Return a pointer to a constant array for the given ObjCEncodeExpr node.
1183
1184 /// Returns a pointer to a character array containing the literal and a
1185 /// terminating '\0' character. The result has pointer to array type.
1186 ///
1187 /// \param GlobalName If provided, the name to use for the global (if one is
1188 /// created).
1190 GetAddrOfConstantCString(const std::string &Str,
1191 const char *GlobalName = nullptr);
1192
1193 /// Returns a pointer to a constant global variable for the given file-scope
1194 /// compound literal expression.
1196
1197 /// If it's been emitted already, returns the GlobalVariable corresponding to
1198 /// a compound literal. Otherwise, returns null.
1199 llvm::GlobalVariable *
1201
1202 /// Notes that CLE's GlobalVariable is GV. Asserts that CLE isn't already
1203 /// emitted.
1205 llvm::GlobalVariable *GV);
1206
1207 /// Returns a pointer to a global variable representing a temporary
1208 /// with static or thread storage duration.
1210 const Expr *Inner);
1211
1212 /// Retrieve the record type that describes the state of an
1213 /// Objective-C fast enumeration loop (for..in).
1215
1216 // Produce code for this constructor/destructor. This method doesn't try
1217 // to apply any ABI rules about which other constructors/destructors
1218 // are needed or if they are alias to each other.
1219 llvm::Function *codegenCXXStructor(GlobalDecl GD);
1220
1221 /// Return the address of the constructor/destructor of the given type.
1222 llvm::Constant *
1224 llvm::FunctionType *FnType = nullptr,
1225 bool DontDefer = false,
1226 ForDefinition_t IsForDefinition = NotForDefinition) {
1227 return cast<llvm::Constant>(getAddrAndTypeOfCXXStructor(GD, FnInfo, FnType,
1228 DontDefer,
1229 IsForDefinition)
1230 .getCallee());
1231 }
1232
1233 llvm::FunctionCallee getAddrAndTypeOfCXXStructor(
1234 GlobalDecl GD, const CGFunctionInfo *FnInfo = nullptr,
1235 llvm::FunctionType *FnType = nullptr, bool DontDefer = false,
1236 ForDefinition_t IsForDefinition = NotForDefinition);
1237
1238 /// Given a builtin id for a function like "__builtin_fabsf", return a
1239 /// Function* for "fabsf".
1240 llvm::Constant *getBuiltinLibFunction(const FunctionDecl *FD,
1241 unsigned BuiltinID);
1242
1243 llvm::Function *getIntrinsic(unsigned IID, ArrayRef<llvm::Type *> Tys = {});
1244
1245 void AddCXXGlobalInit(llvm::Function *F) { CXXGlobalInits.push_back(F); }
1246
1247 /// Emit code for a single top level declaration.
1248 void EmitTopLevelDecl(Decl *D);
1249
1250 /// Stored a deferred empty coverage mapping for an unused
1251 /// and thus uninstrumented top level declaration.
1253
1254 /// Remove the deferred empty coverage mapping as this
1255 /// declaration is actually instrumented.
1256 void ClearUnusedCoverageMapping(const Decl *D);
1257
1258 /// Emit all the deferred coverage mappings
1259 /// for the uninstrumented functions.
1261
1262 /// Emit an alias for "main" if it has no arguments (needed for wasm).
1263 void EmitMainVoidAlias();
1264
1265 /// Tell the consumer that this variable has been instantiated.
1267
1268 /// If the declaration has internal linkage but is inside an
1269 /// extern "C" linkage specification, prepare to emit an alias for it
1270 /// to the expected name.
1271 template<typename SomeDecl>
1272 void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV);
1273
1274 /// Add a global to a list to be added to the llvm.used metadata.
1275 void addUsedGlobal(llvm::GlobalValue *GV);
1276
1277 /// Add a global to a list to be added to the llvm.compiler.used metadata.
1278 void addCompilerUsedGlobal(llvm::GlobalValue *GV);
1279
1280 /// Add a global to a list to be added to the llvm.compiler.used metadata.
1281 void addUsedOrCompilerUsedGlobal(llvm::GlobalValue *GV);
1282
1283 /// Add a destructor and object to add to the C++ global destructor function.
1284 void AddCXXDtorEntry(llvm::FunctionCallee DtorFn, llvm::Constant *Object) {
1285 CXXGlobalDtorsOrStermFinalizers.emplace_back(DtorFn.getFunctionType(),
1286 DtorFn.getCallee(), Object);
1287 }
1288
1289 /// Add an sterm finalizer to the C++ global cleanup function.
1290 void AddCXXStermFinalizerEntry(llvm::FunctionCallee DtorFn) {
1291 CXXGlobalDtorsOrStermFinalizers.emplace_back(DtorFn.getFunctionType(),
1292 DtorFn.getCallee(), nullptr);
1293 }
1294
1295 /// Add an sterm finalizer to its own llvm.global_dtors entry.
1296 void AddCXXStermFinalizerToGlobalDtor(llvm::Function *StermFinalizer,
1297 int Priority) {
1298 AddGlobalDtor(StermFinalizer, Priority);
1299 }
1300
1301 void AddCXXPrioritizedStermFinalizerEntry(llvm::Function *StermFinalizer,
1302 int Priority) {
1304 PrioritizedCXXStermFinalizers.size());
1305 PrioritizedCXXStermFinalizers.push_back(
1306 std::make_pair(Key, StermFinalizer));
1307 }
1308
1309 /// Create or return a runtime function declaration with the specified type
1310 /// and name. If \p AssumeConvergent is true, the call will have the
1311 /// convergent attribute added.
1312 ///
1313 /// For new code, please use the overload that takes a QualType; it sets
1314 /// function attributes more accurately.
1315 llvm::FunctionCallee
1316 CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name,
1317 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1318 bool Local = false, bool AssumeConvergent = false);
1319
1320 /// Create or return a runtime function declaration with the specified type
1321 /// and name. If \p AssumeConvergent is true, the call will have the
1322 /// convergent attribute added.
1323 llvm::FunctionCallee
1325 StringRef Name,
1326 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1327 bool Local = false, bool AssumeConvergent = false);
1328
1329 /// Create a new runtime global variable with the specified type and name.
1330 llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty,
1331 StringRef Name);
1332
1333 ///@name Custom Blocks Runtime Interfaces
1334 ///@{
1335
1336 llvm::Constant *getNSConcreteGlobalBlock();
1337 llvm::Constant *getNSConcreteStackBlock();
1338 llvm::FunctionCallee getBlockObjectAssign();
1339 llvm::FunctionCallee getBlockObjectDispose();
1340
1341 ///@}
1342
1343 llvm::Function *getLLVMLifetimeStartFn();
1344 llvm::Function *getLLVMLifetimeEndFn();
1345 llvm::Function *getLLVMFakeUseFn();
1346
1347 // Make sure that this type is translated.
1348 void UpdateCompletedType(const TagDecl *TD);
1349
1350 llvm::Constant *getMemberPointerConstant(const UnaryOperator *e);
1351
1352 /// Emit type info if type of an expression is a variably modified
1353 /// type. Also emit proper debug info for cast types.
1355 CodeGenFunction *CGF = nullptr);
1356
1357 /// Return the result of value-initializing the given type, i.e. a null
1358 /// expression of the given type. This is usually, but not always, an LLVM
1359 /// null constant.
1360 llvm::Constant *EmitNullConstant(QualType T);
1361
1362 /// Return a null constant appropriate for zero-initializing a base class with
1363 /// the given type. This is usually, but not always, an LLVM null constant.
1364 llvm::Constant *EmitNullConstantForBase(const CXXRecordDecl *Record);
1365
1366 /// Emit a general error that something can't be done.
1367 void Error(SourceLocation loc, StringRef error);
1368
1369 /// Print out an error that codegen doesn't support the specified stmt yet.
1370 void ErrorUnsupported(const Stmt *S, const char *Type);
1371
1372 /// Print out an error that codegen doesn't support the specified decl yet.
1373 void ErrorUnsupported(const Decl *D, const char *Type);
1374
1375 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
1376 /// guaranteed). Produces a warning if we're low on stack space and allocates
1377 /// more in that case. Use this in code that may recurse deeply to avoid stack
1378 /// overflow.
1380 llvm::function_ref<void()> Fn);
1381
1382 /// Set the attributes on the LLVM function for the given decl and function
1383 /// info. This applies attributes necessary for handling the ABI as well as
1384 /// user specified attributes like section.
1385 void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F,
1386 const CGFunctionInfo &FI);
1387
1388 /// Set the LLVM function attributes (sext, zext, etc).
1390 llvm::Function *F, bool IsThunk);
1391
1392 /// Set the LLVM function attributes which only apply to a function
1393 /// definition.
1394 void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F);
1395
1396 /// Set the LLVM function attributes that represent floating point
1397 /// environment.
1398 void setLLVMFunctionFEnvAttributes(const FunctionDecl *D, llvm::Function *F);
1399
1400 /// Return true iff the given type uses 'sret' when used as a return type.
1401 bool ReturnTypeUsesSRet(const CGFunctionInfo &FI);
1402
1403 /// Return true iff the given type has `inreg` set.
1404 bool ReturnTypeHasInReg(const CGFunctionInfo &FI);
1405
1406 /// Return true iff the given type uses an argument slot when 'sret' is used
1407 /// as a return type.
1409
1410 /// Return true iff the given type uses 'fpret' when used as a return type.
1411 bool ReturnTypeUsesFPRet(QualType ResultType);
1412
1413 /// Return true iff the given type uses 'fp2ret' when used as a return type.
1414 bool ReturnTypeUsesFP2Ret(QualType ResultType);
1415
1416 /// Get the LLVM attributes and calling convention to use for a particular
1417 /// function type.
1418 ///
1419 /// \param Name - The function name.
1420 /// \param Info - The function type information.
1421 /// \param CalleeInfo - The callee information these attributes are being
1422 /// constructed for. If valid, the attributes applied to this decl may
1423 /// contribute to the function attributes and calling convention.
1424 /// \param Attrs [out] - On return, the attribute list to use.
1425 /// \param CallingConv [out] - On return, the LLVM calling convention to use.
1426 void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info,
1427 CGCalleeInfo CalleeInfo,
1428 llvm::AttributeList &Attrs, unsigned &CallingConv,
1429 bool AttrOnCallSite, bool IsThunk);
1430
1431 /// Adjust Memory attribute to ensure that the BE gets the right attribute
1432 // in order to generate the library call or the intrinsic for the function
1433 // name 'Name'.
1434 void AdjustMemoryAttribute(StringRef Name, CGCalleeInfo CalleeInfo,
1435 llvm::AttributeList &Attrs);
1436
1437 /// Like the overload taking a `Function &`, but intended specifically
1438 /// for frontends that want to build on Clang's target-configuration logic.
1439 void addDefaultFunctionDefinitionAttributes(llvm::AttrBuilder &attrs);
1440
1441 StringRef getMangledName(GlobalDecl GD);
1442 StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD);
1443 const GlobalDecl getMangledNameDecl(StringRef);
1444
1445 void EmitTentativeDefinition(const VarDecl *D);
1446
1448
1450
1452
1453 /// Appends Opts to the "llvm.linker.options" metadata value.
1454 void AppendLinkerOptions(StringRef Opts);
1455
1456 /// Appends a detect mismatch command to the linker options.
1457 void AddDetectMismatch(StringRef Name, StringRef Value);
1458
1459 /// Appends a dependent lib to the appropriate metadata value.
1460 void AddDependentLib(StringRef Lib);
1461
1462
1463 llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD);
1464
1465 void setFunctionLinkage(GlobalDecl GD, llvm::Function *F) {
1466 F->setLinkage(getFunctionLinkage(GD));
1467 }
1468
1469 /// Return the appropriate linkage for the vtable, VTT, and type information
1470 /// of the given class.
1471 llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD);
1472
1473 /// Return the store size, in character units, of the given LLVM type.
1474 CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const;
1475
1476 /// Returns LLVM linkage for a declarator.
1477 llvm::GlobalValue::LinkageTypes
1479
1480 /// Returns LLVM linkage for a declarator.
1481 llvm::GlobalValue::LinkageTypes
1483
1484 /// Emit all the global annotations.
1485 void EmitGlobalAnnotations();
1486
1487 /// Emit an annotation string.
1488 llvm::Constant *EmitAnnotationString(StringRef Str);
1489
1490 /// Emit the annotation's translation unit.
1491 llvm::Constant *EmitAnnotationUnit(SourceLocation Loc);
1492
1493 /// Emit the annotation line number.
1494 llvm::Constant *EmitAnnotationLineNo(SourceLocation L);
1495
1496 /// Emit additional args of the annotation.
1497 llvm::Constant *EmitAnnotationArgs(const AnnotateAttr *Attr);
1498
1499 /// Generate the llvm::ConstantStruct which contains the annotation
1500 /// information for a given GlobalValue. The annotation struct is
1501 /// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the
1502 /// GlobalValue being annotated. The second field is the constant string
1503 /// created from the AnnotateAttr's annotation. The third field is a constant
1504 /// string containing the name of the translation unit. The fourth field is
1505 /// the line number in the file of the annotated value declaration.
1506 llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV,
1507 const AnnotateAttr *AA,
1508 SourceLocation L);
1509
1510 /// Add global annotations that are set on D, for the global GV. Those
1511 /// annotations are emitted during finalization of the LLVM code.
1512 void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV);
1513
1514 bool isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn,
1515 SourceLocation Loc) const;
1516
1517 bool isInNoSanitizeList(SanitizerMask Kind, llvm::GlobalVariable *GV,
1519 StringRef Category = StringRef()) const;
1520
1521 /// Imbue XRay attributes to a function, applying the always/never attribute
1522 /// lists in the process. Returns true if we did imbue attributes this way,
1523 /// false otherwise.
1524 bool imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc,
1525 StringRef Category = StringRef()) const;
1526
1527 /// \returns true if \p Fn at \p Loc should be excluded from profile
1528 /// instrumentation by the SCL passed by \p -fprofile-list.
1530 isFunctionBlockedByProfileList(llvm::Function *Fn, SourceLocation Loc) const;
1531
1532 /// \returns true if \p Fn at \p Loc should be excluded from profile
1533 /// instrumentation.
1535 isFunctionBlockedFromProfileInstr(llvm::Function *Fn,
1536 SourceLocation Loc) const;
1537
1539 return SanitizerMD.get();
1540 }
1541
1543 DeferredVTables.push_back(RD);
1544 }
1545
1546 /// Emit code for a single global function or var decl. Forward declarations
1547 /// are emitted lazily.
1548 void EmitGlobal(GlobalDecl D);
1549
1551
1552 llvm::GlobalValue *GetGlobalValue(StringRef Ref);
1553
1554 /// Set attributes which are common to any form of a global definition (alias,
1555 /// Objective-C method, function, global variable).
1556 ///
1557 /// NOTE: This should only be called for definitions.
1558 void SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV);
1559
1560 void addReplacement(StringRef Name, llvm::Constant *C);
1561
1562 void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C);
1563
1564 /// Emit a code for threadprivate directive.
1565 /// \param D Threadprivate declaration.
1567
1568 /// Emit a code for declare reduction construct.
1570 CodeGenFunction *CGF = nullptr);
1571
1572 /// Emit a code for declare mapper construct.
1574 CodeGenFunction *CGF = nullptr);
1575
1576 // Emit code for the OpenACC Declare declaration.
1578 CodeGenFunction *CGF = nullptr);
1579 // Emit code for the OpenACC Routine declaration.
1581 CodeGenFunction *CGF = nullptr);
1582
1583 /// Emit a code for requires directive.
1584 /// \param D Requires declaration
1586
1587 /// Emit a code for the allocate directive.
1588 /// \param D The allocate declaration
1590
1591 /// Return the alignment specified in an allocate directive, if present.
1592 std::optional<CharUnits> getOMPAllocateAlignment(const VarDecl *VD);
1593
1594 /// Returns whether the given record has hidden LTO visibility and therefore
1595 /// may participate in (single-module) CFI and whole-program vtable
1596 /// optimization.
1597 bool HasHiddenLTOVisibility(const CXXRecordDecl *RD);
1598
1599 /// Returns whether the given record has public LTO visibility (regardless of
1600 /// -lto-whole-program-visibility) and therefore may not participate in
1601 /// (single-module) CFI and whole-program vtable optimization.
1603
1604 /// Returns the vcall visibility of the given type. This is the scope in which
1605 /// a virtual function call could be made which ends up being dispatched to a
1606 /// member function of this class. This scope can be wider than the visibility
1607 /// of the class itself when the class has a more-visible dynamic base class.
1608 /// The client should pass in an empty Visited set, which is used to prevent
1609 /// redundant recursive processing.
1610 llvm::GlobalObject::VCallVisibility
1612 llvm::DenseSet<const CXXRecordDecl *> &Visited);
1613
1614 /// Emit type metadata for the given vtable using the given layout.
1616 llvm::GlobalVariable *VTable,
1617 const VTableLayout &VTLayout);
1618
1619 llvm::Type *getVTableComponentType() const;
1620
1621 /// Generate a cross-DSO type identifier for MD.
1622 llvm::ConstantInt *CreateCrossDsoCfiTypeId(llvm::Metadata *MD);
1623
1624 /// Generate a KCFI type identifier for T.
1625 llvm::ConstantInt *CreateKCFITypeId(QualType T, StringRef Salt);
1626
1627 /// Create a metadata identifier for the given type. This may either be an
1628 /// MDString (for external identifiers) or a distinct unnamed MDNode (for
1629 /// internal identifiers).
1631
1632 /// Create a metadata identifier that is intended to be used to check virtual
1633 /// calls via a member function pointer.
1635
1636 /// Create a metadata identifier for the generalization of the given type.
1637 /// This may either be an MDString (for external identifiers) or a distinct
1638 /// unnamed MDNode (for internal identifiers).
1640
1641 /// Create and attach type metadata to the given function.
1643 llvm::Function *F);
1644
1645 /// Set type metadata to the given function.
1646 void setKCFIType(const FunctionDecl *FD, llvm::Function *F);
1647
1648 /// Emit KCFI type identifier constants and remove unused identifiers.
1649 void finalizeKCFITypes();
1650
1651 /// Whether this function's return type has no side effects, and thus may
1652 /// be trivially discarded if it is unused.
1653 bool MayDropFunctionReturn(const ASTContext &Context,
1654 QualType ReturnType) const;
1655
1656 /// Returns whether this module needs the "all-vtables" type identifier.
1657 bool NeedAllVtablesTypeId() const;
1658
1659 /// Create and attach type metadata for the given vtable.
1660 void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset,
1661 const CXXRecordDecl *RD);
1662
1663 /// Return a vector of most-base classes for RD. This is used to implement
1664 /// control flow integrity checks for member function pointers.
1665 ///
1666 /// A most-base class of a class C is defined as a recursive base class of C,
1667 /// including C itself, that does not have any bases.
1670
1671 /// Get the declaration of std::terminate for the platform.
1672 llvm::FunctionCallee getTerminateFn();
1673
1674 llvm::SanitizerStatReport &getSanStats();
1675
1676 llvm::Value *
1678
1679 /// OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument
1680 /// information in the program executable. The argument information stored
1681 /// includes the argument name, its type, the address and access qualifiers
1682 /// used. This helper can be used to generate metadata for source code kernel
1683 /// function as well as generated implicitly kernels. If a kernel is generated
1684 /// implicitly null value has to be passed to the last two parameters,
1685 /// otherwise all parameters must have valid non-null values.
1686 /// \param FN is a pointer to IR function being generated.
1687 /// \param FD is a pointer to function declaration if any.
1688 /// \param CGF is a pointer to CodeGenFunction that generates this function.
1689 void GenKernelArgMetadata(llvm::Function *FN,
1690 const FunctionDecl *FD = nullptr,
1691 CodeGenFunction *CGF = nullptr);
1692
1693 /// Get target specific null pointer.
1694 /// \param T is the LLVM type of the null pointer.
1695 /// \param QT is the clang QualType of the null pointer.
1696 llvm::Constant *getNullPointer(llvm::PointerType *T, QualType QT);
1697
1699 LValueBaseInfo *BaseInfo = nullptr,
1700 TBAAAccessInfo *TBAAInfo = nullptr,
1701 bool forPointeeType = false);
1703 LValueBaseInfo *BaseInfo = nullptr,
1704 TBAAAccessInfo *TBAAInfo = nullptr);
1705 bool stopAutoInit();
1706
1707 /// Print the postfix for externalized static variable or kernels for single
1708 /// source offloading languages CUDA and HIP. The unique postfix is created
1709 /// using either the CUID argument, or the file's UniqueID and active macros.
1710 /// The fallback method without a CUID requires that the offloading toolchain
1711 /// does not define separate macros via the -cc1 options.
1712 void printPostfixForExternalizedDecl(llvm::raw_ostream &OS,
1713 const Decl *D) const;
1714
1715 /// Move some lazily-emitted states to the NewBuilder. This is especially
1716 /// essential for the incremental parsing environment like Clang Interpreter,
1717 /// because we'll lose all important information after each repl.
1718 void moveLazyEmissionStates(CodeGenModule *NewBuilder);
1719
1720 /// Emit the IR encoding to attach the CUDA launch bounds attribute to \p F.
1721 /// If \p MaxThreadsVal is not nullptr, the max threads value is stored in it,
1722 /// if a valid one was found.
1723 void handleCUDALaunchBoundsAttr(llvm::Function *F,
1724 const CUDALaunchBoundsAttr *A,
1725 int32_t *MaxThreadsVal = nullptr,
1726 int32_t *MinBlocksVal = nullptr,
1727 int32_t *MaxClusterRankVal = nullptr);
1728
1729 /// Emit the IR encoding to attach the AMD GPU flat-work-group-size attribute
1730 /// to \p F. Alternatively, the work group size can be taken from a \p
1731 /// ReqdWGS. If \p MinThreadsVal is not nullptr, the min threads value is
1732 /// stored in it, if a valid one was found. If \p MaxThreadsVal is not
1733 /// nullptr, the max threads value is stored in it, if a valid one was found.
1735 llvm::Function *F, const AMDGPUFlatWorkGroupSizeAttr *A,
1736 const ReqdWorkGroupSizeAttr *ReqdWGS = nullptr,
1737 int32_t *MinThreadsVal = nullptr, int32_t *MaxThreadsVal = nullptr);
1738
1739 /// Emit the IR encoding to attach the AMD GPU waves-per-eu attribute to \p F.
1740 void handleAMDGPUWavesPerEUAttr(llvm::Function *F,
1741 const AMDGPUWavesPerEUAttr *A);
1742
1743 llvm::Constant *
1744 GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty, LangAS AddrSpace,
1745 const VarDecl *D,
1746 ForDefinition_t IsForDefinition = NotForDefinition);
1747
1748 // FIXME: Hardcoding priority here is gross.
1749 void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535,
1750 unsigned LexOrder = ~0U,
1751 llvm::Constant *AssociatedData = nullptr);
1752 void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535,
1753 bool IsDtorAttrFunc = false);
1754
1755 // Return whether structured convergence intrinsics should be generated for
1756 // this target.
1758 // TODO: this should probably become unconditional once the controlled
1759 // convergence becomes the norm.
1760 return getTriple().isSPIRVLogical();
1761 }
1762
1764 std::pair<const FunctionDecl *, SourceLocation> Global) {
1765 MustTailCallUndefinedGlobals.insert(Global);
1766 }
1767
1769 // In C23 (N3096) $6.7.10:
1770 // """
1771 // If any object is initialized with an empty iniitializer, then it is
1772 // subject to default initialization:
1773 // - if it is an aggregate, every member is initialized (recursively)
1774 // according to these rules, and any padding is initialized to zero bits;
1775 // - if it is a union, the first named member is initialized (recursively)
1776 // according to these rules, and any padding is initialized to zero bits.
1777 //
1778 // If the aggregate or union contains elements or members that are
1779 // aggregates or unions, these rules apply recursively to the subaggregates
1780 // or contained unions.
1781 //
1782 // If there are fewer initializers in a brace-enclosed list than there are
1783 // elements or members of an aggregate, or fewer characters in a string
1784 // literal used to initialize an array of known size than there are elements
1785 // in the array, the remainder of the aggregate is subject to default
1786 // initialization.
1787 // """
1788 //
1789 // From my understanding, the standard is ambiguous in the following two
1790 // areas:
1791 // 1. For a union type with empty initializer, if the first named member is
1792 // not the largest member, then the bytes comes after the first named member
1793 // but before padding are left unspecified. An example is:
1794 // union U { int a; long long b;};
1795 // union U u = {}; // The first 4 bytes are 0, but 4-8 bytes are left
1796 // unspecified.
1797 //
1798 // 2. It only mentions padding for empty initializer, but doesn't mention
1799 // padding for a non empty initialization list. And if the aggregation or
1800 // union contains elements or members that are aggregates or unions, and
1801 // some are non empty initializers, while others are empty initiailizers,
1802 // the padding initialization is unclear. An example is:
1803 // struct S1 { int a; long long b; };
1804 // struct S2 { char c; struct S1 s1; };
1805 // // The values for paddings between s2.c and s2.s1.a, between s2.s1.a
1806 // and s2.s1.b are unclear.
1807 // struct S2 s2 = { 'c' };
1808 //
1809 // Here we choose to zero initiailize left bytes of a union type. Because
1810 // projects like the Linux kernel are relying on this behavior. If we don't
1811 // explicitly zero initialize them, the undef values can be optimized to
1812 // return gabage data. We also choose to zero initialize paddings for
1813 // aggregates and unions, no matter they are initialized by empty
1814 // initializers or non empty initializers. This can provide a consistent
1815 // behavior. So projects like the Linux kernel can rely on it.
1816 return !getLangOpts().CPlusPlus;
1817 }
1818
1819 // Helper to get the alignment for a variable.
1820 unsigned getVtableGlobalVarAlignment(const VarDecl *D = nullptr) {
1822 unsigned PAlign = getItaniumVTableContext().isRelativeLayout()
1823 ? 32
1824 : getTarget().getPointerAlign(AS);
1825 return PAlign;
1826 }
1827
1828 /// Helper function to construct a TrapReasonBuilder
1830 return TrapReasonBuilder(&getDiags(), DiagID, TR);
1831 }
1832
1833private:
1834 bool shouldDropDLLAttribute(const Decl *D, const llvm::GlobalValue *GV) const;
1835
1836 llvm::Constant *GetOrCreateLLVMFunction(
1837 StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,
1838 bool DontDefer = false, bool IsThunk = false,
1839 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1840 ForDefinition_t IsForDefinition = NotForDefinition);
1841
1842 // Adds a declaration to the list of multi version functions if not present.
1843 void AddDeferredMultiVersionResolverToEmit(GlobalDecl GD);
1844
1845 // References to multiversion functions are resolved through an implicitly
1846 // defined resolver function. This function is responsible for creating
1847 // the resolver symbol for the provided declaration. The value returned
1848 // will be for an ifunc (llvm::GlobalIFunc) if the current target supports
1849 // that feature and for a regular function (llvm::GlobalValue) otherwise.
1850 llvm::Constant *GetOrCreateMultiVersionResolver(GlobalDecl GD);
1851
1852 // In scenarios where a function is not known to be a multiversion function
1853 // until a later declaration, it is sometimes necessary to change the
1854 // previously created mangled name to align with requirements of whatever
1855 // multiversion function kind the function is now known to be. This function
1856 // is responsible for performing such mangled name updates.
1857 void UpdateMultiVersionNames(GlobalDecl GD, const FunctionDecl *FD,
1858 StringRef &CurName);
1859
1860 bool GetCPUAndFeaturesAttributes(GlobalDecl GD,
1861 llvm::AttrBuilder &AttrBuilder,
1862 bool SetTargetFeatures = true);
1863 void setNonAliasAttributes(GlobalDecl GD, llvm::GlobalObject *GO);
1864
1865 /// Set function attributes for a function declaration.
1866 void SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
1867 bool IsIncompleteFunction, bool IsThunk);
1868
1869 void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = nullptr);
1870
1871 void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
1872 void EmitMultiVersionFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
1873
1874 void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false);
1875 void EmitAliasDefinition(GlobalDecl GD);
1876 void emitIFuncDefinition(GlobalDecl GD);
1877 void emitCPUDispatchDefinition(GlobalDecl GD);
1878 void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
1879 void EmitObjCIvarInitializations(ObjCImplementationDecl *D);
1880
1881 // C++ related functions.
1882
1883 void EmitDeclContext(const DeclContext *DC);
1884 void EmitLinkageSpec(const LinkageSpecDecl *D);
1885 void EmitTopLevelStmt(const TopLevelStmtDecl *D);
1886
1887 /// Emit the function that initializes C++ thread_local variables.
1888 void EmitCXXThreadLocalInitFunc();
1889
1890 /// Emit the function that initializes global variables for a C++ Module.
1891 void EmitCXXModuleInitFunc(clang::Module *Primary);
1892
1893 /// Emit the function that initializes C++ globals.
1894 void EmitCXXGlobalInitFunc();
1895
1896 /// Emit the function that performs cleanup associated with C++ globals.
1897 void EmitCXXGlobalCleanUpFunc();
1898
1899 /// Emit the function that initializes the specified global (if PerformInit is
1900 /// true) and registers its destructor.
1901 void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
1902 llvm::GlobalVariable *Addr,
1903 bool PerformInit);
1904
1905 void EmitPointerToInitFunc(const VarDecl *VD, llvm::GlobalVariable *Addr,
1906 llvm::Function *InitFunc, InitSegAttr *ISA);
1907
1908 /// EmitCtorList - Generates a global array of functions and priorities using
1909 /// the given list and name. This array will have appending linkage and is
1910 /// suitable for use as a LLVM constructor or destructor array. Clears Fns.
1911 void EmitCtorList(CtorList &Fns, const char *GlobalName);
1912
1913 /// Emit any needed decls for which code generation was deferred.
1914 void EmitDeferred();
1915
1916 /// Try to emit external vtables as available_externally if they have emitted
1917 /// all inlined virtual functions. It runs after EmitDeferred() and therefore
1918 /// is not allowed to create new references to things that need to be emitted
1919 /// lazily.
1920 void EmitVTablesOpportunistically();
1921
1922 /// Call replaceAllUsesWith on all pairs in Replacements.
1923 void applyReplacements();
1924
1925 /// Call replaceAllUsesWith on all pairs in GlobalValReplacements.
1926 void applyGlobalValReplacements();
1927
1928 void checkAliases();
1929
1930 std::map<int, llvm::TinyPtrVector<llvm::Function *>> DtorsUsingAtExit;
1931
1932 /// Register functions annotated with __attribute__((destructor)) using
1933 /// __cxa_atexit, if it is available, or atexit otherwise.
1934 void registerGlobalDtorsWithAtExit();
1935
1936 // When using sinit and sterm functions, unregister
1937 // __attribute__((destructor)) annotated functions which were previously
1938 // registered by the atexit subroutine using unatexit.
1939 void unregisterGlobalDtorsWithUnAtExit();
1940
1941 /// Emit deferred multiversion function resolvers and associated variants.
1942 void emitMultiVersionFunctions();
1943
1944 /// Emit any vtables which we deferred and still have a use for.
1945 void EmitDeferredVTables();
1946
1947 /// Emit a dummy function that reference a CoreFoundation symbol when
1948 /// @available is used on Darwin.
1949 void emitAtAvailableLinkGuard();
1950
1951 /// Emit the llvm.used and llvm.compiler.used metadata.
1952 void emitLLVMUsed();
1953
1954 /// For C++20 Itanium ABI, emit the initializers for the module.
1955 void EmitModuleInitializers(clang::Module *Primary);
1956
1957 /// Emit the link options introduced by imported modules.
1958 void EmitModuleLinkOptions();
1959
1960 /// Helper function for EmitStaticExternCAliases() to redirect ifuncs that
1961 /// have a resolver name that matches 'Elem' to instead resolve to the name of
1962 /// 'CppFunc'. This redirection is necessary in cases where 'Elem' has a name
1963 /// that will be emitted as an alias of the name bound to 'CppFunc'; ifuncs
1964 /// may not reference aliases. Redirection is only performed if 'Elem' is only
1965 /// used by ifuncs in which case, 'Elem' is destroyed. 'true' is returned if
1966 /// redirection is successful, and 'false' is returned otherwise.
1967 bool CheckAndReplaceExternCIFuncs(llvm::GlobalValue *Elem,
1968 llvm::GlobalValue *CppFunc);
1969
1970 /// Emit aliases for internal-linkage declarations inside "C" language
1971 /// linkage specifications, giving them the "expected" name where possible.
1972 void EmitStaticExternCAliases();
1973
1974 void EmitDeclMetadata();
1975
1976 /// Emit the Clang version as llvm.ident metadata.
1977 void EmitVersionIdentMetadata();
1978
1979 /// Emit the Clang commandline as llvm.commandline metadata.
1980 void EmitCommandLineMetadata();
1981
1982 /// Emit the module flag metadata used to pass options controlling the
1983 /// the backend to LLVM.
1984 void EmitBackendOptionsMetadata(const CodeGenOptions &CodeGenOpts);
1985
1986 /// Emits OpenCL specific Metadata e.g. OpenCL version.
1987 void EmitOpenCLMetadata();
1988
1989 /// Emit the llvm.gcov metadata used to tell LLVM where to emit the .gcno and
1990 /// .gcda files in a way that persists in .bc files.
1991 void EmitCoverageFile();
1992
1993 /// Given a sycl_kernel_entry_point attributed function, emit the
1994 /// corresponding SYCL kernel caller offload entry point function.
1995 void EmitSYCLKernelCaller(const FunctionDecl *KernelEntryPointFn,
1996 ASTContext &Ctx);
1997
1998 /// Determine whether the definition must be emitted; if this returns \c
1999 /// false, the definition can be emitted lazily if it's used.
2000 bool MustBeEmitted(const ValueDecl *D);
2001
2002 /// Determine whether the definition can be emitted eagerly, or should be
2003 /// delayed until the end of the translation unit. This is relevant for
2004 /// definitions whose linkage can change, e.g. implicit function instantions
2005 /// which may later be explicitly instantiated.
2006 bool MayBeEmittedEagerly(const ValueDecl *D);
2007
2008 /// Check whether we can use a "simpler", more core exceptions personality
2009 /// function.
2010 void SimplifyPersonality();
2011
2012 /// Helper function for getDefaultFunctionAttributes. Builds a set of function
2013 /// attributes which can be simply added to a function.
2014 void getTrivialDefaultFunctionAttributes(StringRef Name, bool HasOptnone,
2015 bool AttrOnCallSite,
2016 llvm::AttrBuilder &FuncAttrs);
2017
2018 /// Helper function for ConstructAttributeList and
2019 /// addDefaultFunctionDefinitionAttributes. Builds a set of function
2020 /// attributes to add to a function with the given properties.
2021 void getDefaultFunctionAttributes(StringRef Name, bool HasOptnone,
2022 bool AttrOnCallSite,
2023 llvm::AttrBuilder &FuncAttrs);
2024
2025 llvm::Metadata *CreateMetadataIdentifierImpl(QualType T, MetadataTypeMap &Map,
2026 StringRef Suffix);
2027};
2028
2029} // end namespace CodeGen
2030} // end namespace clang
2031
2032#endif // LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
Enums/classes describing ABI related information about constructors, destructors and thunks.
#define V(N, I)
Definition: ASTContext.h:3597
const Decl * D
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
Expr * E
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
int Priority
Definition: Format.cpp:3181
int Category
Definition: Format.cpp:3180
llvm::DenseSet< const void * > Visited
Definition: HTMLLogger.cpp:145
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
Definition: MachO.h:51
llvm::MachO::Record Record
Definition: MachO.h:31
SourceLocation Loc
Definition: SemaObjC.cpp:754
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:188
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Attr - This represents one attribute.
Definition: Attr.h:44
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4634
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:6560
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:3679
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:185
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
ABIInfo - Target specific hooks for defining how a type should be passed or returned from functions.
Definition: ABIInfo.h:48
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Definition: Address.h:128
A pair of helper functions for a __block variable.
void Profile(llvm::FoldingSetNodeID &id) const
virtual void emitCopy(CodeGenFunction &CGF, Address dest, Address src)=0
BlockByrefHelpers(CharUnits alignment)
virtual bool needsCopy() const
CharUnits Alignment
The alignment of the field.
virtual void emitDispose(CodeGenFunction &CGF, Address field)=0
BlockByrefHelpers(const BlockByrefHelpers &)=default
virtual bool needsDispose() const
virtual void profileImpl(llvm::FoldingSetNodeID &id) const =0
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:43
Abstract information about a function or function prototype.
Definition: CGCall.h:41
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition: CGDebugInfo.h:59
CGFunctionInfo - Class to encapsulate the information about a function definition.
Implements runtime-specific code generation functions.
Definition: CGObjCRuntime.h:65
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD)
llvm::FunctionCallee getBlockObjectAssign()
Definition: CGBlocks.cpp:2938
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:1311
void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
void setDSOLocal(llvm::GlobalValue *GV) const
llvm::GlobalObject::VCallVisibility GetVCallVisibilityLevel(const CXXRecordDecl *RD, llvm::DenseSet< const CXXRecordDecl * > &Visited)
Returns the vcall visibility of the given type.
Definition: CGVTables.cpp:1324
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.
CGDebugInfo * getModuleDebugInfo()
ConstantAddress GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *E)
Returns a pointer to a constant global variable for the given file-scope compound literal expression.
void setLLVMFunctionFEnvAttributes(const FunctionDecl *D, llvm::Function *F)
Set the LLVM function attributes that represent floating point environment.
bool NeedAllVtablesTypeId() const
Returns whether this module needs the "all-vtables" type identifier.
void addCompilerUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.compiler.used metadata.
CodeGenVTables & getVTables()
llvm::ConstantInt * CreateCrossDsoCfiTypeId(llvm::Metadata *MD)
Generate a cross-DSO type identifier for MD.
void setStaticLocalDeclAddress(const VarDecl *D, llvm::Constant *C)
llvm::Constant * EmitNullConstantForBase(const CXXRecordDecl *Record)
Return a null constant appropriate for zero-initializing a base class with the given type.
llvm::Function * getLLVMLifetimeStartFn()
Lazily declare the @llvm.lifetime.start intrinsic.
Definition: CGDecl.cpp:2607
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:737
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:3096
llvm::FunctionCallee getAddrAndTypeOfCXXStructor(GlobalDecl GD, const CGFunctionInfo *FnInfo=nullptr, llvm::FunctionType *FnType=nullptr, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
Definition: CGCXX.cpp:217
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:1130
void setGVPropertiesAux(llvm::GlobalValue *GV, const NamedDecl *D) const
llvm::Constant * getFunctionPointer(GlobalDecl GD, llvm::Type *Ty=nullptr)
Return the ABI-correct function pointer value for a reference to the given function.
const IntrusiveRefCntPtr< llvm::vfs::FileSystem > & getFileSystem() const
void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr)
Notes that BE's global block is available via Addr.
Definition: CGBlocks.cpp:1275
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".
Definition: CGBuiltin.cpp:176
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:2880
llvm::GlobalValue::LinkageTypes getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage)
Returns LLVM linkage for a declarator.
TBAAAccessInfo mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo, TBAAAccessInfo SrcInfo)
mergeTBAAInfoForMemoryTransfer - Get merged TBAA information for the purposes of memory transfer call...
llvm::Type * getBlockDescriptorType()
Fetches the type of a generic block descriptor.
Definition: CGBlocks.cpp:1124
llvm::Constant * GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name)
Gets the address of a block which requires no captures.
Definition: CGBlocks.cpp:1283
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:2625
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:706
void AppendLinkerOptions(StringRef Opts)
Appends Opts to the "llvm.linker.options" metadata value.
bool hasObjCRuntime()
Return true iff an Objective-C runtime has been configured.
void EmitExternalDeclaration(const DeclaratorDecl *D)
void AddDependentLib(StringRef Lib)
Appends a dependent lib to the appropriate metadata value.
void Release()
Finalize LLVM code generation.
llvm::FunctionCallee IsOSVersionAtLeastFn
ProfileList::ExclusionType isFunctionBlockedByProfileList(llvm::Function *Fn, SourceLocation Loc) const
CGPointerAuthInfo getPointerAuthInfoForPointeeType(QualType type)
llvm::MDNode * getTBAABaseTypeInfo(QualType QTy)
getTBAABaseTypeInfo - Get metadata that describes the given base access type.
CGPointerAuthInfo EmitPointerAuthInfo(const RecordDecl *RD)
void EmitVTableTypeMetadata(const CXXRecordDecl *RD, llvm::GlobalVariable *VTable, const VTableLayout &VTLayout)
Emit type metadata for the given vtable using the given layout.
Definition: CGVTables.cpp:1358
bool lookupRepresentativeDecl(StringRef MangledName, GlobalDecl &Result) const
void EmitOMPAllocateDecl(const OMPAllocateDecl *D)
Emit a code for the allocate directive.
Definition: CGDecl.cpp:2894
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...
Definition: CGVTables.cpp:1312
const llvm::DataLayout & getDataLayout() const
llvm::Constant * getNSConcreteGlobalBlock()
Definition: CGBlocks.cpp:2950
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
TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType)
getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an access to a virtual table poi...
bool shouldEmitConvergenceTokens() const
CGCXXABI & getCXXABI() const
ConstantAddress GetWeakRefReference(const ValueDecl *VD)
Get a reference to the target of VD.
CGPointerAuthInfo getFunctionPointerAuthInfo(QualType T)
Return the abstract pointer authentication schema for a pointer to the given function type.
CharUnits getVBaseAlignment(CharUnits DerivedAlign, const CXXRecordDecl *Derived, const CXXRecordDecl *VBase)
Returns the assumed alignment of a virtual base of a class.
Definition: CGClass.cpp:76
llvm::Constant * GetFunctionStart(const ValueDecl *Decl)
llvm::GlobalVariable * getAddrOfConstantCompoundLiteralIfEmitted(const CompoundLiteralExpr *E)
If it's been emitted already, returns the GlobalVariable corresponding to a compound literal.
static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V)
void EmitTentativeDefinition(const VarDecl *D)
bool ReturnTypeUsesFP2Ret(QualType ResultType)
Return true iff the given type uses 'fp2ret' when used as a return type.
Definition: CGCall.cpp: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()
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:203
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:255
SmallVector< const CXXRecordDecl *, 0 > getMostBaseClasses(const CXXRecordDecl *RD)
Return a vector of most-base classes for RD.
void AddDeferredUnusedCoverageMapping(Decl *D)
Stored a deferred empty coverage mapping for an unused and thus uninstrumented top level declaration.
bool AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD)
Returns whether the given record has public LTO visibility (regardless of -lto-whole-program-visibili...
Definition: CGVTables.cpp:1288
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...
Definition: CGVTables.cpp:1193
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:2382
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:2410
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()
Definition: CGBlocks.cpp:2960
ConstantAddress GetAddrOfUnnamedGlobalConstantDecl(const UnnamedGlobalConstantDecl *GCD)
Get the address of a UnnamedGlobalConstant.
TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo, TBAAAccessInfo TargetInfo)
mergeTBAAInfoForCast - Get merged TBAA information for the purposes of type casts.
llvm::Constant * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr, ForDefinition_t IsForDefinition=NotForDefinition)
Return the llvm::Constant for the address of the given global variable.
MicrosoftVTableContext & getMicrosoftVTableContext()
const HeaderSearchOptions & getHeaderSearchOpts() const
llvm::SanitizerStatReport & getSanStats()
llvm::Constant * EmitAnnotationString(StringRef Str)
Emit an annotation string.
llvm::Type * getVTableComponentType() const
Definition: CGVTables.cpp:716
void EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare mapper construct.
Definition: CGDecl.cpp:2872
llvm::Function * getLLVMLifetimeEndFn()
Lazily declare the @llvm.lifetime.end intrinsic.
Definition: CGDecl.cpp:2616
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:2890
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:2236
std::optional< CharUnits > getOMPAllocateAlignment(const VarDecl *VD)
Return the alignment specified in an allocate directive, if present.
Definition: CGDecl.cpp:2945
llvm::GlobalVariable * CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, llvm::GlobalValue::LinkageTypes Linkage, llvm::Align Alignment)
Will return a global variable of the given type.
llvm::FunctionCallee getTerminateFn()
Get the declaration of std::terminate for the platform.
Definition: CGException.cpp:63
CharUnits getNaturalPointeeTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
llvm::FunctionCallee getBlockObjectDispose()
Definition: CGBlocks.cpp:2926
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:2865
const ItaniumVTableContext & getItaniumVTableContext() const
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys={})
void AddDetectMismatch(StringRef Name, StringRef Value)
Appends a detect mismatch command to the linker options.
void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
llvm::Value * createOpenCLIntToSamplerConversion(const Expr *E, CodeGenFunction &CGF)
ConstantAddress GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, const Expr *Inner)
Returns a pointer to a global variable representing a temporary with static or thread storage duratio...
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
LangAS GetGlobalConstantAddressSpace() const
Return the AST address space of constant literal, which is used to emit the constant literal as globa...
LangAS GetGlobalVarAddressSpace(const VarDecl *D)
Return the AST address space of the underlying global variable for D, as determined by its declaratio...
llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD)
Return the appropriate linkage for the vtable, VTT, and type information of the given class.
Definition: CGVTables.cpp:1086
void SetLLVMFunctionAttributes(GlobalDecl GD, const CGFunctionInfo &Info, llvm::Function *F, bool IsThunk)
Set the LLVM function attributes (sext, zext, etc).
void addDeferredVTable(const CXXRecordDecl *RD)
llvm::Type * getGenericBlockLiteralType()
The type of a generic block literal.
Definition: CGBlocks.cpp:1135
void EmitOpenACCRoutine(const OpenACCRoutineDecl *D, CodeGenFunction *CGF=nullptr)
Definition: CGDecl.cpp:2885
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.
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)
Definition: CGDeclCXX.cpp:438
llvm::Constant * EmitAnnotationUnit(SourceLocation Loc)
Emit the annotation's translation unit.
CGPointerAuthInfo getPointerAuthInfoForType(QualType type)
ConstantAddress GetAddrOfConstantCString(const std::string &Str, const char *GlobalName=nullptr)
Returns a pointer to a character array containing the literal and a terminating '\0' character.
std::vector< Structor > CtorList
void printPostfixForExternalizedDecl(llvm::raw_ostream &OS, const Decl *D) const
Print the postfix for externalized static variable or kernels for single source offloading languages ...
llvm::Constant * GetAddrOfThunk(StringRef Name, llvm::Type *FnTy, GlobalDecl GD)
Get the address of the thunk for the given global decl.
Definition: CGVTables.cpp: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.
This class organizes the cross-module state that is used while lowering AST types to LLVM types.
Definition: CodeGenTypes.h:54
ItaniumVTableContext & getItaniumVTableContext()
Definition: CGVTables.h:87
MicrosoftVTableContext & getMicrosoftVTableContext()
Definition: CGVTables.h:95
A specialization of Address that requires the address to be an LLVM Constant.
Definition: Address.h:296
The Counter with an optional additional Counter for branches.
CounterPair(unsigned Val)
May be None.
Organizes the cross-function state that is used while generating code coverage mapping data.
This class records statistics on instrumentation based profiling.
bool hasDiagnostics()
Whether or not the stats we've gathered indicate any potential problems.
void addMissing(bool MainFile)
Record that a function we've visited has no profile data.
void addMismatched(bool MainFile)
Record that a function we've visited has mismatched profile data.
void addVisited(bool MainFile)
Record that we've visited a function and whether or not that function was in the main source file.
void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile)
Report potential problems we've found to Diags.
LValue - This represents an lvalue references.
Definition: CGValue.h:182
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Definition: TargetInfo.h:47
Helper class for stores the "trap reason" built by.
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3541
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:779
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:231
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3864
This represents one expression.
Definition: Expr.h:112
Represents a function declaration or definition.
Definition: Decl.h:1999
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: TypeBase.h:4478
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...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:434
bool hasDefaultVisibilityExportMapping() const
Definition: LangOptions.h:704
bool isExplicitDefaultVisibilityExportMapping() const
Definition: LangOptions.h:709
bool isAllDefaultVisibilityExportMapping() const
Definition: LangOptions.h:714
bool isTargetDevice() const
True when compiling for an offloading target device.
Definition: LangOptions.h:757
Represents a linkage specification.
Definition: DeclCXX.h:3009
A global _GUID constant.
Definition: DeclCXX.h:4392
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4914
Describes a module or submodule.
Definition: Module.h:144
This represents a decl that may have a name.
Definition: Decl.h:273
This represents '#pragma omp allocate ...' directive.
Definition: DeclOpenMP.h:474
This represents '#pragma omp declare mapper ...' directive.
Definition: DeclOpenMP.h:287
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:177
This represents '#pragma omp requires...' directive.
Definition: DeclOpenMP.h:417
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:110
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:409
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2597
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:28
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
ExclusionType
Represents if an how something should be excluded from profiling.
Definition: ProfileList.h:31
A (possibly-)qualified type.
Definition: TypeBase.h:937
Represents a struct/union/class.
Definition: Decl.h:4309
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:1801
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3714
Exposes information about the current target.
Definition: TargetInfo.h:226
uint64_t getPointerAlign(LangAS AddrSpace) const
Definition: TargetInfo.h:490
A template parameter object.
A declaration that models statements at global scope.
Definition: Decl.h:4597
The base class of the type hierarchy.
Definition: TypeBase.h:1833
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:2246
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition: DeclCXX.h:4449
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:711
Represents a variable declaration or definition.
Definition: Decl.h:925
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static const FunctionDecl * getCallee(const CXXConstructExpr &D)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Definition: ModuleMapFile.h:36
The JSON file list parser is used to communicate input to InstallAPI.
GVALinkage
A more specific kind of linkage than enum Linkage.
Definition: Linkage.h:72
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:24
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ Result
The result type of a method or function.
LangAS
Defines the address space values used by the address space qualifier of QualType.
Definition: AddressSpaces.h:25
const FunctionProtoType * T
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:278
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Visibility
Describes the different kinds of visibility that a declaration may have.
Definition: Visibility.h:34
@ HiddenVisibility
Objects with "hidden" visibility are not seen by the dynamic linker.
Definition: Visibility.h:37
@ ProtectedVisibility
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
Definition: Visibility.h:42
@ DefaultVisibility
Objects with "default" visibility are seen by the dynamic linker and act like normal objects.
Definition: Visibility.h:46
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
Structor(int Priority, unsigned LexOrder, llvm::Constant *Initializer, llvm::Constant *AssociatedData)
This structure provides a set of types that are commonly used during IR emission.
llvm::Function * objc_retainAutoreleasedReturnValue
id objc_retainAutoreleasedReturnValue(id);
llvm::Function * objc_retainAutoreleaseReturnValue
id objc_retainAutoreleaseReturnValue(id);
llvm::FunctionCallee objc_alloc
void objc_alloc(id);
llvm::Function * objc_retain
id objc_retain(id);
llvm::FunctionCallee objc_alloc_init
void objc_alloc_init(id);
llvm::Function * objc_autorelease
id objc_autorelease(id);
llvm::Function * objc_moveWeak
void objc_moveWeak(id *dest, id *src);
llvm::FunctionCallee objc_autoreleasePoolPopInvoke
void objc_autoreleasePoolPop(void*); Note this method is used when we are using exception handling
llvm::InlineAsm * retainAutoreleasedReturnValueMarker
A void(void) inline asm to use to mark that the return value of a call will be immediately retain.
llvm::Function * clang_arc_use
void clang.arc.use(...);
llvm::Function * objc_initWeak
id objc_initWeak(id*, id);
llvm::FunctionCallee objc_retainRuntimeFunction
id objc_retain(id); Note this is the runtime method not the intrinsic.
llvm::Function * objc_copyWeak
void objc_copyWeak(id *dest, id *src);
llvm::Function * objc_destroyWeak
void objc_destroyWeak(id*);
llvm::Function * objc_retainAutorelease
id objc_retainAutorelease(id);
llvm::Function * objc_autoreleasePoolPush
void *objc_autoreleasePoolPush(void);
llvm::Function * objc_retainBlock
id objc_retainBlock(id);
llvm::Function * objc_storeStrong
void objc_storeStrong(id*, id);
llvm::Function * objc_loadWeak
id objc_loadWeak(id*);
llvm::Function * clang_arc_noop_use
void clang.arc.noop.use(...);
llvm::Function * objc_loadWeakRetained
id objc_loadWeakRetained(id*);
llvm::Function * objc_release
void objc_release(id);
llvm::FunctionCallee objc_autoreleaseRuntimeFunction
id objc_autorelease(id); Note this is the runtime method not the intrinsic.
llvm::Function * objc_autoreleaseReturnValue
id objc_autoreleaseReturnValue(id);
llvm::FunctionCallee objc_releaseRuntimeFunction
void objc_release(id); Note this is the runtime method not the intrinsic.
llvm::FunctionCallee objc_allocWithZone
void objc_allocWithZone(id);
llvm::FunctionCallee objc_autoreleasePoolPop
void objc_autoreleasePoolPop(void*);
llvm::Function * objc_storeWeak
id objc_storeWeak(id*, id);
llvm::Function * objc_unsafeClaimAutoreleasedReturnValue
id objc_unsafeClaimAutoreleasedReturnValue(id);
bool operator<(const OrderGlobalInitsOrStermFinalizers &RHS) const
bool operator==(const OrderGlobalInitsOrStermFinalizers &RHS) const
OrderGlobalInitsOrStermFinalizers(unsigned int p, unsigned int l)
static TBAAAccessInfo getMayAliasInfo()
Definition: CodeGenTBAA.h:63