14 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
15 #define LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
31 #include "llvm/ADT/DenseMap.h"
32 #include "llvm/ADT/SetVector.h"
33 #include "llvm/ADT/SmallPtrSet.h"
34 #include "llvm/ADT/StringMap.h"
35 #include "llvm/IR/Module.h"
36 #include "llvm/IR/ValueHandle.h"
37 #include "llvm/Transforms/Utils/SanitizerStats.h"
48 class IndexedInstrProfReader;
57 class ObjCImplementationDecl;
58 class ObjCCategoryImplDecl;
59 class ObjCProtocolDecl;
73 class HeaderSearchOptions;
74 class PreprocessorOptions;
75 class DiagnosticsEngine;
77 class CXXDestructorDecl;
79 class CoverageSourceInfo;
84 class CodeGenFunction;
89 class CGOpenCLRuntime;
92 class BlockFieldFlags;
93 class FunctionArgList;
94 class CoverageMappingModuleGen;
95 class TargetCodeGenInfo;
183 uint32_t VisitedInMainFile;
184 uint32_t MissingInMainFile;
191 : VisitedInMainFile(0), MissingInMainFile(0), Visited(0), Missing(0),
231 void Profile(llvm::FoldingSetNodeID &
id)
const {
235 virtual void profileImpl(llvm::FoldingSetNodeID &
id)
const = 0;
255 : Priority(Priority), Initializer(Initializer),
256 AssociatedData(AssociatedData) {}
270 llvm::Module &TheModule;
273 std::unique_ptr<CGCXXABI> ABI;
274 llvm::LLVMContext &VMContext;
276 std::unique_ptr<CodeGenTBAA> TBAA;
278 mutable std::unique_ptr<TargetCodeGenInfo> TheTargetCodeGenInfo;
289 std::unique_ptr<CGOpenCLRuntime> OpenCLRuntime;
290 std::unique_ptr<CGOpenMPRuntime> OpenMPRuntime;
291 std::unique_ptr<CGCUDARuntime> CUDARuntime;
292 std::unique_ptr<CGDebugInfo> DebugInfo;
293 std::unique_ptr<ObjCEntrypoints> ObjCData;
294 llvm::MDNode *NoObjCARCExceptionsMetadata =
nullptr;
295 std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader;
297 std::unique_ptr<llvm::SanitizerStatReport> SanStats;
302 llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences;
308 std::map<StringRef, GlobalDecl> DeferredDecls;
312 struct DeferredGlobal {
313 DeferredGlobal(llvm::GlobalValue *GV,
GlobalDecl GD) : GV(GV), GD(GD) {}
314 llvm::TrackingVH<llvm::GlobalValue> GV;
317 std::vector<DeferredGlobal> DeferredDeclsToEmit;
318 void addDeferredDeclToEmit(llvm::GlobalValue *GV,
GlobalDecl GD) {
319 DeferredDeclsToEmit.emplace_back(GV, GD);
324 std::vector<GlobalDecl> Aliases;
326 typedef llvm::StringMap<llvm::TrackingVH<llvm::Constant> > ReplacementsTy;
327 ReplacementsTy Replacements;
333 GlobalValReplacements;
341 std::vector<const CXXRecordDecl*> DeferredVTables;
346 std::vector<llvm::WeakVH> LLVMUsed;
347 std::vector<llvm::WeakVH> LLVMCompilerUsed;
358 llvm::MapVector<GlobalDecl, StringRef> MangledDeclNames;
359 llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> Manglings;
362 std::vector<llvm::Constant*> Annotations;
365 llvm::StringMap<llvm::Constant*> AnnotationStrings;
367 llvm::StringMap<llvm::GlobalVariable *> CFConstantStringMap;
369 llvm::DenseMap<llvm::Constant *, llvm::GlobalVariable *> ConstantStringMap;
370 llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap;
371 llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap;
372 llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap;
374 llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap;
375 llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap;
378 llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap;
383 llvm::GlobalValue *> StaticExternCMap;
384 StaticExternCMap StaticExternCValues;
387 std::vector<const VarDecl *> CXXThreadLocals;
391 std::vector<llvm::Function *> CXXThreadLocalInits;
392 std::vector<const VarDecl *> CXXThreadLocalInitVars;
395 std::vector<llvm::Function *> CXXGlobalInits;
402 llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition;
404 typedef std::pair<OrderGlobalInits, llvm::Function*> GlobalInitData;
406 struct GlobalInitPriorityCmp {
407 bool operator()(
const GlobalInitData &LHS,
408 const GlobalInitData &RHS)
const {
409 return LHS.first.priority < RHS.first.priority;
415 SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits;
418 std::vector<std::pair<llvm::WeakVH,llvm::Constant*> > CXXGlobalDtors;
421 llvm::SetVector<clang::Module *> ImportedModules;
424 SmallVector<llvm::Metadata *, 16> LinkerOptionsMetadata;
431 llvm::WeakVH CFConstantStringClassRef;
435 llvm::WeakVH ConstantStringClassRef;
438 llvm::StructType *NSConstantStringType =
nullptr;
442 QualType ObjCFastEnumerationStateType;
447 void createObjCRuntime();
449 void createOpenCLRuntime();
450 void createOpenMPRuntime();
451 void createCUDARuntime();
453 bool isTriviallyRecursive(
const FunctionDecl *F);
454 bool shouldEmitFunction(GlobalDecl GD);
459 llvm::Constant *NSConcreteGlobalBlock =
nullptr;
460 llvm::Constant *NSConcreteStackBlock =
nullptr;
462 llvm::Constant *BlockObjectAssign =
nullptr;
463 llvm::Constant *BlockObjectDispose =
nullptr;
466 llvm::Type *GenericBlockLiteralType =
nullptr;
473 llvm::Constant *LifetimeStartFn =
nullptr;
476 llvm::Constant *LifetimeEndFn =
nullptr;
480 std::unique_ptr<SanitizerMetadata> SanitizerMD;
484 llvm::DenseMap<const Decl *, bool> DeferredEmptyCoverageMappingDecls;
486 std::unique_ptr<CoverageMappingModuleGen> CoverageMapping;
491 llvm::DenseMap<QualType, llvm::Metadata *> MetadataIdMap;
518 assert(OpenCLRuntime !=
nullptr);
519 return *OpenCLRuntime;
524 assert(OpenMPRuntime !=
nullptr);
525 return *OpenMPRuntime;
530 assert(CUDARuntime !=
nullptr);
535 assert(ObjCData !=
nullptr);
540 llvm::IndexedInstrProfReader *
getPGOReader()
const {
return PGOReader.get(); }
543 return CoverageMapping.get();
547 return StaticLocalDeclMap[D];
551 StaticLocalDeclMap[D] = C;
556 llvm::GlobalValue::LinkageTypes
Linkage);
559 return StaticLocalDeclGuardMap[D];
562 llvm::GlobalVariable *C) {
563 StaticLocalDeclGuardMap[D] = C;
570 return AtomicSetterHelperFnMap[Ty];
573 llvm::Constant *Fn) {
574 AtomicSetterHelperFnMap[Ty] = Fn;
578 return AtomicGetterHelperFnMap[Ty];
581 llvm::Constant *Fn) {
582 AtomicGetterHelperFnMap[Ty] = Fn;
586 return TypeDescriptorMap[Ty];
589 TypeDescriptorMap[Ty] = C;
595 if (!NoObjCARCExceptionsMetadata)
597 return NoObjCARCExceptionsMetadata;
603 const {
return HeaderSearchOpts; }
605 const {
return PreprocessorOpts; }
610 return TheModule.getDataLayout();
656 llvm::MDNode *TBAAInfo,
657 bool ConvertTypeToTag =
true);
679 llvm_unreachable(
"unknown visibility!");
688 llvm::GlobalVariable *
690 llvm::GlobalValue::LinkageTypes
Linkage);
712 bool IsForDefinition =
false);
717 bool ForVTable =
false,
718 bool DontDefer =
false,
719 bool IsForDefinition =
false);
788 StringRef
Name =
".str");
801 const char *GlobalName =
nullptr);
826 llvm::FunctionType *FnType =
nullptr,
827 bool DontDefer =
false,
bool IsForDefinition =
false);
857 template<
typename SomeDecl>
868 CXXGlobalDtors.emplace_back(DtorFn, Object);
874 llvm::AttributeSet ExtraAttrs =
875 llvm::AttributeSet());
879 llvm::AttributeSet ExtraAttrs =
880 llvm::AttributeSet());
1029 llvm::GlobalValue::LinkageTypes
1031 bool IsConstantVariable);
1034 llvm::GlobalValue::LinkageTypes
1057 const AnnotateAttr *AA,
1068 StringRef
Category = StringRef())
const;
1071 return SanitizerMD.get();
1075 DeferredVTables.push_back(RD);
1151 bool ForVTable,
bool DontDefer =
false,
1152 bool IsThunk =
false,
1153 llvm::AttributeSet ExtraAttrs = llvm::AttributeSet(),
1154 bool IsForDefinition =
false);
1156 llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName,
1157 llvm::PointerType *PTy,
1159 bool IsForDefinition =
false);
1161 void setNonAliasAttributes(
const Decl *D, llvm::GlobalObject *GO);
1164 void SetFunctionAttributes(
GlobalDecl GD, llvm::Function *F,
1165 bool IsIncompleteFunction,
bool IsThunk);
1167 void EmitGlobalDefinition(
GlobalDecl D, llvm::GlobalValue *GV =
nullptr);
1169 void EmitGlobalFunctionDefinition(
GlobalDecl GD, llvm::GlobalValue *GV);
1170 void EmitGlobalVarDefinition(
const VarDecl *D,
bool IsTentative =
false);
1183 void EmitCXXThreadLocalInitFunc();
1186 void EmitCXXGlobalInitFunc();
1189 void EmitCXXGlobalDtorFunc();
1193 void EmitCXXGlobalVarDeclInitFunc(
const VarDecl *D,
1194 llvm::GlobalVariable *Addr,
1197 void EmitPointerToInitFunc(
const VarDecl *VD, llvm::GlobalVariable *Addr,
1198 llvm::Function *InitFunc, InitSegAttr *ISA);
1201 void AddGlobalCtor(llvm::Function *Ctor,
int Priority = 65535,
1202 llvm::Constant *AssociatedData =
nullptr);
1203 void AddGlobalDtor(llvm::Function *Dtor,
int Priority = 65535);
1208 void EmitCtorList(
const CtorList &Fns,
const char *GlobalName);
1211 void EmitDeferred();
1214 void applyReplacements();
1217 void applyGlobalValReplacements();
1219 void checkAliases();
1222 void EmitDeferredVTables();
1225 void emitLLVMUsed();
1228 void EmitModuleLinkOptions();
1232 void EmitStaticExternCAliases();
1234 void EmitDeclMetadata();
1237 void EmitVersionIdentMetadata();
1240 void EmitTargetMetadata();
1244 void EmitCoverageFile();
1247 llvm::Constant *EmitUuidofInitializer(StringRef uuidstr);
1257 bool MayBeEmittedEagerly(
const ValueDecl *D);
1261 void SimplifyPersonality();
1266 #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.
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.
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...
NamespaceDecl - Represent a C++ namespace.
llvm::Constant * objc_loadWeakRetained
id objc_loadWeakRetained(id*);
const PreprocessorOptions & getPreprocessorOpts() const
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.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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 * CreateBuiltinFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeSet ExtraAttrs=llvm::AttributeSet())
Create a new compiler builtin function with the specified type and name.
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);
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.
llvm::Constant * GetAddrOfGlobal(GlobalDecl GD, bool IsForDefinition=false)
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
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
id 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)
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
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)
llvm::Constant * CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeSet ExtraAttrs=llvm::AttributeSet())
Create a new runtime function with the specified type and name.
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 * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr, bool IsForDefinition=false)
Return the llvm::Constant for the address of the given global variable.
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 * 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.
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.
llvm::Constant * getAddrOfCXXStructor(const CXXMethodDecl *MD, StructorType Type, const CGFunctionInfo *FnInfo=nullptr, llvm::FunctionType *FnType=nullptr, bool DontDefer=false, bool IsForDefinition=false)
Return the address of the constructor/destructor of the given type.
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)
llvm::Value * getBuiltinLibFunction(const FunctionDecl *FD, unsigned BuiltinID)
Given a builtin id for a function like "__builtin_fabsf", return a Function* for "fabsf".
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...
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
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(...);
ConstantAddress GetAddrOfConstantString(const StringLiteral *Literal)
Return a pointer to a constant NSString object for the given string.
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
void UpdateCompletedType(const TagDecl *TD)
detail::InMemoryDirectory::const_iterator E
unsigned GetGlobalVarAddressSpace(const VarDecl *D, unsigned AddrSpace)
Return the address space of the underlying global variable for D, as determined by its declaration...
const llvm::Triple & getTriple() const
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 "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 * GetAddrOfGlobalBlock(const BlockExpr *BE, const char *)
Gets the address of a block which requires no captures.
StringRef getMangledName(GlobalDecl GD)
virtual void emitDispose(CodeGenFunction &CGF, Address field)=0
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.
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 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...
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)
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.
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.
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 ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info, CGCalleeInfo CalleeInfo, AttributeListType &PAL, unsigned &CallingConv, bool AttrOnCallSite)
Get the LLVM attributes and calling convention to use for a particular function type.
llvm::Constant * objc_retainAutoreleaseReturnValue
id objc_retainAutoreleaseReturnValue(id);
llvm::Constant * GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty=nullptr, bool ForVTable=false, bool DontDefer=false, bool IsForDefinition=false)
Return the address of the given function.
This represents '#pragma omp threadprivate ...' directive.
void EmitGlobal(GlobalDecl D)
Emit code for a singal global function or var decl.
CGCalleeInfo - Class to encapsulate the information about a callee to be used during the generation o...
void AddDependentLib(StringRef Lib)
Appends a dependent lib to the "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()