Path: blob/main/contrib/llvm-project/clang/lib/CodeGen/CGCXXABI.h
35233 views
//===----- CGCXXABI.h - Interface to C++ ABIs -------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This provides an abstract class for C++ code generation. Concrete subclasses9// of this implement code generation for specific C++ ABIs.10//11//===----------------------------------------------------------------------===//1213#ifndef LLVM_CLANG_LIB_CODEGEN_CGCXXABI_H14#define LLVM_CLANG_LIB_CODEGEN_CGCXXABI_H1516#include "CodeGenFunction.h"17#include "clang/Basic/LLVM.h"18#include "clang/CodeGen/CodeGenABITypes.h"1920namespace llvm {21class Constant;22class Type;23class Value;24class CallInst;25}2627namespace clang {28class CastExpr;29class CXXConstructorDecl;30class CXXDestructorDecl;31class CXXMethodDecl;32class CXXRecordDecl;33class MangleContext;3435namespace CodeGen {36class CGCallee;37class CodeGenFunction;38class CodeGenModule;39struct CatchTypeInfo;4041/// Implements C++ ABI-specific code generation functions.42class CGCXXABI {43friend class CodeGenModule;4445protected:46CodeGenModule &CGM;47std::unique_ptr<MangleContext> MangleCtx;4849CGCXXABI(CodeGenModule &CGM)50: CGM(CGM), MangleCtx(CGM.getContext().createMangleContext()) {}5152protected:53ImplicitParamDecl *getThisDecl(CodeGenFunction &CGF) {54return CGF.CXXABIThisDecl;55}56llvm::Value *getThisValue(CodeGenFunction &CGF) {57return CGF.CXXABIThisValue;58}5960Address getThisAddress(CodeGenFunction &CGF);6162/// Issue a diagnostic about unsupported features in the ABI.63void ErrorUnsupportedABI(CodeGenFunction &CGF, StringRef S);6465/// Get a null value for unsupported member pointers.66llvm::Constant *GetBogusMemberPointer(QualType T);6768ImplicitParamDecl *&getStructorImplicitParamDecl(CodeGenFunction &CGF) {69return CGF.CXXStructorImplicitParamDecl;70}71llvm::Value *&getStructorImplicitParamValue(CodeGenFunction &CGF) {72return CGF.CXXStructorImplicitParamValue;73}7475/// Loads the incoming C++ this pointer as it was passed by the caller.76llvm::Value *loadIncomingCXXThis(CodeGenFunction &CGF);7778void setCXXABIThisValue(CodeGenFunction &CGF, llvm::Value *ThisPtr);7980ASTContext &getContext() const { return CGM.getContext(); }8182bool mayNeedDestruction(const VarDecl *VD) const;8384/// Determine whether we will definitely emit this variable with a constant85/// initializer, either because the language semantics demand it or because86/// we know that the initializer is a constant.87// For weak definitions, any initializer available in the current translation88// is not necessarily reflective of the initializer used; such initializers89// are ignored unless if InspectInitForWeakDef is true.90bool91isEmittedWithConstantInitializer(const VarDecl *VD,92bool InspectInitForWeakDef = false) const;9394virtual bool requiresArrayCookie(const CXXDeleteExpr *E, QualType eltType);95virtual bool requiresArrayCookie(const CXXNewExpr *E);9697/// Determine whether there's something special about the rules of98/// the ABI tell us that 'this' is a complete object within the99/// given function. Obvious common logic like being defined on a100/// final class will have been taken care of by the caller.101virtual bool isThisCompleteObject(GlobalDecl GD) const = 0;102103virtual bool constructorsAndDestructorsReturnThis() const {104return CGM.getCodeGenOpts().CtorDtorReturnThis;105}106107public:108109virtual ~CGCXXABI();110111/// Gets the mangle context.112MangleContext &getMangleContext() {113return *MangleCtx;114}115116/// Returns true if the given constructor or destructor is one of the117/// kinds that the ABI says returns 'this' (only applies when called118/// non-virtually for destructors).119///120/// There currently is no way to indicate if a destructor returns 'this'121/// when called virtually, and code generation does not support the case.122virtual bool HasThisReturn(GlobalDecl GD) const {123if (isa<CXXConstructorDecl>(GD.getDecl()) ||124(isa<CXXDestructorDecl>(GD.getDecl()) &&125GD.getDtorType() != Dtor_Deleting))126return constructorsAndDestructorsReturnThis();127return false;128}129130virtual bool hasMostDerivedReturn(GlobalDecl GD) const { return false; }131132virtual bool useSinitAndSterm() const { return false; }133134/// Returns true if the target allows calling a function through a pointer135/// with a different signature than the actual function (or equivalently,136/// bitcasting a function or function pointer to a different function type).137/// In principle in the most general case this could depend on the target, the138/// calling convention, and the actual types of the arguments and return139/// value. Here it just means whether the signature mismatch could *ever* be140/// allowed; in other words, does the target do strict checking of signatures141/// for all calls.142virtual bool canCallMismatchedFunctionType() const { return true; }143144/// If the C++ ABI requires the given type be returned in a particular way,145/// this method sets RetAI and returns true.146virtual bool classifyReturnType(CGFunctionInfo &FI) const = 0;147148/// Specify how one should pass an argument of a record type.149enum RecordArgABI {150/// Pass it using the normal C aggregate rules for the ABI, potentially151/// introducing extra copies and passing some or all of it in registers.152RAA_Default = 0,153154/// Pass it on the stack using its defined layout. The argument must be155/// evaluated directly into the correct stack position in the arguments area,156/// and the call machinery must not move it or introduce extra copies.157RAA_DirectInMemory,158159/// Pass it as a pointer to temporary memory.160RAA_Indirect161};162163/// Returns how an argument of the given record type should be passed.164virtual RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const = 0;165166/// Returns true if the implicit 'sret' parameter comes after the implicit167/// 'this' parameter of C++ instance methods.168virtual bool isSRetParameterAfterThis() const { return false; }169170/// Returns true if the ABI permits the argument to be a homogeneous171/// aggregate.172virtual bool173isPermittedToBeHomogeneousAggregate(const CXXRecordDecl *RD) const {174return true;175};176177/// Find the LLVM type used to represent the given member pointer178/// type.179virtual llvm::Type *180ConvertMemberPointerType(const MemberPointerType *MPT);181182/// Load a member function from an object and a member function183/// pointer. Apply the this-adjustment and set 'This' to the184/// adjusted value.185virtual CGCallee EmitLoadOfMemberFunctionPointer(186CodeGenFunction &CGF, const Expr *E, Address This,187llvm::Value *&ThisPtrForCall, llvm::Value *MemPtr,188const MemberPointerType *MPT);189190/// Calculate an l-value from an object and a data member pointer.191virtual llvm::Value *192EmitMemberDataPointerAddress(CodeGenFunction &CGF, const Expr *E,193Address Base, llvm::Value *MemPtr,194const MemberPointerType *MPT);195196/// Perform a derived-to-base, base-to-derived, or bitcast member197/// pointer conversion.198virtual llvm::Value *EmitMemberPointerConversion(CodeGenFunction &CGF,199const CastExpr *E,200llvm::Value *Src);201202/// Perform a derived-to-base, base-to-derived, or bitcast member203/// pointer conversion on a constant value.204virtual llvm::Constant *EmitMemberPointerConversion(const CastExpr *E,205llvm::Constant *Src);206207/// Return true if the given member pointer can be zero-initialized208/// (in the C++ sense) with an LLVM zeroinitializer.209virtual bool isZeroInitializable(const MemberPointerType *MPT);210211/// Return whether or not a member pointers type is convertible to an IR type.212virtual bool isMemberPointerConvertible(const MemberPointerType *MPT) const {213return true;214}215216/// Create a null member pointer of the given type.217virtual llvm::Constant *EmitNullMemberPointer(const MemberPointerType *MPT);218219/// Create a member pointer for the given method.220virtual llvm::Constant *EmitMemberFunctionPointer(const CXXMethodDecl *MD);221222/// Create a member pointer for the given field.223virtual llvm::Constant *EmitMemberDataPointer(const MemberPointerType *MPT,224CharUnits offset);225226/// Create a member pointer for the given member pointer constant.227virtual llvm::Constant *EmitMemberPointer(const APValue &MP, QualType MPT);228229/// Emit a comparison between two member pointers. Returns an i1.230virtual llvm::Value *231EmitMemberPointerComparison(CodeGenFunction &CGF,232llvm::Value *L,233llvm::Value *R,234const MemberPointerType *MPT,235bool Inequality);236237/// Determine if a member pointer is non-null. Returns an i1.238virtual llvm::Value *239EmitMemberPointerIsNotNull(CodeGenFunction &CGF,240llvm::Value *MemPtr,241const MemberPointerType *MPT);242243protected:244/// A utility method for computing the offset required for the given245/// base-to-derived or derived-to-base member-pointer conversion.246/// Does not handle virtual conversions (in case we ever fully247/// support an ABI that allows this). Returns null if no adjustment248/// is required.249llvm::Constant *getMemberPointerAdjustment(const CastExpr *E);250251public:252virtual void emitVirtualObjectDelete(CodeGenFunction &CGF,253const CXXDeleteExpr *DE,254Address Ptr, QualType ElementType,255const CXXDestructorDecl *Dtor) = 0;256virtual void emitRethrow(CodeGenFunction &CGF, bool isNoReturn) = 0;257virtual void emitThrow(CodeGenFunction &CGF, const CXXThrowExpr *E) = 0;258virtual llvm::GlobalVariable *getThrowInfo(QualType T) { return nullptr; }259260/// Determine whether it's possible to emit a vtable for \p RD, even261/// though we do not know that the vtable has been marked as used by semantic262/// analysis.263virtual bool canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const = 0;264265virtual void emitBeginCatch(CodeGenFunction &CGF, const CXXCatchStmt *C) = 0;266267virtual llvm::CallInst *268emitTerminateForUnexpectedException(CodeGenFunction &CGF,269llvm::Value *Exn);270271virtual llvm::Constant *getAddrOfRTTIDescriptor(QualType Ty) = 0;272virtual CatchTypeInfo273getAddrOfCXXCatchHandlerType(QualType Ty, QualType CatchHandlerType) = 0;274virtual CatchTypeInfo getCatchAllTypeInfo();275276virtual bool shouldTypeidBeNullChecked(QualType SrcRecordTy) = 0;277virtual void EmitBadTypeidCall(CodeGenFunction &CGF) = 0;278virtual llvm::Value *EmitTypeid(CodeGenFunction &CGF, QualType SrcRecordTy,279Address ThisPtr,280llvm::Type *StdTypeInfoPtrTy) = 0;281282virtual bool shouldDynamicCastCallBeNullChecked(bool SrcIsPtr,283QualType SrcRecordTy) = 0;284virtual bool shouldEmitExactDynamicCast(QualType DestRecordTy) = 0;285286virtual llvm::Value *emitDynamicCastCall(CodeGenFunction &CGF, Address Value,287QualType SrcRecordTy,288QualType DestTy,289QualType DestRecordTy,290llvm::BasicBlock *CastEnd) = 0;291292virtual llvm::Value *emitDynamicCastToVoid(CodeGenFunction &CGF,293Address Value,294QualType SrcRecordTy) = 0;295296/// Emit a dynamic_cast from SrcRecordTy to DestRecordTy. The cast fails if297/// the dynamic type of Value is not exactly DestRecordTy.298virtual llvm::Value *emitExactDynamicCast(CodeGenFunction &CGF, Address Value,299QualType SrcRecordTy,300QualType DestTy,301QualType DestRecordTy,302llvm::BasicBlock *CastSuccess,303llvm::BasicBlock *CastFail) = 0;304305virtual bool EmitBadCastCall(CodeGenFunction &CGF) = 0;306307virtual llvm::Value *GetVirtualBaseClassOffset(CodeGenFunction &CGF,308Address This,309const CXXRecordDecl *ClassDecl,310const CXXRecordDecl *BaseClassDecl) = 0;311312virtual llvm::BasicBlock *EmitCtorCompleteObjectHandler(CodeGenFunction &CGF,313const CXXRecordDecl *RD);314315/// Emit the code to initialize hidden members required316/// to handle virtual inheritance, if needed by the ABI.317virtual void318initializeHiddenVirtualInheritanceMembers(CodeGenFunction &CGF,319const CXXRecordDecl *RD) {}320321/// Emit constructor variants required by this ABI.322virtual void EmitCXXConstructors(const CXXConstructorDecl *D) = 0;323324/// Additional implicit arguments to add to the beginning (Prefix) and end325/// (Suffix) of a constructor / destructor arg list.326///327/// Note that Prefix should actually be inserted *after* the first existing328/// arg; `this` arguments always come first.329struct AddedStructorArgs {330struct Arg {331llvm::Value *Value;332QualType Type;333};334SmallVector<Arg, 1> Prefix;335SmallVector<Arg, 1> Suffix;336AddedStructorArgs() = default;337AddedStructorArgs(SmallVector<Arg, 1> P, SmallVector<Arg, 1> S)338: Prefix(std::move(P)), Suffix(std::move(S)) {}339static AddedStructorArgs prefix(SmallVector<Arg, 1> Args) {340return {std::move(Args), {}};341}342static AddedStructorArgs suffix(SmallVector<Arg, 1> Args) {343return {{}, std::move(Args)};344}345};346347/// Similar to AddedStructorArgs, but only notes the number of additional348/// arguments.349struct AddedStructorArgCounts {350unsigned Prefix = 0;351unsigned Suffix = 0;352AddedStructorArgCounts() = default;353AddedStructorArgCounts(unsigned P, unsigned S) : Prefix(P), Suffix(S) {}354static AddedStructorArgCounts prefix(unsigned N) { return {N, 0}; }355static AddedStructorArgCounts suffix(unsigned N) { return {0, N}; }356};357358/// Build the signature of the given constructor or destructor variant by359/// adding any required parameters. For convenience, ArgTys has been360/// initialized with the type of 'this'.361virtual AddedStructorArgCounts362buildStructorSignature(GlobalDecl GD,363SmallVectorImpl<CanQualType> &ArgTys) = 0;364365/// Returns true if the given destructor type should be emitted as a linkonce366/// delegating thunk, regardless of whether the dtor is defined in this TU or367/// not.368virtual bool useThunkForDtorVariant(const CXXDestructorDecl *Dtor,369CXXDtorType DT) const = 0;370371virtual void setCXXDestructorDLLStorage(llvm::GlobalValue *GV,372const CXXDestructorDecl *Dtor,373CXXDtorType DT) const;374375virtual llvm::GlobalValue::LinkageTypes376getCXXDestructorLinkage(GVALinkage Linkage, const CXXDestructorDecl *Dtor,377CXXDtorType DT) const;378379/// Emit destructor variants required by this ABI.380virtual void EmitCXXDestructors(const CXXDestructorDecl *D) = 0;381382/// Get the type of the implicit "this" parameter used by a method. May return383/// zero if no specific type is applicable, e.g. if the ABI expects the "this"384/// parameter to point to some artificial offset in a complete object due to385/// vbases being reordered.386virtual const CXXRecordDecl *getThisArgumentTypeForMethod(GlobalDecl GD) {387return cast<CXXMethodDecl>(GD.getDecl())->getParent();388}389390/// Perform ABI-specific "this" argument adjustment required prior to391/// a call of a virtual function.392/// The "VirtualCall" argument is true iff the call itself is virtual.393virtual Address394adjustThisArgumentForVirtualFunctionCall(CodeGenFunction &CGF, GlobalDecl GD,395Address This, bool VirtualCall) {396return This;397}398399/// Build a parameter variable suitable for 'this'.400void buildThisParam(CodeGenFunction &CGF, FunctionArgList &Params);401402/// Insert any ABI-specific implicit parameters into the parameter list for a403/// function. This generally involves extra data for constructors and404/// destructors.405///406/// ABIs may also choose to override the return type, which has been407/// initialized with the type of 'this' if HasThisReturn(CGF.CurGD) is true or408/// the formal return type of the function otherwise.409virtual void addImplicitStructorParams(CodeGenFunction &CGF, QualType &ResTy,410FunctionArgList &Params) = 0;411412/// Get the ABI-specific "this" parameter adjustment to apply in the prologue413/// of a virtual function.414virtual CharUnits getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD) {415return CharUnits::Zero();416}417418/// Emit the ABI-specific prolog for the function.419virtual void EmitInstanceFunctionProlog(CodeGenFunction &CGF) = 0;420421virtual AddedStructorArgs422getImplicitConstructorArgs(CodeGenFunction &CGF, const CXXConstructorDecl *D,423CXXCtorType Type, bool ForVirtualBase,424bool Delegating) = 0;425426/// Add any ABI-specific implicit arguments needed to call a constructor.427///428/// \return The number of arguments added at the beginning and end of the429/// call, which is typically zero or one.430AddedStructorArgCounts431addImplicitConstructorArgs(CodeGenFunction &CGF, const CXXConstructorDecl *D,432CXXCtorType Type, bool ForVirtualBase,433bool Delegating, CallArgList &Args);434435/// Get the implicit (second) parameter that comes after the "this" pointer,436/// or nullptr if there is isn't one.437virtual llvm::Value *438getCXXDestructorImplicitParam(CodeGenFunction &CGF,439const CXXDestructorDecl *DD, CXXDtorType Type,440bool ForVirtualBase, bool Delegating) = 0;441442/// Emit the destructor call.443virtual void EmitDestructorCall(CodeGenFunction &CGF,444const CXXDestructorDecl *DD, CXXDtorType Type,445bool ForVirtualBase, bool Delegating,446Address This, QualType ThisTy) = 0;447448/// Emits the VTable definitions required for the given record type.449virtual void emitVTableDefinitions(CodeGenVTables &CGVT,450const CXXRecordDecl *RD) = 0;451452/// Checks if ABI requires extra virtual offset for vtable field.453virtual bool454isVirtualOffsetNeededForVTableField(CodeGenFunction &CGF,455CodeGenFunction::VPtr Vptr) = 0;456457/// Checks if ABI requires to initialize vptrs for given dynamic class.458virtual bool doStructorsInitializeVPtrs(const CXXRecordDecl *VTableClass) = 0;459460/// Get the address point of the vtable for the given base subobject.461virtual llvm::Constant *462getVTableAddressPoint(BaseSubobject Base,463const CXXRecordDecl *VTableClass) = 0;464465/// Get the address point of the vtable for the given base subobject while466/// building a constructor or a destructor.467virtual llvm::Value *468getVTableAddressPointInStructor(CodeGenFunction &CGF, const CXXRecordDecl *RD,469BaseSubobject Base,470const CXXRecordDecl *NearestVBase) = 0;471472/// Get the address of the vtable for the given record decl which should be473/// used for the vptr at the given offset in RD.474virtual llvm::GlobalVariable *getAddrOfVTable(const CXXRecordDecl *RD,475CharUnits VPtrOffset) = 0;476477/// Build a virtual function pointer in the ABI-specific way.478virtual CGCallee getVirtualFunctionPointer(CodeGenFunction &CGF,479GlobalDecl GD, Address This,480llvm::Type *Ty,481SourceLocation Loc) = 0;482483using DeleteOrMemberCallExpr =484llvm::PointerUnion<const CXXDeleteExpr *, const CXXMemberCallExpr *>;485486/// Emit the ABI-specific virtual destructor call.487virtual llvm::Value *EmitVirtualDestructorCall(CodeGenFunction &CGF,488const CXXDestructorDecl *Dtor,489CXXDtorType DtorType,490Address This,491DeleteOrMemberCallExpr E) = 0;492493virtual void adjustCallArgsForDestructorThunk(CodeGenFunction &CGF,494GlobalDecl GD,495CallArgList &CallArgs) {}496497/// Emit any tables needed to implement virtual inheritance. For Itanium,498/// this emits virtual table tables. For the MSVC++ ABI, this emits virtual499/// base tables.500virtual void emitVirtualInheritanceTables(const CXXRecordDecl *RD) = 0;501502virtual bool exportThunk() = 0;503virtual void setThunkLinkage(llvm::Function *Thunk, bool ForVTable,504GlobalDecl GD, bool ReturnAdjustment) = 0;505506virtual llvm::Value *507performThisAdjustment(CodeGenFunction &CGF, Address This,508const CXXRecordDecl *UnadjustedClass,509const ThunkInfo &TI) = 0;510511virtual llvm::Value *512performReturnAdjustment(CodeGenFunction &CGF, Address Ret,513const CXXRecordDecl *UnadjustedClass,514const ReturnAdjustment &RA) = 0;515516virtual void EmitReturnFromThunk(CodeGenFunction &CGF,517RValue RV, QualType ResultType);518519virtual size_t getSrcArgforCopyCtor(const CXXConstructorDecl *,520FunctionArgList &Args) const = 0;521522/// Gets the offsets of all the virtual base pointers in a given class.523virtual std::vector<CharUnits> getVBPtrOffsets(const CXXRecordDecl *RD);524525/// Gets the pure virtual member call function.526virtual StringRef GetPureVirtualCallName() = 0;527528/// Gets the deleted virtual member call name.529virtual StringRef GetDeletedVirtualCallName() = 0;530531/**************************** Array cookies ******************************/532533/// Returns the extra size required in order to store the array534/// cookie for the given new-expression. May return 0 to indicate that no535/// array cookie is required.536///537/// Several cases are filtered out before this method is called:538/// - non-array allocations never need a cookie539/// - calls to \::operator new(size_t, void*) never need a cookie540///541/// \param expr - the new-expression being allocated.542virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr);543544/// Initialize the array cookie for the given allocation.545///546/// \param NewPtr - a char* which is the presumed-non-null547/// return value of the allocation function548/// \param NumElements - the computed number of elements,549/// potentially collapsed from the multidimensional array case;550/// always a size_t551/// \param ElementType - the base element allocated type,552/// i.e. the allocated type after stripping all array types553virtual Address InitializeArrayCookie(CodeGenFunction &CGF,554Address NewPtr,555llvm::Value *NumElements,556const CXXNewExpr *expr,557QualType ElementType);558559/// Reads the array cookie associated with the given pointer,560/// if it has one.561///562/// \param Ptr - a pointer to the first element in the array563/// \param ElementType - the base element type of elements of the array564/// \param NumElements - an out parameter which will be initialized565/// with the number of elements allocated, or zero if there is no566/// cookie567/// \param AllocPtr - an out parameter which will be initialized568/// with a char* pointing to the address returned by the allocation569/// function570/// \param CookieSize - an out parameter which will be initialized571/// with the size of the cookie, or zero if there is no cookie572virtual void ReadArrayCookie(CodeGenFunction &CGF, Address Ptr,573const CXXDeleteExpr *expr,574QualType ElementType, llvm::Value *&NumElements,575llvm::Value *&AllocPtr, CharUnits &CookieSize);576577/// Return whether the given global decl needs a VTT parameter.578virtual bool NeedsVTTParameter(GlobalDecl GD);579580protected:581/// Returns the extra size required in order to store the array582/// cookie for the given type. Assumes that an array cookie is583/// required.584virtual CharUnits getArrayCookieSizeImpl(QualType elementType);585586/// Reads the array cookie for an allocation which is known to have one.587/// This is called by the standard implementation of ReadArrayCookie.588///589/// \param ptr - a pointer to the allocation made for an array, as a char*590/// \param cookieSize - the computed cookie size of an array591///592/// Other parameters are as above.593///594/// \return a size_t595virtual llvm::Value *readArrayCookieImpl(CodeGenFunction &IGF, Address ptr,596CharUnits cookieSize);597598public:599600/*************************** Static local guards ****************************/601602/// Emits the guarded initializer and destructor setup for the given603/// variable, given that it couldn't be emitted as a constant.604/// If \p PerformInit is false, the initialization has been folded to a605/// constant and should not be performed.606///607/// The variable may be:608/// - a static local variable609/// - a static data member of a class template instantiation610virtual void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D,611llvm::GlobalVariable *DeclPtr,612bool PerformInit) = 0;613614/// Emit code to force the execution of a destructor during global615/// teardown. The default implementation of this uses atexit.616///617/// \param Dtor - a function taking a single pointer argument618/// \param Addr - a pointer to pass to the destructor function.619virtual void registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,620llvm::FunctionCallee Dtor,621llvm::Constant *Addr) = 0;622623/*************************** thread_local initialization ********************/624625/// Emits ABI-required functions necessary to initialize thread_local626/// variables in this translation unit.627///628/// \param CXXThreadLocals - The thread_local declarations in this translation629/// unit.630/// \param CXXThreadLocalInits - If this translation unit contains any631/// non-constant initialization or non-trivial destruction for632/// thread_local variables, a list of functions to perform the633/// initialization.634virtual void EmitThreadLocalInitFuncs(635CodeGenModule &CGM, ArrayRef<const VarDecl *> CXXThreadLocals,636ArrayRef<llvm::Function *> CXXThreadLocalInits,637ArrayRef<const VarDecl *> CXXThreadLocalInitVars) = 0;638639// Determine if references to thread_local global variables can be made640// directly or require access through a thread wrapper function.641virtual bool usesThreadWrapperFunction(const VarDecl *VD) const = 0;642643/// Emit a reference to a non-local thread_local variable (including644/// triggering the initialization of all thread_local variables in its645/// translation unit).646virtual LValue EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF,647const VarDecl *VD,648QualType LValType) = 0;649650/// Emit a single constructor/destructor with the given type from a C++651/// constructor Decl.652virtual void emitCXXStructor(GlobalDecl GD) = 0;653654/// Load a vtable from This, an object of polymorphic type RD, or from one of655/// its virtual bases if it does not have its own vtable. Returns the vtable656/// and the class from which the vtable was loaded.657virtual std::pair<llvm::Value *, const CXXRecordDecl *>658LoadVTablePtr(CodeGenFunction &CGF, Address This,659const CXXRecordDecl *RD) = 0;660};661662// Create an instance of a C++ ABI class:663664/// Creates an Itanium-family ABI.665CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);666667/// Creates a Microsoft-family ABI.668CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);669670struct CatchRetScope final : EHScopeStack::Cleanup {671llvm::CatchPadInst *CPI;672673CatchRetScope(llvm::CatchPadInst *CPI) : CPI(CPI) {}674675void Emit(CodeGenFunction &CGF, Flags flags) override {676llvm::BasicBlock *BB = CGF.createBasicBlock("catchret.dest");677CGF.Builder.CreateCatchRet(CPI, BB);678CGF.EmitBlock(BB);679}680};681}682}683684#endif685686687