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