13#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
14#define LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
34#include "llvm/ADT/DenseMap.h"
35#include "llvm/ADT/MapVector.h"
36#include "llvm/ADT/SetVector.h"
37#include "llvm/ADT/SmallPtrSet.h"
38#include "llvm/ADT/StringMap.h"
39#include "llvm/IR/Module.h"
40#include "llvm/IR/ValueHandle.h"
41#include "llvm/Support/Allocator.h"
42#include "llvm/Support/VirtualFileSystemFwd.h"
43#include "llvm/Transforms/Utils/SanitizerStats.h"
55class IndexedInstrProfReader;
70class ObjCImplementationDecl;
79class PointerAuthSchema;
84class HeaderSearchOptions;
85class DiagnosticsEngine;
87class CXXDestructorDecl;
89class CoverageSourceInfo;
100class CGOpenMPRuntime;
104class CoverageMappingModuleGen;
106class TargetCodeGenInfo;
129 static constexpr uint32_t None = (1u << 31);
130 static constexpr uint32_t Mask = None - 1;
138 assert(!(InitVal & ~Mask));
318 void Profile(llvm::FoldingSetNodeID &
id)
const {
334 CodeGenModule(
const CodeGenModule &) =
delete;
335 void operator=(
const CodeGenModule &) =
delete;
361 unsigned NumAutoVarInit = 0;
362 llvm::Module &TheModule;
365 std::unique_ptr<CGCXXABI> ABI;
366 llvm::LLVMContext &VMContext;
367 std::string ModuleNameHash;
368 bool CXX20ModuleInits =
false;
369 std::unique_ptr<CodeGenTBAA> TBAA;
371 mutable std::unique_ptr<TargetCodeGenInfo> TheTargetCodeGenInfo;
375 mutable std::unique_ptr<llvm::abi::TargetInfo> TheLLVMABITargetInfo;
381 llvm::BumpPtrAllocator AbiAlloc;
382 std::unique_ptr<QualTypeMapper> AbiMapper;
383 std::unique_ptr<llvm::abi::IRTypeMapper> AbiReverseMapper;
388 std::unique_ptr<CodeGenTypes> Types;
393 std::unique_ptr<CGObjCRuntime> ObjCRuntime;
394 std::unique_ptr<CGOpenCLRuntime> OpenCLRuntime;
395 std::unique_ptr<CGOpenMPRuntime> OpenMPRuntime;
396 std::unique_ptr<CGCUDARuntime> CUDARuntime;
397 std::unique_ptr<CGHLSLRuntime> HLSLRuntime;
398 std::unique_ptr<CGDebugInfo> DebugInfo;
399 std::unique_ptr<ObjCEntrypoints> ObjCData;
400 llvm::MDNode *NoObjCARCExceptionsMetadata =
nullptr;
401 std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader;
403 std::unique_ptr<llvm::SanitizerStatReport> SanStats;
415 llvm::DenseMap<StringRef, GlobalDecl> DeferredDecls;
417 llvm::StringSet<llvm::BumpPtrAllocator> DeferredResolversToEmit;
421 std::vector<GlobalDecl> DeferredDeclsToEmit;
423 DeferredDeclsToEmit.emplace_back(GD);
424 addEmittedDeferredDecl(GD);
428 llvm::DenseMap<llvm::StringRef, GlobalDecl> EmittedDeferredDecls;
432 if (!Context.getLangOpts().IncrementalExtensions)
436 auto L = llvm::GlobalValue::ExternalLinkage;
437 if (llvm::isa<FunctionDecl>(GD.
getDecl()))
439 else if (
auto *VD = llvm::dyn_cast<VarDecl>(GD.
getDecl()))
442 if (llvm::GlobalValue::isInternalLinkage(L) ||
443 llvm::GlobalValue::isLinkOnceLinkage(L) ||
444 llvm::GlobalValue::isWeakLinkage(L)) {
451 std::vector<GlobalDecl> Aliases;
456 std::vector<GlobalDecl> MultiVersionFuncs;
458 llvm::MapVector<StringRef, llvm::TrackingVH<llvm::Constant>> Replacements;
464 GlobalValReplacements;
468 llvm::DenseMap<const VarDecl*, llvm::GlobalVariable*> InitializerConstants;
473 llvm::DenseSet<GlobalDecl> DiagnosedConflictingDefinitions;
476 std::vector<const CXXRecordDecl*> DeferredVTables;
484 std::vector<const CXXRecordDecl *> OpportunisticVTables;
489 std::vector<llvm::WeakTrackingVH> LLVMUsed;
490 std::vector<llvm::WeakTrackingVH> LLVMCompilerUsed;
501 llvm::MapVector<GlobalDecl, StringRef> MangledDeclNames;
502 llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> Manglings;
505 std::vector<llvm::Constant*> Annotations;
511 llvm::MapVector<std::string, const ValueDecl *, llvm::StringMap<unsigned>>
515 llvm::StringMap<llvm::Constant*> AnnotationStrings;
518 llvm::DenseMap<unsigned, llvm::Constant *> AnnotationArgs;
520 llvm::StringMap<llvm::GlobalVariable *> CFConstantStringMap;
522 llvm::DenseMap<llvm::Constant *, llvm::GlobalVariable *> ConstantStringMap;
523 llvm::DenseMap<const UnnamedGlobalConstantDecl *, llvm::GlobalVariable *>
524 UnnamedGlobalConstantDeclMap;
525 llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap;
526 llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap;
527 llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap;
529 llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap;
530 llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap;
533 llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap;
537 typedef llvm::MapVector<IdentifierInfo *,
538 llvm::GlobalValue *> StaticExternCMap;
539 StaticExternCMap StaticExternCValues;
542 std::vector<const VarDecl *> CXXThreadLocals;
546 std::vector<llvm::Function *> CXXThreadLocalInits;
547 std::vector<const VarDecl *> CXXThreadLocalInitVars;
550 std::vector<llvm::Function *> CXXGlobalInits;
557 llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition;
567 llvm::MapVector<llvm::GlobalAlias *, const FunctionDecl *>
568 PendingMSVCGlobalDeletes;
572 bool HasDirectGlobalDelete =
false;
574 typedef std::pair<OrderGlobalInitsOrStermFinalizers, llvm::Function *>
583 MustTailCallUndefinedGlobals;
585 struct GlobalInitPriorityCmp {
586 bool operator()(
const GlobalInitData &LHS,
587 const GlobalInitData &RHS)
const {
588 return LHS.first.priority < RHS.first.priority;
594 SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits;
599 typedef std::tuple<llvm::FunctionType *, llvm::WeakTrackingVH,
601 CXXGlobalDtorsOrStermFinalizer_t;
602 SmallVector<CXXGlobalDtorsOrStermFinalizer_t, 8>
603 CXXGlobalDtorsOrStermFinalizers;
605 typedef std::pair<OrderGlobalInitsOrStermFinalizers, llvm::Function *>
608 struct StermFinalizerPriorityCmp {
609 bool operator()(
const StermFinalizerData &LHS,
610 const StermFinalizerData &RHS)
const {
611 return LHS.first.priority < RHS.first.priority;
617 SmallVector<StermFinalizerData, 8> PrioritizedCXXStermFinalizers;
620 llvm::SetVector<clang::Module *> ImportedModules;
624 llvm::SmallPtrSet<clang::Module *, 16> EmittedModuleInitializers;
627 SmallVector<llvm::MDNode *, 16> LinkerOptionsMetadata;
630 SmallVector<llvm::MDNode *, 16> ELFDependentLibraries;
633 llvm::GlobalVariable *LoadTimeCommentGlobal =
nullptr;
640 llvm::WeakTrackingVH CFConstantStringClassRef;
644 QualType ObjCFastEnumerationStateType;
649 void createObjCRuntime();
651 void createOpenCLRuntime();
652 void createOpenMPRuntime();
653 void createCUDARuntime();
654 void createHLSLRuntime();
656 bool shouldEmitFunction(GlobalDecl GD);
657 bool shouldOpportunisticallyEmitVTables();
659 llvm::DenseMap<const CompoundLiteralExpr *, llvm::GlobalVariable *>
660 EmittedCompoundLiterals;
664 llvm::DenseMap<const BlockExpr *, llvm::Constant *> EmittedGlobalBlocks;
669 llvm::Constant *NSConcreteGlobalBlock =
nullptr;
670 llvm::Constant *NSConcreteStackBlock =
nullptr;
672 llvm::FunctionCallee BlockObjectAssign =
nullptr;
673 llvm::FunctionCallee BlockObjectDispose =
nullptr;
675 llvm::Type *BlockDescriptorType =
nullptr;
676 llvm::Type *GenericBlockLiteralType =
nullptr;
687 llvm::Function *LifetimeStartFn =
nullptr;
690 llvm::Function *LifetimeEndFn =
nullptr;
693 llvm::Function *FakeUseFn =
nullptr;
695 std::unique_ptr<SanitizerMetadata> SanitizerMD;
697 llvm::MapVector<const Decl *, bool> DeferredEmptyCoverageMappingDecls;
699 std::unique_ptr<CoverageMappingModuleGen> CoverageMapping;
704 typedef llvm::DenseMap<QualType, llvm::Metadata *> MetadataTypeMap;
705 MetadataTypeMap MetadataIdMap;
706 MetadataTypeMap VirtualMetadataIdMap;
707 MetadataTypeMap GeneralizedMetadataIdMap;
708 MetadataTypeMap CallGraphMetadataIdMap;
713 GlobalTopLevelStmtBlockInFlight;
715 llvm::DenseMap<GlobalDecl, uint16_t> PtrAuthDiscriminatorHashes;
717 llvm::DenseMap<const CXXRecordDecl *, std::optional<PointerAuthQualifier>>
719 std::optional<PointerAuthQualifier>
720 computeVTPointerAuthentication(
const CXXRecordDecl *ThisClass,
728 std::vector<std::string> MSHotPatchFunctions;
756 if (!ObjCRuntime) createObjCRuntime();
800 assert(OpenCLRuntime !=
nullptr);
801 return *OpenCLRuntime;
806 assert(OpenMPRuntime !=
nullptr);
807 return *OpenMPRuntime;
812 assert(CUDARuntime !=
nullptr);
818 assert(HLSLRuntime !=
nullptr);
823 assert(ObjCData !=
nullptr);
834 llvm::IndexedInstrProfReader *
getPGOReader()
const {
return PGOReader.get(); }
837 return CoverageMapping.get();
841 return StaticLocalDeclMap[D];
845 StaticLocalDeclMap[D] =
C;
850 llvm::GlobalValue::LinkageTypes
Linkage);
853 return StaticLocalDeclGuardMap[D];
856 llvm::GlobalVariable *
C) {
857 StaticLocalDeclGuardMap[D] =
C;
867 return AtomicSetterHelperFnMap[Ty];
870 llvm::Constant *Fn) {
871 AtomicSetterHelperFnMap[Ty] = Fn;
875 return AtomicGetterHelperFnMap[Ty];
878 llvm::Constant *Fn) {
879 AtomicGetterHelperFnMap[Ty] = Fn;
883 return TypeDescriptorMap[Ty];
886 TypeDescriptorMap[Ty] =
C;
892 if (!NoObjCARCExceptionsMetadata)
893 NoObjCARCExceptionsMetadata = llvm::MDNode::get(
getLLVMContext(), {});
894 return NoObjCARCExceptionsMetadata;
903 const {
return HeaderSearchOpts; }
905 const {
return PreprocessorOpts; }
910 return TheModule.getDataLayout();
913 const llvm::Triple &
getTriple()
const {
return Target.getTriple(); }
946 return VTables.getItaniumVTableContext();
950 return VTables.getItaniumVTableContext();
954 return VTables.getMicrosoftVTableContext();
999 if (
Base.getTBAAInfo().isMayAlias())
1053 llvm_unreachable(
"unknown visibility!");
1064 llvm::GlobalVariable *
1066 llvm::GlobalValue::LinkageTypes
Linkage,
1067 llvm::Align Alignment);
1070 llvm::FunctionType *ty,
const Twine &name,
const CGFunctionInfo &FI,
1072 llvm::GlobalVariable::LinkageTypes
Linkage =
1073 llvm::GlobalVariable::InternalLinkage);
1099 llvm::Type *Ty =
nullptr,
1106 bool ForVTable =
false,
1107 bool DontDefer =
false,
1118 llvm::Type *Ty =
nullptr);
1132 llvm::Type *Ty =
nullptr);
1148 llvm::Constant *StorageAddress,
1154 llvm::Constant *StorageAddress,
1155 llvm::ConstantInt *OtherDiscriminator);
1165 llvm::Value *StorageAddress,
bool IsVTTEntry =
false);
1167 std::optional<PointerAuthQualifier>
1169 bool IsVTTEntry =
false);
1255 return EmittedGlobalBlocks.lookup(BE);
1271 StringRef Name =
".str");
1283 StringRef GlobalName =
".str");
1291 llvm::GlobalVariable *
1297 llvm::GlobalVariable *GV);
1319 llvm::FunctionType *FnType =
nullptr,
1320 bool DontDefer =
false,
1330 llvm::FunctionType *FnType =
nullptr,
bool DontDefer =
false,
1336 unsigned BuiltinID);
1366 template<
typename SomeDecl>
1380 CXXGlobalDtorsOrStermFinalizers.emplace_back(DtorFn.getFunctionType(),
1381 DtorFn.getCallee(),
Object);
1386 CXXGlobalDtorsOrStermFinalizers.emplace_back(DtorFn.getFunctionType(),
1387 DtorFn.getCallee(),
nullptr);
1399 PrioritizedCXXStermFinalizers.size());
1400 PrioritizedCXXStermFinalizers.push_back(
1401 std::make_pair(Key, StermFinalizer));
1410 llvm::FunctionCallee
1412 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1413 bool Local =
false,
bool AssumeConvergent =
false);
1418 llvm::FunctionCallee
1421 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1422 bool Local =
false,
bool AssumeConvergent =
false);
1478 llvm::function_ref<
void()> Fn);
1488 llvm::Function *F,
bool IsThunk);
1527 llvm::AttributeList &Attrs,
unsigned &
CallingConv,
1528 bool AttrOnCallSite,
bool IsThunk);
1534 llvm::AttributeList &Attrs);
1582 llvm::GlobalValue::LinkageTypes
1586 llvm::GlobalValue::LinkageTypes
1612 const AnnotateAttr *AA,
1624 StringRef Category = StringRef())
const;
1630 StringRef Category = StringRef())
const;
1644 return SanitizerMD.get();
1648 DeferredVTables.push_back(RD);
1741 llvm::GlobalObject::VCallVisibility
1743 llvm::DenseSet<const CXXRecordDecl *> &Visited);
1747 llvm::GlobalVariable *VTable,
1858 bool forPointeeType =
false);
1870 const Decl *D)
const;
1881 const CUDALaunchBoundsAttr *A,
1882 int32_t *MaxThreadsVal =
nullptr,
1883 int32_t *MinBlocksVal =
nullptr,
1884 int32_t *MaxClusterRankVal =
nullptr);
1892 llvm::Function *F,
const AMDGPUFlatWorkGroupSizeAttr *A,
1893 const ReqdWorkGroupSizeAttr *ReqdWGS =
nullptr,
1894 int32_t *MinThreadsVal =
nullptr,
int32_t *MaxThreadsVal =
nullptr);
1898 const AMDGPUWavesPerEUAttr *A);
1906 void AddGlobalCtor(llvm::Function *Ctor,
int Priority = 65535,
1907 unsigned LexOrder = ~0
U,
1908 llvm::Constant *AssociatedData =
nullptr);
1909 void AddGlobalDtor(llvm::Function *Dtor,
int Priority = 65535,
1910 bool IsDtorAttrFunc =
false);
1921 std::pair<const FunctionDecl *, SourceLocation>
Global) {
1922 MustTailCallUndefinedGlobals.insert(
Global);
1979 unsigned PAlign = Context.getLangOpts().RelativeCXXABIVTables
1991 llvm::Type *DestTy) {
1994 return llvm::ConstantExpr::getPointerCast(Src, DestTy);
1997 std::optional<llvm::Attribute::AttrKind>
2007 ABIArgInfo convertABIArgInfo(
const llvm::abi::ArgInfo &AbiInfo,
2011 void ProcessPragmaCommentCopyright(StringRef Comment,
bool isFromASTFile);
2013 bool shouldDropDLLAttribute(
const Decl *D,
const llvm::GlobalValue *GV)
const;
2015 llvm::Constant *GetOrCreateLLVMFunction(
2016 StringRef MangledName, llvm::Type *Ty,
GlobalDecl D,
bool ForVTable,
2017 bool DontDefer =
false,
bool IsThunk =
false,
2018 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
2022 void AddDeferredMultiVersionResolverToEmit(
GlobalDecl GD);
2029 llvm::Constant *GetOrCreateMultiVersionResolver(
GlobalDecl GD);
2037 void setMultiVersionResolverAttributes(llvm::Function *Resolver,
2046 StringRef &CurName);
2048 bool GetCPUAndFeaturesAttributes(
GlobalDecl GD,
2049 llvm::AttrBuilder &AttrBuilder,
2050 bool SetTargetFeatures =
true);
2051 void setNonAliasAttributes(
GlobalDecl GD, llvm::GlobalObject *GO);
2054 void SetFunctionAttributes(
GlobalDecl GD, llvm::Function *F,
2055 bool IsIncompleteFunction,
bool IsThunk);
2057 void EmitGlobalDefinition(
GlobalDecl D, llvm::GlobalValue *GV =
nullptr);
2059 void EmitGlobalFunctionDefinition(
GlobalDecl GD, llvm::GlobalValue *GV);
2060 void EmitMultiVersionFunctionDefinition(
GlobalDecl GD, llvm::GlobalValue *GV);
2062 void EmitGlobalVarDefinition(
const VarDecl *D,
bool IsTentative =
false);
2065 void emitCPUDispatchDefinition(
GlobalDecl GD);
2076 void EmitCXXThreadLocalInitFunc();
2082 void EmitCXXGlobalInitFunc();
2085 void EmitCXXGlobalCleanUpFunc();
2089 void EmitCXXGlobalVarDeclInitFunc(
const VarDecl *D,
2090 llvm::GlobalVariable *
Addr,
2093 void EmitPointerToInitFunc(
const VarDecl *VD, llvm::GlobalVariable *
Addr,
2094 llvm::Function *InitFunc, InitSegAttr *ISA);
2099 void EmitCtorList(
CtorList &Fns,
const char *GlobalName);
2102 void EmitDeferred();
2108 void EmitVTablesOpportunistically();
2111 void applyReplacements();
2114 void applyGlobalValReplacements();
2116 void checkAliases();
2118 std::map<int, llvm::TinyPtrVector<llvm::Function *>> DtorsUsingAtExit;
2122 void registerGlobalDtorsWithAtExit();
2127 void unregisterGlobalDtorsWithUnAtExit();
2130 void emitMultiVersionFunctions();
2133 void EmitDeferredVTables();
2137 void emitAtAvailableLinkGuard();
2140 void emitLLVMUsed();
2146 void EmitModuleLinkOptions();
2155 bool CheckAndReplaceExternCIFuncs(llvm::GlobalValue *Elem,
2156 llvm::GlobalValue *CppFunc);
2160 void EmitStaticExternCAliases();
2162 void EmitDeclMetadata();
2165 void EmitVersionIdentMetadata();
2168 void EmitCommandLineMetadata();
2172 void EmitBackendOptionsMetadata(
const CodeGenOptions &CodeGenOpts);
2175 void EmitOpenCLMetadata();
2179 void EmitCoverageFile();
2183 void EmitSYCLKernelCaller(
const FunctionDecl *KernelEntryPointFn,
2191 void addSYCLModuleIdAttr(llvm::Function *Fn);
2197 llvm::Function *embedSYCLDeviceBinary();
2207 bool MayBeEmittedEagerly(
const ValueDecl *D);
2211 void SimplifyPersonality();
2216 bool AttrOnCallSite,
2217 llvm::AttrBuilder &FuncAttrs);
2222 void getDefaultFunctionAttributes(StringRef Name,
bool HasOptnone,
2223 bool AttrOnCallSite,
2224 llvm::AttrBuilder &FuncAttrs);
2226 llvm::Metadata *CreateMetadataIdentifierImpl(
QualType T, MetadataTypeMap &Map,
2228 bool ForceString =
false);
2232 void emitPFPFieldsWithEvaluatedOffset();
Enums/classes describing ABI related information about constructors, destructors and thunks.
static void getTrivialDefaultFunctionAttributes(StringRef Name, bool HasOptnone, const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
Defines a utilitiy for warning once when close to out of stack space.
This file contains the declaration of TrapReasonBuilder and related classes.
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Attr - This represents one attribute.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
const CXXBaseSpecifier *const * path_const_iterator
This is an opaque type for sizes expressed in character units.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
ABIInfo - Target specific hooks for defining how a type should be passed or returned from functions.
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
virtual ~BlockByrefHelpers()
void Profile(llvm::FoldingSetNodeID &id) const
virtual void emitCopy(CodeGenFunction &CGF, Address dest, Address src)=0
BlockByrefHelpers(CharUnits alignment)
virtual bool needsCopy() const
llvm::Constant * CopyHelper
CharUnits Alignment
The alignment of the field.
virtual void emitDispose(CodeGenFunction &CGF, Address field)=0
BlockByrefHelpers(const BlockByrefHelpers &)=default
virtual bool needsDispose() const
llvm::Constant * DisposeHelper
virtual void profileImpl(llvm::FoldingSetNodeID &id) const =0
Implements C++ ABI-specific code generation functions.
Abstract information about a function or function prototype.
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
CGFunctionInfo - Class to encapsulate the information about a function definition.
Implements runtime-specific code generation functions.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD)
llvm::FunctionCallee getBlockObjectAssign()
const PreprocessorOptions & getPreprocessorOpts() const
ConstantAddress GetAddrOfMSGuidDecl(const MSGuidDecl *GD)
Get the address of a GUID.
void AddCXXPrioritizedStermFinalizerEntry(llvm::Function *StermFinalizer, int Priority)
void setGVProperties(llvm::GlobalValue *GV, GlobalDecl GD) const
Set visibility, dllimport/dllexport and dso_local.
void AddCXXDtorEntry(llvm::FunctionCallee DtorFn, llvm::Constant *Object)
Add a destructor and object to add to the C++ global destructor function.
llvm::FoldingSet< BlockByrefHelpers > ByrefHelpersCache
void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset, const CXXRecordDecl *RD)
Create and attach type metadata for the given vtable.
void UpdateCompletedType(const TagDecl *TD)
void handleCUDALaunchBoundsAttr(llvm::Function *F, const CUDALaunchBoundsAttr *A, int32_t *MaxThreadsVal=nullptr, int32_t *MinBlocksVal=nullptr, int32_t *MaxClusterRankVal=nullptr)
Emit the IR encoding to attach the CUDA launch bounds attribute to F.
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.
void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
void setDSOLocal(llvm::GlobalValue *GV) const
llvm::GlobalObject::VCallVisibility GetVCallVisibilityLevel(const CXXRecordDecl *RD, llvm::DenseSet< const CXXRecordDecl * > &Visited)
Returns the vcall visibility of the given type.
llvm::MDNode * getTBAAStructInfo(QualType QTy)
CGHLSLRuntime & getHLSLRuntime()
Return a reference to the configured HLSL runtime.
llvm::Constant * EmitAnnotationArgs(const AnnotateAttr *Attr)
Emit additional args of the annotation.
llvm::Module & getModule() const
std::optional< llvm::Attribute::AttrKind > StackProtectorAttribute(const Decl *D) const
llvm::GlobalValue * getPFPDeactivationSymbol(const FieldDecl *FD)
llvm::FunctionCallee CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false, bool AssumeConvergent=false)
Create or return a runtime function declaration with the specified type and name.
llvm::ConstantInt * CreateKCFITypeId(QualType T, StringRef Salt)
Generate a KCFI type identifier for T.
CGDebugInfo * getModuleDebugInfo()
llvm::Constant * performAddrSpaceCast(llvm::Constant *Src, llvm::Type *DestTy)
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()
CtorList & getGlobalDtors()
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.
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.
void createFunctionTypeMetadataForIcall(const FunctionDecl *FD, llvm::Function *F)
Create and attach type metadata to the given function.
std::optional< PointerAuthQualifier > getVTablePointerAuthentication(const CXXRecordDecl *thisClass, bool IsVTTEntry=false)
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.
llvm::Metadata * CreateMetadataIdentifierForCallGraphType(QualType T)
Create a metadata identifier for the Call Graph Section.
CharUnits getMinimumClassObjectSize(const CXXRecordDecl *CD)
Returns the minimum object size for an object of the given class type (or a class derived from it).
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.
bool classNeedsVectorDestructor(const CXXRecordDecl *RD)
Check that class need vector deleting destructor body.
llvm::FunctionCallee getAddrAndTypeOfCXXStructor(GlobalDecl GD, const CGFunctionInfo *FnInfo=nullptr, llvm::FunctionType *FnType=nullptr, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
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)
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.
const ABIInfo & getABIInfo()
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.
void EmitMainVoidAlias()
Emit an alias for "main" if it has no arguments (needed for wasm).
void DecorateInstructionWithInvariantGroup(llvm::Instruction *I, const CXXRecordDecl *RD)
Adds !invariant.barrier !tag to instruction.
TrapReasonBuilder BuildTrapReason(unsigned DiagID, TrapReason &TR)
Helper function to construct a TrapReasonBuilder.
llvm::Constant * getBuiltinLibFunction(const FunctionDecl *FD, unsigned BuiltinID)
Given a builtin id for a function like "__builtin_fabsf", return a Function* for "fabsf".
llvm::Constant * getOrCreateMSVCGlobalDeleteWrapper(const FunctionDecl *GlobOD)
Get or create the MSVC-compatible __global_delete wrapper for the given global operator delete,...
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 isObjCDirectPreconditionThunkEnabled() const
Check if the precondition thunk optimization is enabled.
void setAtomicOpts(AtomicOptions AO)
Set the current Atomic options.
bool isPaddedAtomicType(QualType type)
llvm::Constant * getNullPointer(llvm::PointerType *T, QualType QT)
Get target specific null pointer.
void AddCXXGlobalInit(llvm::Function *F)
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
llvm::Constant * EmitAnnotateAttr(llvm::GlobalValue *GV, const AnnotateAttr *AA, SourceLocation L)
Generate the llvm::ConstantStruct which contains the annotation information for a given GlobalValue.
void EmitOpenACCDeclare(const OpenACCDeclareDecl *D, CodeGenFunction *CGF=nullptr)
bool shouldHavePreconditionThunk(const ObjCMethodDecl *OMD) const
Check if a direct method should use precondition thunks at call sites.
llvm::GlobalValue::LinkageTypes getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage)
Returns LLVM linkage for a declarator.
TBAAAccessInfo mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo, TBAAAccessInfo SrcInfo)
mergeTBAAInfoForMemoryTransfer - Get merged TBAA information for the purposes of memory transfer call...
llvm::Type * getBlockDescriptorType()
Fetches the type of a generic block descriptor.
llvm::Constant * GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name)
Gets the address of a block which requires no captures.
llvm::Constant * getAtomicGetterHelperFnMap(QualType Ty)
CGPointerAuthInfo getMemberFunctionPointerAuthInfo(QualType FT)
const LangOptions & getLangOpts() const
CGCUDARuntime & getCUDARuntime()
Return a reference to the configured CUDA runtime.
int getUniqueBlockCount()
Fetches the global unique block count.
llvm::Constant * EmitAnnotationLineNo(SourceLocation L)
Emit the annotation line number.
QualType getObjCFastEnumerationStateType()
Retrieve the record type that describes the state of an Objective-C fast enumeration loop (for....
CtorList & getGlobalCtors()
CharUnits getNaturalTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, bool forPointeeType=false)
CodeGenTypes & getTypes()
bool shouldMapVisibilityToDLLExport(const NamedDecl *D) const
CGOpenCLRuntime & getOpenCLRuntime()
Return a reference to the configured OpenCL runtime.
const std::string & getModuleNameHash() const
const TargetInfo & getTarget() const
bool shouldEmitRTTI(bool ForEH=false)
void EmitGlobal(GlobalDecl D)
Emit code for a single global function or var decl.
llvm::Function * getLLVMFakeUseFn()
Lazily declare the @llvm.fake.use intrinsic.
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.
void createIndirectFunctionTypeMD(const FunctionDecl *FD, llvm::Function *F)
Create and attach callgraph metadata if the function is a potential indirect call target to support c...
void AppendLinkerOptions(StringRef Opts)
Appends Opts to the "llvm.linker.options" metadata value.
bool hasObjCRuntime()
Return true iff an Objective-C runtime has been configured.
void createCalleeTypeMetadataForIcall(const QualType &QT, llvm::CallBase *CB)
Create and attach callee_type metadata to the given call.
bool tryEmitCUDADeviceInvalidFunctionBody(GlobalDecl GD, llvm::Function *Fn)
Emit a trap stub body for functions in ASTContext::CUDADeviceInvalidFuncs.
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.
void computeABIInfoUsingLib(CGFunctionInfo &FI)
Drive the experimental LLVMABI-based lowering path: map argument and return types into the LLVMABI li...
bool lookupRepresentativeDecl(StringRef MangledName, GlobalDecl &Result) const
void EmitOMPAllocateDecl(const OMPAllocateDecl *D)
Emit a code for the allocate directive.
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.
bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D)
Try to emit a base destructor as an alias to its primary base-class destructor.
llvm::GlobalValue::LinkageTypes getLLVMLinkageVarDefinition(const VarDecl *VD)
Returns LLVM linkage for a declarator.
llvm::Constant * getMemberPointerConstant(const UnaryOperator *e)
unsigned getVtableGlobalVarAlignment(const VarDecl *D=nullptr)
bool HasHiddenLTOVisibility(const CXXRecordDecl *RD)
Returns whether the given record has hidden LTO visibility and therefore may participate in (single-m...
const llvm::DataLayout & getDataLayout() const
llvm::Constant * getNSConcreteGlobalBlock()
QualType GetCallGraphPromotedType(QualType Ty) const
Applies C default argument promotions to a parameter type for Call Graph Section type reconstruction.
void addUndefinedGlobalForTailCall(std::pair< const FunctionDecl *, SourceLocation > Global)
CharUnits computeNonVirtualBaseClassOffset(const CXXRecordDecl *DerivedClass, CastExpr::path_const_iterator Start, CastExpr::path_const_iterator End)
ObjCEntrypoints & getObjCEntrypoints() const
void requireVectorDestructorDefinition(const CXXRecordDecl *RD)
Record that new[] was called for the class, transform vector deleting destructor definition in a form...
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.
std::string getPFPFieldName(const FieldDecl *FD)
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.
llvm::Constant * GetFunctionStart(const ValueDecl *Decl)
void addPendingGlobalDelete(llvm::GlobalAlias *GlobalDeleteAlias, const FunctionDecl *OperatorDeleteFD)
Record a pending __global_delete variant that may need a forwarding body.
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.
void EmitDeferredUnusedCoverageMappings()
Emit all the deferred coverage mappings for the uninstrumented functions.
bool mayVTableBeDuplicated(llvm::GlobalValue::LinkageTypes Linkage) const
Returns true if a vtable with the given linkage may be emitted with more than one address in the prog...
void addUsedOrCompilerUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.compiler.used metadata.
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
bool imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc, StringRef Category=StringRef()) const
Imbue XRay attributes to a function, applying the always/never attribute lists in the process.
llvm::Constant * getMemberFunctionPointer(const FunctionDecl *FD, llvm::Type *Ty=nullptr)
SanitizerMetadata * getSanitizerMetadata()
void EmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target)
Emit a definition as a global alias for another definition, unconditionally.
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...
llvm::Function * codegenCXXStructor(GlobalDecl GD)
CharUnits getClassPointerAlignment(const CXXRecordDecl *CD)
Returns the assumed alignment of an opaque pointer to the given class.
const llvm::Triple & getTriple() const
void setAtomicSetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
llvm::Constant * getOrCreateStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
SmallVector< const CXXRecordDecl *, 0 > getMostBaseClasses(const CXXRecordDecl *RD)
Return a vector of most-base classes for RD.
void AddDeferredUnusedCoverageMapping(Decl *D)
Stored a deferred empty coverage mapping for an unused and thus uninstrumented top level declaration.
bool AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD)
Returns whether the given record has public LTO visibility (regardless of -lto-whole-program-visibili...
void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV)
If the declaration has internal linkage but is inside an extern "C" linkage specification,...
void DecorateInstructionWithTBAA(llvm::Instruction *Inst, TBAAAccessInfo TBAAInfo)
DecorateInstructionWithTBAA - Decorate the instruction with a TBAA tag.
uint16_t getPointerAuthDeclDiscriminator(GlobalDecl GD)
Return the "other" decl-specific discriminator for the given decl.
llvm::Constant * getAtomicSetterHelperFnMap(QualType Ty)
TBAAAccessInfo getTBAAInfoForSubobject(LValue Base, QualType AccessType)
getTBAAInfoForSubobject - Get TBAA information for an access with a given base lvalue.
bool shouldUseTBAA() const
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.
bool ReturnTypeHasInReg(const CGFunctionInfo &FI)
Return true iff the given type has inreg set.
void EmitVTable(CXXRecordDecl *Class)
This is a callback from Sema to tell us that a particular vtable is required to be emitted in this tr...
llvm::Constant * CreateRuntimeVariable(llvm::Type *Ty, StringRef Name)
Create a new runtime global variable with the specified type and name.
void AdjustMemoryAttribute(StringRef Name, CGCalleeInfo CalleeInfo, llvm::AttributeList &Attrs)
Adjust Memory attribute to ensure that the BE gets the right attribute.
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.
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...
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...
const llvm::abi::TargetInfo & getLLVMABITargetInfo(llvm::abi::TypeBuilder &TB)
Lazily build and return the LLVMABI library's TargetInfo for the current target.
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)
void noteDirectGlobalDelete()
Note that global operator delete is directly used in this TU.
llvm::Constant * GetAddrOfGlobal(GlobalDecl GD, ForDefinition_t IsForDefinition=NotForDefinition)
AtomicOptions getAtomicOpts()
Get the current Atomic options.
ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal)
Return a pointer to a constant CFString object for the given string.
InstrProfStats & getPGOStats()
ProfileList::ExclusionType isFunctionBlockedFromProfileInstr(llvm::Function *Fn, SourceLocation Loc) const
void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV)
Add global annotations that are set on D, for the global GV.
void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const
Set the TLS mode for the given LLVM GlobalValue for the thread-local variable declaration D.
ItaniumVTableContext & getItaniumVTableContext()
ConstantAddress GetAddrOfConstantStringFromLiteral(const StringLiteral *S, StringRef Name=".str")
Return a pointer to a constant array for the given string literal.
ASTContext & getContext() const
ConstantAddress GetAddrOfTemplateParamObject(const TemplateParamObjectDecl *TPO)
Get the address of a template parameter object.
void EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D)
Emit a code for threadprivate directive.
llvm::Constant * getNSConcreteStackBlock()
ConstantAddress GetAddrOfUnnamedGlobalConstantDecl(const UnnamedGlobalConstantDecl *GCD)
Get the address of a UnnamedGlobalConstant.
TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo, TBAAAccessInfo TargetInfo)
mergeTBAAInfoForCast - Get merged TBAA information for the purposes of type casts.
llvm::Constant * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr, ForDefinition_t IsForDefinition=NotForDefinition)
Return the llvm::Constant for the address of the given global variable.
MicrosoftVTableContext & getMicrosoftVTableContext()
const HeaderSearchOptions & getHeaderSearchOpts() const
QualType ReconstructCallGraphPrototype(const FunctionNoProtoType *FNPT, ArrayRef< QualType > ParamTypes) const
Reconstructs a FunctionProtoType for an unprototyped function type (FunctionNoProtoType) using the gi...
llvm::SanitizerStatReport & getSanStats()
llvm::Constant * EmitAnnotationString(StringRef Str)
Emit an annotation string.
llvm::Type * getVTableComponentType() const
void EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare mapper construct.
llvm::Function * getLLVMLifetimeEndFn()
Lazily declare the @llvm.lifetime.end intrinsic.
bool supportsCOMDAT() const
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.
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD)
Tell the consumer that this variable has been instantiated.
bool shouldHavePreconditionInline(const ObjCMethodDecl *OMD) const
Check if a direct method should have inline precondition checks at call sites.
bool ReturnTypeUsesSRet(const CGFunctionInfo &FI)
Return true iff the given type uses 'sret' when used as a return type.
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 ...
std::optional< CharUnits > getOMPAllocateAlignment(const VarDecl *VD)
Return the alignment specified in an allocate directive, if present.
llvm::GlobalVariable * CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, llvm::GlobalValue::LinkageTypes Linkage, llvm::Align Alignment)
Will return a global variable of the given type.
llvm::FunctionCallee getTerminateFn()
Get the declaration of std::terminate for the platform.
CharUnits getNaturalPointeeTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
llvm::FunctionCallee getBlockObjectDispose()
TBAAAccessInfo mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA, TBAAAccessInfo InfoB)
mergeTBAAInfoForConditionalOperator - Get merged TBAA information for the purposes of conditional ope...
std::string getMangledNameIgnoringAsmLabel(GlobalDecl GD, const NamedDecl *ND)
llvm::LLVMContext & getLLVMContext()
llvm::GlobalValue * GetGlobalValue(StringRef Ref)
bool shouldZeroInitPadding() const
void GenKernelArgMetadata(llvm::Function *FN, const FunctionDecl *FD=nullptr, CodeGenFunction *CGF=nullptr)
OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument information in the program executab...
void setKCFIType(const FunctionDecl *FD, llvm::Function *F)
Set type metadata to the given function.
void setAtomicGetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO)
void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare reduction construct.
const ItaniumVTableContext & getItaniumVTableContext() const
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys={})
void AddDetectMismatch(StringRef Name, StringRef Value)
Appends a detect mismatch command to the linker options.
void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
llvm::Value * createOpenCLIntToSamplerConversion(const Expr *E, CodeGenFunction &CGF)
ConstantAddress GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, const Expr *Inner)
Returns a pointer to a global variable representing a temporary with static or thread storage duratio...
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
LangAS GetGlobalConstantAddressSpace() const
Return the AST address space of constant literal, which is used to emit the constant literal as globa...
LangAS GetGlobalVarAddressSpace(const VarDecl *D)
Return the AST address space of the underlying global variable for D, as determined by its declaratio...
llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD)
Return the appropriate linkage for the vtable, VTT, and type information of the given class.
void SetLLVMFunctionAttributes(GlobalDecl GD, const CGFunctionInfo &Info, llvm::Function *F, bool IsThunk)
Set the LLVM function attributes (sext, zext, etc).
void addDeferredVTable(const CXXRecordDecl *RD)
llvm::Type * getGenericBlockLiteralType()
The type of a generic block literal.
void EmitOpenACCRoutine(const OpenACCRoutineDecl *D, CodeGenFunction *CGF=nullptr)
void emitGlobalDeleteForwardingBodies()
Emit __global_delete forwarding bodies for any pending variants, if this TU directly uses global oper...
CharUnits getMinimumObjectSize(QualType Ty)
Returns the minimum object size for an object of the given type.
void addReplacement(StringRef Name, llvm::Constant *C)
std::optional< CGPointerAuthInfo > getVTablePointerAuthInfo(CodeGenFunction *Context, const CXXRecordDecl *Record, llvm::Value *StorageAddress, bool IsVTTEntry=false)
llvm::Constant * getConstantSignedPointer(llvm::Constant *Pointer, const PointerAuthSchema &Schema, llvm::Constant *StorageAddress, GlobalDecl SchemaDecl, QualType SchemaType)
Sign a constant pointer using the given scheme, producing a constant with the same IR type.
llvm::FunctionCallee IsPlatformVersionAtLeastFn
void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535, unsigned LexOrder=~0U, llvm::Constant *AssociatedData=nullptr)
AddGlobalCtor - Add a function to the list that will be called before main() runs.
llvm::Metadata * CreateMetadataIdentifierForFnType(QualType T)
Create a metadata identifier for the given function type.
bool shouldSignPointer(const PointerAuthSchema &Schema)
Does a given PointerAuthScheme require us to sign a value.
void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F)
Set the LLVM function attributes which only apply to a function definition.
llvm::Metadata * CreateMetadataIdentifierForVirtualMemPtrType(QualType T)
Create a metadata identifier that is intended to be used to check virtual calls via a member function...
bool shouldUseLLVMABILowering(unsigned CallingConv) const
True when -fexperimental-abi-lowering is in effect AND the active target has an LLVMABI implementatio...
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...
ConstantAddress GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *)
Return a pointer to a constant array for the given ObjCEncodeExpr node.
const GlobalDecl getMangledNameDecl(StringRef)
void ClearUnusedCoverageMapping(const Decl *D)
Remove the deferred empty coverage mapping as this declaration is actually instrumented.
void EmitTopLevelDecl(Decl *D)
Emit code for a single top level declaration.
llvm::Function * CreateGlobalInitOrCleanUpFunction(llvm::FunctionType *ty, const Twine &name, const CGFunctionInfo &FI, SourceLocation Loc=SourceLocation(), bool TLS=false, llvm::GlobalVariable::LinkageTypes Linkage=llvm::GlobalVariable::InternalLinkage)
llvm::Constant * EmitAnnotationUnit(SourceLocation Loc)
Emit the annotation's translation unit.
CGPointerAuthInfo getPointerAuthInfoForType(QualType type)
ConstantAddress GetAddrOfConstantCString(const std::string &Str, StringRef GlobalName=".str")
Returns a pointer to a character array containing the literal and a terminating '\0' character.
std::vector< Structor > CtorList
void printPostfixForExternalizedDecl(llvm::raw_ostream &OS, const Decl *D) const
Print the postfix for externalized static variable or kernels for single source offloading languages ...
llvm::Constant * GetAddrOfThunk(StringRef Name, llvm::Type *FnTy, GlobalDecl GD)
Get the address of the thunk for the given global decl.
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.
A specialization of Address that requires the address to be an LLVM Constant.
ValueOpt(unsigned InitVal)
CounterPair(unsigned Val)
May be None.
Organizes the cross-function state that is used while generating code coverage mapping data.
This class records statistics on instrumentation based profiling.
bool hasDiagnostics()
Whether or not the stats we've gathered indicate any potential problems.
void addMissing(bool MainFile)
Record that a function we've visited has no profile data.
void addMismatched(bool MainFile)
Record that a function we've visited has mismatched profile data.
void addVisited(bool MainFile)
Record that we've visited a function and whether or not that function was in the main source file.
void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile)
Report potential problems we've found to Diags.
LValue - This represents an lvalue references.
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Helper class for stores the "trap reason" built by.
CompoundLiteralExpr - [C99 6.5.2.5].
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...
Represents a ValueDecl that came out of a declarator.
Concrete class used by the front-end to report problems and issues.
ExplicitCastExpr - An explicit cast written in the source code.
This represents one expression.
Represents a member of a struct/union/class.
Represents a function declaration or definition.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
FunctionType - C99 6.7.5.3 - Function Declarators.
GlobalDecl - represents a global declaration.
const Decl * getDecl() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
clang::ObjCRuntime ObjCRuntime
bool hasDefaultVisibilityExportMapping() const
bool isExplicitDefaultVisibilityExportMapping() const
bool isAllDefaultVisibilityExportMapping() const
bool isTargetDevice() const
True when compiling for an offloading target device.
bool isVisibilityExplicit() const
Represents a linkage specification.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Describes a module or submodule.
This represents a decl that may have a name.
LinkageInfo getLinkageAndVisibility() const
Determines the linkage and visibility of this entity.
This represents 'pragma omp allocate ...' directive.
This represents 'pragma omp declare mapper ...' directive.
This represents 'pragma omp declare reduction ...' directive.
This represents 'pragma omp requires...' directive.
This represents 'pragma omp threadprivate ...' directive.
ObjCEncodeExpr, used for @encode in Objective-C.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
ObjCMethodDecl - Represents an instance or class method declaration.
bool isDirectMethod() const
True if the method is tagged as objc_direct.
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
bool allowsDirectDispatch() const
Does this runtime supports direct dispatch.
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.
A (possibly-)qualified type.
Represents a struct/union/class.
Encodes a location in the source.
Stmt - This represents one statement.
StringLiteral - This represents a string literal expression, e.g.
Represents the declaration of a struct/union/class/enum.
Exposes information about the current target.
uint64_t getPointerAlign(LangAS AddrSpace) const
A template parameter object.
A declaration that models statements at global scope.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
Defines the clang::TargetInfo interface.
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
@ 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.
static const FunctionDecl * getCallee(const CXXConstructExpr &D)
Top level wrappers for InstallAPI frontend operations.
GVALinkage
A more specific kind of linkage than enum Linkage.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ 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.
const FunctionProtoType * T
LangAS
Defines the address space values used by the address space qualifier of QualType.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Visibility
Describes the different kinds of visibility that a declaration may have.
@ HiddenVisibility
Objects with "hidden" visibility are not seen by the dynamic linker.
@ ProtectedVisibility
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
@ DefaultVisibility
Objects with "default" visibility are seen by the dynamic linker and act like normal objects.
Diagnostic wrappers for TextAPI types for error reporting.
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 __packed_splat4 uint16_t
llvm::Constant * Initializer
Structor(int Priority, unsigned LexOrder, llvm::Constant *Initializer, llvm::Constant *AssociatedData)
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()