14 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
15 #define LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
32 #include "llvm/ADT/DenseMap.h"
33 #include "llvm/ADT/SetVector.h"
34 #include "llvm/ADT/SmallPtrSet.h"
35 #include "llvm/ADT/StringMap.h"
36 #include "llvm/IR/Module.h"
37 #include "llvm/IR/ValueHandle.h"
38 #include "llvm/Transforms/Utils/SanitizerStats.h"
49 class IndexedInstrProfReader;
58 class ObjCImplementationDecl;
59 class ObjCCategoryImplDecl;
60 class ObjCProtocolDecl;
74 class HeaderSearchOptions;
75 class PreprocessorOptions;
76 class DiagnosticsEngine;
78 class CXXDestructorDecl;
80 class CoverageSourceInfo;
85 class CodeGenFunction;
90 class CGOpenCLRuntime;
93 class BlockFieldFlags;
94 class FunctionArgList;
95 class CoverageMappingModuleGen;
96 class TargetCodeGenInfo;
189 uint32_t VisitedInMainFile;
190 uint32_t MissingInMainFile;
197 : VisitedInMainFile(0), MissingInMainFile(0), Visited(0), Missing(0),
237 void Profile(llvm::FoldingSetNodeID &
id)
const {
241 virtual void profileImpl(llvm::FoldingSetNodeID &
id)
const = 0;
261 : Priority(Priority), Initializer(Initializer),
262 AssociatedData(AssociatedData) {}
276 llvm::Module &TheModule;
279 std::unique_ptr<CGCXXABI> ABI;
280 llvm::LLVMContext &VMContext;
282 std::unique_ptr<CodeGenTBAA> TBAA;
284 mutable std::unique_ptr<TargetCodeGenInfo> TheTargetCodeGenInfo;
295 std::unique_ptr<CGOpenCLRuntime> OpenCLRuntime;
296 std::unique_ptr<CGOpenMPRuntime> OpenMPRuntime;
297 std::unique_ptr<CGCUDARuntime> CUDARuntime;
298 std::unique_ptr<CGDebugInfo> DebugInfo;
299 std::unique_ptr<ObjCEntrypoints> ObjCData;
300 llvm::MDNode *NoObjCARCExceptionsMetadata =
nullptr;
301 std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader;
303 std::unique_ptr<llvm::SanitizerStatReport> SanStats;
308 llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences;
314 std::map<StringRef, GlobalDecl> DeferredDecls;
318 std::vector<GlobalDecl> DeferredDeclsToEmit;
320 DeferredDeclsToEmit.emplace_back(GD);
325 std::vector<GlobalDecl> Aliases;
327 typedef llvm::StringMap<llvm::TrackingVH<llvm::Constant> > ReplacementsTy;
328 ReplacementsTy Replacements;
334 GlobalValReplacements;
342 std::vector<const CXXRecordDecl*> DeferredVTables;
345 std::vector<const CXXRecordDecl *> OpportunisticVTables;
350 std::vector<llvm::WeakTrackingVH> LLVMUsed;
351 std::vector<llvm::WeakTrackingVH> LLVMCompilerUsed;
362 llvm::MapVector<GlobalDecl, StringRef> MangledDeclNames;
363 llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> Manglings;
366 std::vector<llvm::Constant*> Annotations;
369 llvm::StringMap<llvm::Constant*> AnnotationStrings;
371 llvm::StringMap<llvm::GlobalVariable *> CFConstantStringMap;
373 llvm::DenseMap<llvm::Constant *, llvm::GlobalVariable *> ConstantStringMap;
374 llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap;
375 llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap;
376 llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap;
378 llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap;
379 llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap;
382 llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap;
387 llvm::GlobalValue *> StaticExternCMap;
388 StaticExternCMap StaticExternCValues;
391 std::vector<const VarDecl *> CXXThreadLocals;
395 std::vector<llvm::Function *> CXXThreadLocalInits;
396 std::vector<const VarDecl *> CXXThreadLocalInitVars;
399 std::vector<llvm::Function *> CXXGlobalInits;
406 llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition;
408 typedef std::pair<OrderGlobalInits, llvm::Function*> GlobalInitData;
410 struct GlobalInitPriorityCmp {
411 bool operator()(
const GlobalInitData &LHS,
412 const GlobalInitData &RHS)
const {
413 return LHS.first.priority < RHS.first.priority;
419 SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits;
422 std::vector<std::pair<llvm::WeakTrackingVH, llvm::Constant *>> CXXGlobalDtors;
425 llvm::SetVector<clang::Module *> ImportedModules;
429 llvm::SmallPtrSet<clang::Module *, 16> EmittedModuleInitializers;
432 SmallVector<llvm::MDNode *, 16> LinkerOptionsMetadata;
439 llvm::WeakTrackingVH CFConstantStringClassRef;
443 QualType ObjCFastEnumerationStateType;
448 void createObjCRuntime();
450 void createOpenCLRuntime();
451 void createOpenMPRuntime();
452 void createCUDARuntime();
454 bool isTriviallyRecursive(
const FunctionDecl *F);
455 bool shouldEmitFunction(GlobalDecl GD);
456 bool shouldOpportunisticallyEmitVTables();
458 llvm::DenseMap<const CompoundLiteralExpr *, llvm::GlobalVariable *>
459 EmittedCompoundLiterals;
463 llvm::DenseMap<const BlockExpr *, llvm::Constant *> EmittedGlobalBlocks;
468 llvm::Constant *NSConcreteGlobalBlock =
nullptr;
469 llvm::Constant *NSConcreteStackBlock =
nullptr;
471 llvm::Constant *BlockObjectAssign =
nullptr;
472 llvm::Constant *BlockObjectDispose =
nullptr;
475 llvm::Type *GenericBlockLiteralType =
nullptr;
482 llvm::Constant *LifetimeStartFn =
nullptr;
485 llvm::Constant *LifetimeEndFn =
nullptr;
489 std::unique_ptr<SanitizerMetadata> SanitizerMD;
493 llvm::DenseMap<const Decl *, bool> DeferredEmptyCoverageMappingDecls;
495 std::unique_ptr<CoverageMappingModuleGen> CoverageMapping;
500 llvm::DenseMap<QualType, llvm::Metadata *> MetadataIdMap;
527 assert(OpenCLRuntime !=
nullptr);
528 return *OpenCLRuntime;
533 assert(OpenMPRuntime !=
nullptr);
534 return *OpenMPRuntime;
539 assert(CUDARuntime !=
nullptr);
544 assert(ObjCData !=
nullptr);
553 llvm::IndexedInstrProfReader *
getPGOReader()
const {
return PGOReader.get(); }
556 return CoverageMapping.get();
560 return StaticLocalDeclMap[D];
564 StaticLocalDeclMap[D] = C;
569 llvm::GlobalValue::LinkageTypes
Linkage);
572 return StaticLocalDeclGuardMap[D];
575 llvm::GlobalVariable *C) {
576 StaticLocalDeclGuardMap[D] = C;
583 return AtomicSetterHelperFnMap[Ty];
586 llvm::Constant *Fn) {
587 AtomicSetterHelperFnMap[Ty] = Fn;
591 return AtomicGetterHelperFnMap[Ty];
594 llvm::Constant *Fn) {
595 AtomicGetterHelperFnMap[Ty] = Fn;
599 return TypeDescriptorMap[Ty];
602 TypeDescriptorMap[Ty] = C;
608 if (!NoObjCARCExceptionsMetadata)
610 return NoObjCARCExceptionsMetadata;
616 const {
return HeaderSearchOpts; }
618 const {
return PreprocessorOpts; }
623 return TheModule.getDataLayout();
669 llvm::MDNode *TBAAInfo,
670 bool ConvertTypeToTag =
true);
692 llvm_unreachable(
"unknown visibility!");
703 llvm::GlobalVariable *
705 llvm::GlobalValue::LinkageTypes
Linkage);
737 bool ForVTable =
false,
738 bool DontDefer =
false,
798 return EmittedGlobalBlocks.lookup(BE);
819 StringRef
Name =
".str");
832 const char *GlobalName =
nullptr);
840 llvm::GlobalVariable *
846 llvm::GlobalVariable *GV);
867 llvm::FunctionType *FnType =
nullptr,
868 bool DontDefer =
false,
899 template<
typename SomeDecl>
910 CXXGlobalDtors.emplace_back(DtorFn, Object);
916 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
922 llvm::AttributeList ExtraAttrs = llvm::AttributeList());
1029 llvm::AttributeList &Attrs,
unsigned &
CallingConv,
1030 bool AttrOnCallSite);
1092 llvm::GlobalValue::LinkageTypes
1094 bool IsConstantVariable);
1097 llvm::GlobalValue::LinkageTypes
1120 const AnnotateAttr *AA,
1131 StringRef
Category = StringRef())
const;
1137 StringRef
Category = StringRef())
const;
1140 return SanitizerMD.get();
1144 DeferredVTables.push_back(RD);
1226 llvm::Constant *GetOrCreateLLVMFunction(
1228 bool DontDefer =
false,
bool IsThunk =
false,
1229 llvm::AttributeList ExtraAttrs = llvm::AttributeList(),
1232 llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName,
1233 llvm::PointerType *PTy,
1238 void setNonAliasAttributes(
const Decl *D, llvm::GlobalObject *GO);
1241 void SetFunctionAttributes(
GlobalDecl GD, llvm::Function *F,
1242 bool IsIncompleteFunction,
bool IsThunk);
1244 void EmitGlobalDefinition(
GlobalDecl D, llvm::GlobalValue *GV =
nullptr);
1246 void EmitGlobalFunctionDefinition(
GlobalDecl GD, llvm::GlobalValue *GV);
1247 void EmitGlobalVarDefinition(
const VarDecl *D,
bool IsTentative =
false);
1259 void EmitCXXThreadLocalInitFunc();
1262 void EmitCXXGlobalInitFunc();
1265 void EmitCXXGlobalDtorFunc();
1269 void EmitCXXGlobalVarDeclInitFunc(
const VarDecl *D,
1270 llvm::GlobalVariable *Addr,
1273 void EmitPointerToInitFunc(
const VarDecl *VD, llvm::GlobalVariable *Addr,
1274 llvm::Function *InitFunc, InitSegAttr *ISA);
1277 void AddGlobalCtor(llvm::Function *Ctor,
int Priority = 65535,
1278 llvm::Constant *AssociatedData =
nullptr);
1279 void AddGlobalDtor(llvm::Function *Dtor,
int Priority = 65535);
1284 void EmitCtorList(
CtorList &Fns,
const char *GlobalName);
1287 void EmitDeferred();
1293 void EmitVTablesOpportunistically();
1296 void applyReplacements();
1299 void applyGlobalValReplacements();
1301 void checkAliases();
1304 void EmitDeferredVTables();
1308 void emitAtAvailableLinkGuard();
1311 void emitLLVMUsed();
1314 void EmitModuleLinkOptions();
1318 void EmitStaticExternCAliases();
1320 void EmitDeclMetadata();
1323 void EmitVersionIdentMetadata();
1326 void EmitTargetMetadata();
1329 void EmitOpenCLMetadata();
1333 void EmitCoverageFile();
1336 llvm::Constant *EmitUuidofInitializer(StringRef uuidstr);
1346 bool MayBeEmittedEagerly(
const ValueDecl *D);
1350 void SimplifyPersonality();
1354 void ConstructDefaultFnAttrList(StringRef Name,
bool HasOptnone,
1355 bool AttrOnCallSite,
1356 llvm::AttrBuilder &FuncAttrs);
1361 #endif // LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
CGOpenCLRuntime & getOpenCLRuntime()
Return a reference to the configured OpenCL runtime.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
llvm::Type * getGenericBlockLiteralType()
The type of a generic block literal.
void EmitDeferredUnusedCoverageMappings()
Emit all the deferred coverage mappings for the uninstrumented functions.
void DecorateInstructionWithInvariantGroup(llvm::Instruction *I, const CXXRecordDecl *RD)
Adds !invariant.barrier !tag to instruction.
ObjCEntrypoints & getObjCEntrypoints() const
void Profile(llvm::FoldingSetNodeID &id) const
void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C)
A (possibly-)qualified type.
bool ReturnTypeUsesSRet(const CGFunctionInfo &FI)
Return true iff the given type uses 'sret' when used as a return type.
CodeGenTypes & getTypes()
llvm::Constant * AssociatedData
bool hasObjCRuntime()
Return true iff an Objective-C runtime has been configured.
llvm::Module & getModule() const
llvm::Constant * getMemberPointerConstant(const UnaryOperator *e)
llvm::LLVMContext & getLLVMContext()
ConstantAddress GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *)
Return a pointer to a constant array for the given ObjCEncodeExpr node.
llvm::Constant * CopyHelper
CharUnits getClassPointerAlignment(const CXXRecordDecl *CD)
Returns the assumed alignment of an opaque pointer to the given class.
Stmt - This represents one statement.
unsigned GetGlobalVarAddressSpace(const VarDecl *D)
Return the AST address space of the underlying global variable for D, as determined by its declaratio...
Implements runtime-specific code generation functions.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Defines the clang::Module class, which describes a module in the source code.
Decl - This represents one declaration (or definition), e.g.
llvm::Constant * objc_autoreleaseReturnValue
id objc_autoreleaseReturnValue(id);
llvm::MDNode * getTBAAStructInfo(QualType QTy)
BlockByrefHelpers(CharUnits alignment)
void setAliasAttributes(const Decl *D, llvm::GlobalValue *GV)
Set attributes which must be preserved by an alias.
const llvm::DataLayout & getDataLayout() const
The base class of the type hierarchy.
void setFunctionLinkage(GlobalDecl GD, llvm::Function *F)
Stores additional source code information like skipped ranges which is required by the coverage mappi...
llvm::Constant * objc_loadWeakRetained
id objc_loadWeakRetained(id*);
const PreprocessorOptions & getPreprocessorOpts() const
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
bool HasHiddenLTOVisibility(const CXXRecordDecl *RD)
Returns whether the given record has hidden LTO visibility and therefore may participate in (single-m...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
CtorList & getGlobalCtors()
bool operator==(const OrderGlobalInits &RHS) const
bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D)
Try to emit a base destructor as an alias to its primary base-class destructor.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V)
llvm::Constant * EmitConstantValue(const APValue &Value, QualType DestType, CodeGenFunction *CGF=nullptr)
Emit the given constant value as a constant, in the type's scalar representation. ...
const CXXBaseSpecifier *const * path_const_iterator
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD)
Tell the consumer that this variable has been instantiated.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Objects with "hidden" visibility are not seen by the dynamic linker.
CompoundLiteralExpr - [C99 6.5.2.5].
void setFunctionDefinitionAttributes(const FunctionDecl *D, llvm::Function *F)
Set attributes for a global definition.
CGDebugInfo * getModuleDebugInfo()
void setFunctionDLLStorageClass(GlobalDecl GD, llvm::Function *F)
Set the DLL storage class on F.
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const
Return the store size, in character units, of the given LLVM type.
llvm::Constant * getAtomicSetterHelperFnMap(QualType Ty)
bool NeedAllVtablesTypeId() const
Returns whether this module needs the "all-vtables" type identifier.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
llvm::Constant * EmitConstantValueForMemory(const APValue &Value, QualType DestType, CodeGenFunction *CGF=nullptr)
Emit the given constant value as a constant, in the type's memory representation. ...
llvm::Constant * objc_autorelease
id objc_autorelease(id);
llvm::GlobalVariable * getStaticLocalDeclGuardAddress(const VarDecl *D)
llvm::Constant * objc_copyWeak
void objc_copyWeak(id *dest, id *src);
llvm::Constant * getAtomicGetterHelperFnMap(QualType Ty)
One of these records is kept for each identifier that is lexed.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Constant * objc_loadWeak
id objc_loadWeak(id*);
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
llvm::Constant * objc_retainAutoreleasedReturnValue
id objc_retainAutoreleasedReturnValue(id);
llvm::Constant * getAddrOfCXXStructor(const CXXMethodDecl *MD, StructorType Type, 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 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...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
llvm::Function * codegenCXXStructor(const CXXMethodDecl *MD, StructorType Type)
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
bool isPaddedAtomicType(QualType type)
Objects with "default" visibility are seen by the dynamic linker and act like normal objects...
llvm::Constant * GetConstantArrayFromStringLiteral(const StringLiteral *E)
Return a constant array for the given string.
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 * getLLVMLifetimeStartFn()
Lazily declare the .lifetime.start intrinsic.
virtual void profileImpl(llvm::FoldingSetNodeID &id) const =0
bool operator<(const OrderGlobalInits &RHS) const
CGCUDARuntime & getCUDARuntime()
Return a reference to the configured CUDA runtime.
llvm::Constant * objc_initWeak
id objc_initWeak(id*, id);
CharUnits - This is an opaque type for sizes expressed in character units.
void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare reduction construct.
Structor(int Priority, llvm::Constant *Initializer, llvm::Constant *AssociatedData)
Visibility
Describes the different kinds of visibility that a declaration may have.
void setStaticLocalDeclAddress(const VarDecl *D, llvm::Constant *C)
Concrete class used by the front-end to report problems and issues.
llvm::Constant * objc_release
void objc_release(id);
ConstantAddress GetAddrOfConstantString(const StringLiteral *Literal)
Return a pointer to a constant NSString object for the given string.
void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info, CGCalleeInfo CalleeInfo, llvm::AttributeList &Attrs, unsigned &CallingConv, bool AttrOnCallSite)
Get the LLVM attributes and calling convention to use for a particular function type.
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...
void addDeferredVTable(const CXXRecordDecl *RD)
void setAtomicGetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
llvm::Constant * getTerminateFn()
Get the declaration of std::terminate for the platform.
void addMissing(bool MainFile)
Record that a function we've visited has no profile data.
void addCompilerUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.compiler.used metadata.
Enums/classes describing ABI related information about constructors, destructors and thunks...
llvm::Constant * CreateRuntimeVariable(llvm::Type *Ty, StringRef Name)
Create a new runtime global variable with the specified type and name.
ItaniumVTableContext & getItaniumVTableContext()
void EmitTentativeDefinition(const VarDecl *D)
llvm::SanitizerStatReport & getSanStats()
Represents a linkage specification.
void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const
Set the visibility for the given LLVM GlobalValue.
detail::InMemoryDirectory::const_iterator I
llvm::Constant * getNSConcreteStackBlock()
llvm::Constant * Initializer
llvm::Constant * CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false)
Create a new runtime function with the specified type and name.
InstrProfStats & getPGOStats()
bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor)
isTypeConstant - Determine whether an object of this type can be emitted as a constant.
const HeaderSearchOptions & getHeaderSearchOpts() const
llvm::Constant * getStaticLocalDeclAddress(const VarDecl *D)
const TargetCodeGenInfo & getTargetCodeGenInfo()
llvm::Constant * objc_storeStrong
void objc_storeStrong(id*, id);
virtual void emitCopy(CodeGenFunction &CGF, Address dest, Address src)=0
void AddDetectMismatch(StringRef Name, StringRef Value)
Appends a detect mismatch command to the linker options.
const TargetInfo & getTarget() const
Represents a ValueDecl that came out of a declarator.
CtorList & getGlobalDtors()
bool shouldUseTBAA() const
StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD)
llvm::Constant * getNullPointer(llvm::PointerType *T, QualType QT)
Get target specific null pointer.
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *FD)
Exposes information about the current target.
void DecorateInstructionWithTBAA(llvm::Instruction *Inst, llvm::MDNode *TBAAInfo, bool ConvertTypeToTag=true)
Decorate the instruction with a TBAA tag.
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
void SetLLVMFunctionAttributes(const Decl *D, const CGFunctionInfo &Info, llvm::Function *F)
Set the LLVM function attributes (sext, zext, etc).
llvm::Constant * EmitAnnotationUnit(SourceLocation Loc)
Emit the annotation's translation unit.
CharUnits Alignment
The alignment of the field.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
Defines the clang::LangOptions interface.
llvm::Constant * objc_autoreleasePoolPop
void objc_autoreleasePoolPop(void*);
virtual bool needsCopy() const
CGCXXABI & getCXXABI() const
void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV)
Add global annotations that are set on D, for the global GV.
llvm::Constant * DisposeHelper
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.
void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
Organizes the cross-function state that is used while generating code coverage mapping data...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents a C++ destructor within a class.
void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile)
Report potential problems we've found to Diags.
void AddCXXDtorEntry(llvm::Constant *DtorFn, llvm::Constant *Object)
Add a destructor and object to add to the C++ global destructor function.
llvm::Constant * objc_retain
id objc_retain(id);
ASTContext & getContext() const
void setStaticLocalDeclGuardAddress(const VarDecl *D, llvm::GlobalVariable *C)
MicrosoftVTableContext & getMicrosoftVTableContext()
bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI)
Return true iff the given type uses an argument slot when 'sret' is used as a return type...
llvm::GlobalValue::LinkageTypes getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant)
Returns LLVM linkage for a declarator.
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
void addMismatched(bool MainFile)
Record that a function we've visited has mismatched profile data.
llvm::Constant * EmitAnnotationString(StringRef Str)
Emit an annotation string.
ConstantAddress GetAddrOfUuidDescriptor(const CXXUuidofExpr *E)
Get the address of a uuid descriptor .
llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
CGOpenMPRuntime(CodeGenModule &CGM)
void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset, const CXXRecordDecl *RD)
Create and attach type metadata for the given vtable.
bool lookupRepresentativeDecl(StringRef MangledName, GlobalDecl &Result) const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
GlobalDecl - represents a global declaration.
llvm::GlobalVariable * CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, llvm::GlobalValue::LinkageTypes Linkage)
Will return a global variable of the given type.
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::Constant * GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk)
Get the address of the thunk for the given global decl.
ConstantAddress GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, const Expr *Inner)
Returns a pointer to a global variable representing a temporary with static or thread storage duratio...
void addVisited(bool MainFile)
Record that we've visited a function and whether or not that function was in the main source file...
The l-value was considered opaque, so the alignment was determined from a type.
llvm::Constant * objc_retainBlock
id objc_retainBlock(id);
llvm::Constant * getOrCreateStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
void RefreshTypeCacheForClass(const CXXRecordDecl *Class)
bool ReturnTypeUsesFPRet(QualType ResultType)
Return true iff the given type uses 'fpret' when used as a return type.
llvm::Constant * objc_storeWeak
id objc_storeWeak(id*, id);
void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV)
If the declaration has internal linkage but is inside an extern "C" linkage specification, prepare to emit an alias for it to the expected name.
llvm::Constant * EmitConstantExpr(const Expr *E, QualType DestType, CodeGenFunction *CGF=nullptr)
Try to emit the given expression as a constant; returns 0 if the expression cannot be emitted as a co...
Encodes a location in the source.
llvm::Constant * getTypeDescriptorFromMap(QualType Ty)
This represents '#pragma omp declare reduction ...' directive.
ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal)
Return a pointer to a constant CFString object for the given string.
TagDecl - Represents the declaration of a struct/union/class/enum.
llvm::Metadata * CreateMetadataIdentifierForType(QualType T)
Create a metadata identifier for the given type.
llvm::Constant * objc_autoreleasePoolPush
void *objc_autoreleasePoolPush(void);
Represents a static or instance method of a struct/union/class.
ConstantAddress GetAddrOfConstantStringFromLiteral(const StringLiteral *S, StringRef Name=".str")
Return a pointer to a constant array for the given string literal.
llvm::Constant * EmitNullConstantForBase(const CXXRecordDecl *Record)
Return a null constant appropriate for zero-initializing a base class with the given type...
This file defines OpenMP nodes for declarative directives.
llvm::Constant * CreateBuiltinFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList())
Create a new compiler builtin function with the specified type and name.
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
llvm::MDNode * getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN, uint64_t O)
Return the path-aware tag for given base type, access node and offset.
llvm::InlineAsm * retainAutoreleasedReturnValueMarker
A void(void) inline asm to use to mark that the return value of a call will be immediately retain...
const CodeGenOptions & getCodeGenOpts() const
void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C)
ConstantAddress GetWeakRefReference(const ValueDecl *VD)
Get a reference to the target of VD.
llvm::Constant * getBlockObjectDispose()
const LangOptions & getLangOpts() const
void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F)
Set the LLVM function attributes which only apply to a function definition.
void EmitTopLevelDecl(Decl *D)
Emit code for a single top level declaration.
llvm::GlobalVariable * getAddrOfConstantCompoundLiteralIfEmitted(const CompoundLiteralExpr *E)
If it's been emitted already, returns the GlobalVariable corresponding to a compound literal...
void CreateFunctionTypeMetadata(const FunctionDecl *FD, llvm::Function *F)
Create and attach type metadata to the given function.
llvm::Constant * EmitAnnotationLineNo(SourceLocation L)
Emit the annotation line number.
virtual bool needsDispose() const
ItaniumVTableContext & getItaniumVTableContext()
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues, like target-specific attributes, builtins and so on.
bool ReturnTypeUsesFP2Ret(QualType ResultType)
Return true iff the given type uses 'fp2ret' when used as a return type.
void Error(SourceLocation loc, StringRef error)
Emit a general error that something can't be done.
llvm::Constant * getLLVMLifetimeEndFn()
Lazily declare the .lifetime.end intrinsic.
std::vector< Structor > CtorList
void addReplacement(StringRef Name, llvm::Constant *C)
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...
llvm::Constant * GetAddrOfGlobal(GlobalDecl GD, ForDefinition_t IsForDefinition=NotForDefinition)
void addUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.used metadata.
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
llvm::Constant * objc_unsafeClaimAutoreleasedReturnValue
id objc_unsafeClaimAutoreleasedReturnValue(id);
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
llvm::GlobalValue * GetGlobalValue(StringRef Ref)
llvm::FoldingSet< BlockByrefHelpers > ByrefHelpersCache
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
int getUniqueBlockCount()
Fetches the global unique block count.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The basic abstraction for the target Objective-C runtime.
void EmitVTableTypeMetadata(llvm::GlobalVariable *VTable, const VTableLayout &VTLayout)
Emit type metadata for the given vtable using the given layout.
bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target, bool InEveryTU)
Try to emit a definition as a global alias for another definition.
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...
void EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D)
Emit a code for threadprivate directive.
llvm::Constant * objc_destroyWeak
void objc_destroyWeak(id*);
llvm::Constant * clang_arc_use
void clang.arc.use(...);
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
void UpdateCompletedType(const TagDecl *TD)
detail::InMemoryDirectory::const_iterator E
ExplicitCastExpr - An explicit cast written in the source code.
void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO)
CharUnits getVBaseAlignment(CharUnits DerivedAlign, const CXXRecordDecl *Derived, const CXXRecordDecl *VBase)
Returns the assumed alignment of a virtual base of a class.
bool isInSanitizerBlacklist(llvm::Function *Fn, SourceLocation Loc) const
void AddDeferredUnusedCoverageMapping(Decl *D)
Stored a deferred empty coverage mapping for an unused and thus uninstrumented top level declaration...
llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD)
Return the appropriate linkage for the vtable, VTT, and type information of the given class...
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
void EmitExplicitCastExprType(const ExplicitCastExpr *E, CodeGenFunction *CGF=nullptr)
Emit type info if type of an expression is a variably modified type.
void AppendLinkerOptions(StringRef Opts)
Appends Opts to the "llvm.linker.options" metadata value.
Implements C++ ABI-specific code generation functions.
ObjCEncodeExpr, used for @encode in Objective-C.
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
bool hasDiagnostics()
Whether or not the stats we've gathered indicate any potential problems.
This class records statistics on instrumentation based profiling.
llvm::Constant * objc_retainAutorelease
id objc_retainAutorelease(id);
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
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.
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.
StringRef getMangledName(GlobalDecl GD)
virtual void emitDispose(CodeGenFunction &CGF, Address field)=0
llvm::Value * createOpenCLIntToSamplerConversion(const Expr *E, CodeGenFunction &CGF)
llvm::Constant * getBlockObjectAssign()
void setAtomicSetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
ConstantAddress GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *E)
Returns a pointer to a constant global variable for the given file-scope compound literal expression...
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
llvm::Constant * EmitConstantInit(const VarDecl &D, CodeGenFunction *CGF=nullptr)
Try to emit the initializer for the given declaration as a constant; returns 0 if the expression cann...
llvm::MDNode * getNoObjCARCExceptionsMetadata()
llvm::Constant * objc_moveWeak
void objc_moveWeak(id *dest, id *src);
llvm::ConstantInt * getSize(CharUnits numChars)
Emit the given number of characters as a value of type size_t.
A pair of helper functions for a __block variable.
void setAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *CLE, llvm::GlobalVariable *GV)
Notes that CLE's GlobalVariable is GV.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
MicrosoftVTableContext & getMicrosoftVTableContext()
DiagnosticsEngine & getDiags() const
Represents a C++ struct/union/class.
llvm::Function * CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty, const Twine &name, const CGFunctionInfo &FI, SourceLocation Loc=SourceLocation(), bool TLS=false)
A specialization of Address that requires the address to be an LLVM Constant.
void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr)
Notes that BE's global block is available via Addr.
void Release()
Finalize LLVM code generation.
void ClearUnusedCoverageMapping(const Decl *D)
Remove the deferred empty coverage mapping as this declaration is actually instrumented.
void EmitGlobalAnnotations()
Emit all the global annotations.
virtual ~BlockByrefHelpers()
llvm::ConstantInt * CreateCrossDsoCfiTypeId(llvm::Metadata *MD)
Generate a cross-DSO type identifier for MD.
OrderGlobalInits(unsigned int p, unsigned int l)
void SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV)
Set attributes which are common to any form of a global definition (alias, Objective-C method...
llvm::Constant * getBuiltinLibFunction(const FunctionDecl *FD, unsigned BuiltinID)
Given a builtin id for a function like "__builtin_fabsf", return a Function* for "fabsf".
StringLiteral - This represents a string literal expression, e.g.
CharUnits computeNonVirtualBaseClassOffset(const CXXRecordDecl *DerivedClass, CastExpr::path_const_iterator Start, CastExpr::path_const_iterator End)
llvm::MDNode * getTBAAInfo(QualType QTy)
llvm::Constant * IsOSVersionAtLeastFn
QualType getObjCFastEnumerationStateType()
Retrieve the record type that describes the state of an Objective-C fast enumeration loop (for...
GVALinkage
A more specific kind of linkage than enum Linkage.
const llvm::Triple & getTriple() const
This structure provides a set of types that are commonly used during IR emission. ...
CoverageMappingModuleGen * getCoverageMapping() const
llvm::Constant * getNSConcreteGlobalBlock()
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.
CodeGenVTables & getVTables()
NamedDecl - This represents a decl with a name.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
SanitizerMetadata * getSanitizerMetadata()
llvm::IndexedInstrProfReader * getPGOReader() const
void AddDefaultFnAttrs(llvm::Function &F)
Adds attributes to F according to our CodeGenOptions and LangOptions, as though we had emitted it our...
llvm::Constant * objc_retainAutoreleaseReturnValue
id objc_retainAutoreleaseReturnValue(id);
This represents '#pragma omp threadprivate ...' directive.
void EmitGlobal(GlobalDecl D)
Emit code for a singal global function or var decl.
Abstract information about a function or function prototype.
void AddDependentLib(StringRef Lib)
Appends a dependent lib to the "llvm.linker.options" metadata value.
llvm::GlobalValue::LinkageTypes getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable)
Returns LLVM linkage for a declarator.
bool supportsCOMDAT() const
void EmitVTable(CXXRecordDecl *Class)
This is a callback from Sema to tell us that that a particular vtable is required to be emitted in th...
llvm::MDNode * getTBAAInfoForVTablePtr()