Go to the documentation of this file.
20 #include "llvm/ADT/StringExtras.h"
21 #include "llvm/IR/Intrinsics.h"
22 #include "llvm/IR/MDBuilder.h"
23 #include "llvm/Support/Path.h"
25 using namespace clang;
26 using namespace CodeGen;
33 "VarDecl must have global or local (in the case of OpenCL) storage!");
35 "Should not call EmitDeclInit on a reference!");
65 llvm_unreachable(
"bad evaluation kind");
93 assert(!D.
getTLSKind() &&
"should have rejected this");
97 llvm::FunctionCallee Func;
98 llvm::Constant *Argument;
108 bool CanRegisterDestructor =
116 if (Record && (CanRegisterDestructor || UsingExternalHelper)) {
128 Argument = llvm::ConstantExpr::getBitCast(Addr.
getPointer(), DestTy);
132 Argument = llvm::ConstantPointerNull::get(DestTy);
134 Argument = llvm::ConstantExpr::getBitCast(
143 Argument = llvm::Constant::getNullValue(CGF.
Int8PtrTy);
152 llvm::Constant *Addr) {
166 llvm::Function *InvariantStart =
CGM.
getIntrinsic(InvStartID, ObjectPtr);
169 uint64_t Width = Size.getQuantity();
170 llvm::Value *Args[2] = { llvm::ConstantInt::getSigned(
Int64Ty, Width),
171 llvm::ConstantExpr::getBitCast(Addr,
Int8PtrTy)};
172 Builder.CreateCall(InvariantStart, Args);
176 llvm::GlobalVariable *GV,
198 unsigned ActualAddrSpace = GV->getAddressSpace();
199 llvm::Constant *DeclPtr = GV;
200 if (ActualAddrSpace != ExpectedAddrSpace) {
201 llvm::PointerType *PTy = llvm::PointerType::getWithSamePointeeType(
202 GV->getType(), ExpectedAddrSpace);
203 DeclPtr = llvm::ConstantExpr::getAddrSpaceCast(DeclPtr, PTy);
207 DeclPtr, GV->getValueType(),
getContext().getDeclAlign(&D));
211 D.
hasAttr<OMPThreadPrivateDeclAttr>()) {
213 &D, DeclAddr, D.
getAttr<OMPThreadPrivateDeclAttr>()->getLocation(),
225 assert(PerformInit &&
"cannot have constant initializer which needs "
226 "destruction for reference");
234 llvm::FunctionCallee dtor,
235 llvm::Constant *addr) {
237 llvm::FunctionType *ty = llvm::FunctionType::get(
CGM.
VoidTy,
false);
240 llvm::raw_svector_ostream Out(FnName);
256 llvm::CallInst *call = CGF.
Builder.CreateCall(dtor, addr);
259 if (
auto *dtorFn = dyn_cast<llvm::Function>(
260 dtor.getCallee()->stripPointerCastsAndAliases()))
261 call->setCallingConv(dtorFn->getCallingConv());
271 const VarDecl &D, llvm::FunctionCallee Dtor, llvm::Constant *Addr,
272 llvm::FunctionCallee &AtExit) {
275 llvm::raw_svector_ostream Out(FnName);
284 llvm::FunctionType *StubTy =
285 llvm::FunctionType::get(
CGM.
IntTy, {CGM.IntTy},
true);
295 Args.push_back(&IPD);
304 llvm::CallInst *call = CGF.
Builder.CreateCall(Dtor, Addr);
307 if (
auto *DtorFn = dyn_cast<llvm::Function>(
308 Dtor.getCallee()->stripPointerCastsAndAliases()))
309 call->setCallingConv(DtorFn->getCallingConv());
322 llvm::FunctionCallee dtor,
323 llvm::Constant *addr) {
331 assert(dtorStub->getType() ==
332 llvm::PointerType::get(
333 llvm::FunctionType::get(
CGM.
VoidTy,
false),
334 dtorStub->getType()->getPointerAddressSpace()) &&
335 "Argument to atexit has a wrong type.");
337 llvm::FunctionType *atexitTy =
338 llvm::FunctionType::get(
IntTy, dtorStub->getType(),
false);
340 llvm::FunctionCallee atexit =
343 if (llvm::Function *atexitFn = dyn_cast<llvm::Function>(atexit.getCallee()))
344 atexitFn->setDoesNotThrow();
358 assert(dtorStub->getType() ==
359 llvm::PointerType::get(
360 llvm::FunctionType::get(
CGM.
VoidTy,
false),
361 dtorStub->getType()->getPointerAddressSpace()) &&
362 "Argument to unatexit has a wrong type.");
364 llvm::FunctionType *unatexitTy =
365 llvm::FunctionType::get(
IntTy, {dtorStub->getType()},
false);
367 llvm::FunctionCallee unatexit =
370 cast<llvm::Function>(unatexit.getCallee())->setDoesNotThrow();
376 llvm::GlobalVariable *DeclPtr,
383 "this initialization requires a guard variable, which "
384 "the kernel does not support");
390 llvm::BasicBlock *InitBlock,
391 llvm::BasicBlock *NoInitBlock,
398 static const uint64_t InitsPerTLSVar = 1024;
399 static const uint64_t InitsPerLocalVar = 1024 * 1024;
401 llvm::MDNode *Weights;
413 NumInits = InitsPerTLSVar;
415 NumInits = InitsPerLocalVar;
420 Weights = MDHelper.createBranchWeights(1, NumInits - 1);
423 Builder.CreateCondBr(NeedsInit, InitBlock, NoInitBlock, Weights);
427 llvm::FunctionType *FTy,
const Twine &Name,
const CGFunctionInfo &FI,
429 llvm::Function *Fn = llvm::Function::Create(FTy,
Linkage, Name, &
getModule());
433 if (
const char *Section =
getTarget().getStaticInitSectionSpecifier())
434 Fn->setSection(Section);
443 Fn->setDoesNotThrow();
445 if (
getLangOpts().Sanitize.has(SanitizerKind::Address) &&
447 Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
449 if (
getLangOpts().Sanitize.has(SanitizerKind::KernelAddress) &&
451 Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
453 if (
getLangOpts().Sanitize.has(SanitizerKind::HWAddress) &&
455 Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
457 if (
getLangOpts().Sanitize.has(SanitizerKind::KernelHWAddress) &&
459 Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
461 if (
getLangOpts().Sanitize.has(SanitizerKind::MemtagStack) &&
463 Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
465 if (
getLangOpts().Sanitize.has(SanitizerKind::Thread) &&
467 Fn->addFnAttr(llvm::Attribute::SanitizeThread);
469 if (
getLangOpts().Sanitize.has(SanitizerKind::Memory) &&
471 Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
473 if (
getLangOpts().Sanitize.has(SanitizerKind::KernelMemory) &&
475 Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
477 if (
getLangOpts().Sanitize.has(SanitizerKind::SafeStack) &&
479 Fn->addFnAttr(llvm::Attribute::SafeStack);
481 if (
getLangOpts().Sanitize.has(SanitizerKind::ShadowCallStack) &&
483 Fn->addFnAttr(llvm::Attribute::ShadowCallStack);
491 void CodeGenModule::EmitPointerToInitFunc(
const VarDecl *D,
492 llvm::GlobalVariable *GV,
493 llvm::Function *InitFunc,
495 llvm::GlobalVariable *PtrArray =
new llvm::GlobalVariable(
496 TheModule, InitFunc->getType(),
true,
497 llvm::GlobalValue::PrivateLinkage, InitFunc,
"__cxx_init_fn_ptr");
498 PtrArray->setSection(ISA->getSection());
502 if (llvm::Comdat *C = GV->getComdat())
503 PtrArray->setComdat(C);
507 CodeGenModule::EmitCXXGlobalVarDeclInitFunc(
const VarDecl *D,
508 llvm::GlobalVariable *Addr,
517 (D->
hasAttr<CUDADeviceAttr>() || D->
hasAttr<CUDAConstantAttr>() ||
526 auto I = DelayedCXXInitPosition.find(D);
527 if (I != DelayedCXXInitPosition.end() && I->second == ~0
U)
530 llvm::FunctionType *FTy = llvm::FunctionType::get(
VoidTy,
false);
533 llvm::raw_svector_ostream Out(FnName);
541 auto *ISA = D->
getAttr<InitSegAttr>();
545 llvm::GlobalVariable *COMDATKey =
552 CXXThreadLocalInits.push_back(Fn);
553 CXXThreadLocalInitVars.push_back(D);
554 }
else if (PerformInit && ISA) {
555 EmitPointerToInitFunc(D, Addr, Fn, ISA);
556 }
else if (
auto *IPA = D->
getAttr<InitPriorityAttr>()) {
558 PrioritizedCXXGlobalInits.size());
559 PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn));
580 AddGlobalCtor(Fn, 65535, COMDATKey);
581 if (COMDATKey && (
getTriple().isOSBinFormatELF() ||
591 llvm::Comdat *
C = Addr->getComdat();
592 if (COMDATKey && C &&
598 I = DelayedCXXInitPosition.find(D);
599 if (I == DelayedCXXInitPosition.end()) {
600 CXXGlobalInits.push_back(Fn);
601 }
else if (I->second != ~0
U) {
602 assert(I->second < CXXGlobalInits.size() &&
603 CXXGlobalInits[I->second] ==
nullptr);
604 CXXGlobalInits[I->second] = Fn;
609 DelayedCXXInitPosition[D] = ~0
U;
612 void CodeGenModule::EmitCXXThreadLocalInitFunc() {
614 *
this, CXXThreadLocals, CXXThreadLocalInits, CXXThreadLocalInitVars);
616 CXXThreadLocalInits.clear();
617 CXXThreadLocalInitVars.clear();
618 CXXThreadLocals.clear();
624 if (FileName.empty())
627 for (
size_t i = 0; i < FileName.size(); ++i) {
638 assert(
Priority <= 65535 &&
"Priority should always be <= 65535.");
643 PrioritySuffix =
std::string(6 - PrioritySuffix.size(),
'0') + PrioritySuffix;
645 return PrioritySuffix;
649 CodeGenModule::EmitCXXGlobalInitFunc() {
650 while (!CXXGlobalInits.empty() && !CXXGlobalInits.back())
651 CXXGlobalInits.pop_back();
653 if (CXXGlobalInits.empty() && PrioritizedCXXGlobalInits.empty())
656 llvm::FunctionType *FTy = llvm::FunctionType::get(
VoidTy,
false);
660 if (!PrioritizedCXXGlobalInits.empty()) {
662 llvm::array_pod_sort(PrioritizedCXXGlobalInits.begin(),
663 PrioritizedCXXGlobalInits.end());
668 I = PrioritizedCXXGlobalInits.begin(),
669 E = PrioritizedCXXGlobalInits.end(); I != E; ) {
671 PrioE = std::upper_bound(I + 1, E, *I, GlobalInitPriorityCmp());
673 LocalCXXGlobalInits.clear();
675 unsigned int Priority = I->first.priority;
679 for (; I < PrioE; ++I)
680 LocalCXXGlobalInits.push_back(I->second);
685 PrioritizedCXXGlobalInits.clear();
688 if (
getCXXABI().useSinitAndSterm() && CXXGlobalInits.empty())
711 Fn->setCallingConv(llvm::CallingConv::SPIR_KERNEL);
717 Fn->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
718 Fn->addFnAttr(
"device-init");
721 CXXGlobalInits.clear();
724 void CodeGenModule::EmitCXXGlobalCleanUpFunc() {
725 if (CXXGlobalDtorsOrStermFinalizers.empty() &&
726 PrioritizedCXXStermFinalizers.empty())
729 llvm::FunctionType *FTy = llvm::FunctionType::get(
VoidTy,
false);
733 if (!PrioritizedCXXStermFinalizers.empty()) {
735 llvm::array_pod_sort(PrioritizedCXXStermFinalizers.begin(),
736 PrioritizedCXXStermFinalizers.end());
741 I = PrioritizedCXXStermFinalizers.begin(),
742 E = PrioritizedCXXStermFinalizers.end();
745 std::upper_bound(I + 1, E, *I, StermFinalizerPriorityCmp());
747 LocalCXXStermFinalizers.clear();
749 unsigned int Priority = I->first.priority;
753 for (; I < PrioE; ++I) {
754 llvm::FunctionCallee DtorFn = I->second;
755 LocalCXXStermFinalizers.emplace_back(DtorFn.getFunctionType(),
756 DtorFn.getCallee(),
nullptr);
760 Fn, LocalCXXStermFinalizers);
763 PrioritizedCXXStermFinalizers.clear();
766 if (CXXGlobalDtorsOrStermFinalizers.empty())
774 Fn, CXXGlobalDtorsOrStermFinalizers);
776 CXXGlobalDtorsOrStermFinalizers.clear();
782 llvm::GlobalVariable *Addr,
803 if (Addr->hasWeakLinkage() || Addr->hasLinkOnceLinkage() ||
825 llvm::BasicBlock *ExitBlock =
nullptr;
830 llvm::Value *Uninit =
Builder.CreateIsNull(GuardVal,
831 "guard.uninitialized");
858 for (
unsigned i = 0, e = Decls.size(); i != e; ++i)
862 Scope.ForceCleanup();
875 ArrayRef<std::tuple<llvm::FunctionType *, llvm::WeakTrackingVH,
877 DtorsOrStermFinalizers) {
886 for (
unsigned i = 0, e = DtorsOrStermFinalizers.size(); i != e; ++i) {
887 llvm::FunctionType *CalleeTy;
890 std::tie(CalleeTy, Callee, Arg) = DtorsOrStermFinalizers[e - i - 1];
892 llvm::CallInst *CI =
nullptr;
893 if (Arg ==
nullptr) {
896 "Arg could not be nullptr unless using sinit and sterm functions.");
897 CI =
Builder.CreateCall(CalleeTy, Callee);
899 CI =
Builder.CreateCall(CalleeTy, Callee, Arg);
902 if (llvm::Function *F = dyn_cast<llvm::Function>(Callee))
903 CI->setCallingConv(F->getCallingConv());
915 bool useEHCleanupForArray,
const VarDecl *VD) {
919 args.push_back(&Dst);
925 FTy,
"__cxx_global_array_dtor", FI, VD->
getLocation());
virtual bool canCallMismatchedFunctionType() const
Returns true if the target allows calling a function through a pointer with a different signature tha...
bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor)
isTypeConstant - Determine whether an object of this type can be emitted as a constant.
@ InternalLinkage
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
llvm::Type * ConvertTypeForMem(QualType T)
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
void EmitObjCAutoreleasePoolCleanup(llvm::Value *Ptr)
ConstantAddress getElementBitCast(llvm::Type *ElemTy) const
llvm::PointerType * Int8PtrTy
A specialization of Address that requires the address to be an LLVM Constant.
TLSKind getTLSKind() const
llvm::IntegerType * IntTy
int
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
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.
SourceLocation getBeginLoc() const LLVM_READONLY
static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D, ConstantAddress Addr)
Emit code to cause the destruction of the given variable with static storage duration.
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
void EmitCXXGuardedInitBranch(llvm::Value *NeedsInit, llvm::BasicBlock *InitBlock, llvm::BasicBlock *NoInitBlock, GuardKind Kind, const VarDecl *D)
Emit a branch to select whether or not to perform guarded initialization.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
virtual bool HasThisReturn(GlobalDecl GD) const
Returns true if the given constructor or destructor is one of the kinds that the ABI says returns 'th...
static void EmitDeclInit(CodeGenFunction &CGF, const VarDecl &D, ConstantAddress DeclPtr)
void addUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.used metadata.
static std::string getPrioritySuffix(unsigned int Priority)
llvm::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
bool isExternallyVisible() const
Encodes a location in the source.
void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
MangleContext & getMangleContext()
Gets the mangle context.
void GenerateCXXGlobalInitFunc(llvm::Function *Fn, ArrayRef< llvm::Function * > CXXThreadLocals, ConstantAddress Guard=ConstantAddress::invalid())
GenerateCXXGlobalInitFunc - Generates code for initializing global variables.
virtual void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D, llvm::GlobalVariable *DeclPtr, bool PerformInit)=0
Emits the guarded initializer and destructor setup for the given variable, given that it couldn't be ...
A (possibly-)qualified type.
unsigned getTargetAddressSpace(QualType T) const
virtual void mangleDynamicAtExitDestructor(const VarDecl *D, raw_ostream &)=0
ASTContext & getContext() const
static SmallString< 128 > getTransformedFileName(llvm::Module &M)
llvm::Value * unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub)
Call unatexit() with function dtorStub.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
const CGFunctionInfo & arrangeBuiltinFunctionDeclaration(QualType resultType, const FunctionArgList &args)
A builtin function is a freestanding function using the default C conventions.
const LangOptions & getLangOpts() const
virtual void registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D, llvm::FunctionCallee Dtor, llvm::Constant *Addr)=0
Emit code to force the execution of a destructor during global teardown.
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)
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, AlignmentSource Source=AlignmentSource::Type, bool isInit=false, bool isNontemporal=false)
EmitStoreOfScalar - Store a scalar value to an address, taking care to appropriately convert from the...
const TargetCodeGenInfo & getTargetCodeGenInfo()
static void EmitDeclInvariant(CodeGenFunction &CGF, const VarDecl &D, llvm::Constant *Addr)
Emit code to cause the variable at the given address to be considered as constant from this point onw...
LLVM_READONLY bool isPreprocessingNumberBody(unsigned char c)
Return true if this is the body character of a C preprocessing number, which is [a-zA-Z0-9_.
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
@ Dtor_Complete
Complete object dtor.
The base class of the type hierarchy.
llvm::PointerType * VoidPtrTy
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
GlobalDecl - represents a global declaration.
LangAS getAddressSpace() const
llvm::Value * EmitObjCAutoreleasePoolPush()
Produce the code to do a objc_autoreleasepool_push.
virtual LangAS getAddrSpaceOfCxaAtexitPtrParam() const
Get address space of pointer parameter for __cxa_atexit.
bool isReferenceType() const
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited.
void GenOpenCLArgMetadata(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...
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
void emitDestroy(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
emitDestroy - Immediately perform the destruction of the given object.
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
const CGFunctionInfo & arrangeLLVMFunctionInfo(CanQualType returnType, bool instanceMethod, bool chainCall, ArrayRef< CanQualType > argTypes, FunctionType::ExtInfo info, ArrayRef< FunctionProtoType::ExtParameterInfo > paramInfos, RequiredArgs args)
"Arrange" the LLVM information for a call or type with the given signature.
Scope - A scope is a transient data structure that is used while parsing the program.
llvm::Function * generateDestroyHelper(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray, const VarDecl *VD)
generateDestroyHelper - Generates a helper function which, when invoked, destroys the given object.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
llvm::IntegerType * Int64Ty
const CodeGenOptions & getCodeGenOpts() const
llvm::CallInst * EmitRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
void EmitInvariantStart(llvm::Constant *Addr, CharUnits Size)
void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn, const VarDecl *D, llvm::GlobalVariable *Addr, bool PerformInit)
Emit the code necessary to initialize the given global variable.
llvm::Module & getModule() const
Represents a C++ destructor within a class.
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind.
Represents a variable declaration or definition.
void registerGlobalDtorWithAtExit(const VarDecl &D, llvm::FunctionCallee fn, llvm::Constant *addr)
Call atexit() with a function that passes the given argument to the given function.
bool isObjCStrong() const
CodeGenTypes & getTypes()
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
ASTContext & getContext() const
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
llvm::FunctionCallee getAddrAndTypeOfCXXStructor(GlobalDecl GD, const CGFunctionInfo *FnInfo=nullptr, llvm::FunctionType *FnType=nullptr, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
const TargetInfo & getTarget() const
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
const llvm::DataLayout & getDataLayout() const
void StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, const CGFunctionInfo &FnInfo, const FunctionArgList &Args, SourceLocation Loc=SourceLocation(), SourceLocation StartLoc=SourceLocation())
Emit code for the start of a function.
Represents a C++ struct/union/class.
LValue - This represents an lvalue references.
void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr, bool PerformInit)
Emit code in this function to perform a guarded variable initialization.
llvm::Function * createAtExitStub(const VarDecl &VD, llvm::FunctionCallee Dtor, llvm::Constant *Addr)
Create a stub function, suitable for being passed to atexit, which passes the given address to the gi...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
virtual void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest)=0
CGCXXABI & getCXXABI() const
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
This class organizes the cross-function state that is used while generating LLVM code.
@ DK_objc_strong_lifetime
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
const llvm::Triple & getTriple() const
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type.
static AggValueSlot forLValue(const LValue &LV, CodeGenFunction &CGF, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
llvm::CallingConv::ID getRuntimeCC() const
FunctionArgList - Type for representing both the decl and type of parameters to a function.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
CodeGenTypes & getTypes() const
const Expr * getInit() const
A class which abstracts out some details necessary for making a call.
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
bool supportsCOMDAT() const
virtual void mangleDynamicInitializer(const VarDecl *D, raw_ostream &)=0
llvm::Constant * getPointer() const
CGFunctionInfo - Class to encapsulate the information about a function definition.
void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::GlobalVariable *GV, bool PerformInit)
EmitCXXGlobalVarDeclInit - Create the initializer for a C++ variable with global storage.
llvm::Function * createTLSAtExitStub(const VarDecl &VD, llvm::FunctionCallee Dtor, llvm::Constant *Addr, llvm::FunctionCallee &AtExit)
Create a stub function, suitable for being passed to __pt_atexit_np, which passes the given address t...
@ TLS_Dynamic
TLS with a dynamic initializer.
static ApplyDebugLocation CreateArtificial(CodeGenFunction &CGF)
Apply TemporaryLocation if it is valid.
void GenerateCXXGlobalCleanUpFunc(llvm::Function *Fn, ArrayRef< std::tuple< llvm::FunctionType *, llvm::WeakTrackingVH, llvm::Constant * >> DtorsOrStermFinalizers)
GenerateCXXGlobalCleanUpFunc - Generates code for cleaning up global variables.
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF)
Set the IRBuilder to not attach debug locations.
virtual void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest, bool threadlocal=false)=0
virtual bool useSinitAndSterm() const
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
CharUnits - This is an opaque type for sizes expressed in character units.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
virtual llvm::Function * emitThreadPrivateVarDefinition(const VarDecl *VD, Address VDAddr, SourceLocation Loc, bool PerformInit, CodeGenFunction *CGF=nullptr)
Emit a code for initialization of threadprivate variable.
This represents one expression.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
virtual void EmitThreadLocalInitFuncs(CodeGenModule &CGM, ArrayRef< const VarDecl * > CXXThreadLocals, ArrayRef< llvm::Function * > CXXThreadLocalInits, ArrayRef< const VarDecl * > CXXThreadLocalInitVars)=0
Emits ABI-required functions necessary to initialize thread_local variables in this translation unit.
SourceLocation getLocation() const
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
void Error(SourceLocation loc, StringRef error)
Emit a general error that something can't be done.
llvm::LLVMContext & getLLVMContext()
const LangOptions & getLangOpts() const
const LangOptions & getLangOpts() const
const CGFunctionInfo & arrangeNullaryFunction()
A nullary function is a freestanding function of type 'void ()'.
@ Other
Other implicit parameter.
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
bool isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn, SourceLocation Loc) const