21 #include "llvm/ADT/DenseSet.h"
22 #include "llvm/ADT/SetVector.h"
23 #include "llvm/Support/Compiler.h"
24 #include "llvm/Support/Format.h"
25 #include "llvm/Transforms/Utils/Cloning.h"
29 using namespace clang;
30 using namespace CodeGen;
33 : CGM(CGM), VTContext(CGM.getContext().getVTableContext()) {}
41 llvm::raw_svector_ostream Out(Name);
49 return GetOrCreateLLVMFunction(Name, Ty, GD,
true,
54 const ThunkInfo &Thunk, llvm::Function *Fn) {
59 llvm::Function *ThunkFn,
bool ForVTable,
70 ThunkFn->setComdat(CGM.
getModule().getOrInsertComdat(ThunkFn->getName()));
78 (isa<PointerType>(typeL) && isa<PointerType>(typeR)) ||
79 (isa<ReferenceType>(typeL) && isa<ReferenceType>(typeR))));
89 llvm::BasicBlock *AdjustNull =
nullptr;
90 llvm::BasicBlock *AdjustNotNull =
nullptr;
91 llvm::BasicBlock *AdjustEnd =
nullptr;
101 CGF.
Builder.CreateCondBr(IsNull, AdjustNull, AdjustNotNull);
108 Address(ReturnValue, ClassAlign),
111 if (NullCheckValue) {
112 CGF.
Builder.CreateBr(AdjustEnd);
114 CGF.
Builder.CreateBr(AdjustEnd);
117 llvm::PHINode *PHI = CGF.
Builder.CreatePHI(ReturnValue->getType(), 2);
118 PHI->addIncoming(ReturnValue, AdjustNotNull);
119 PHI->addIncoming(llvm::Constant::getNullValue(ReturnValue->getType()),
149 QualType ResultType = FPT->getReturnType();
155 llvm::Function *BaseFn = cast<llvm::Function>(Callee);
158 llvm::ValueToValueMapTy VMap;
159 llvm::Function *NewFn = llvm::CloneFunction(BaseFn, VMap);
160 Fn->replaceAllUsesWith(NewFn);
162 Fn->eraseFromParent();
169 llvm::Function::arg_iterator AI = Fn->arg_begin();
176 llvm::BasicBlock *EntryBB = &Fn->front();
178 std::find_if(EntryBB->begin(), EntryBB->end(), [&](llvm::Instruction &
I) {
179 return isa<llvm::StoreInst>(
I) &&
182 assert(ThisStore != EntryBB->end() &&
183 "Store of this should be in entry block?");
185 Builder.SetInsertPoint(&*ThisStore);
188 ThisStore->setOperand(0, AdjustedThisPtr);
192 for (llvm::BasicBlock &BB : *Fn) {
193 llvm::Instruction *T = BB.getTerminator();
194 if (isa<llvm::ReturnInst>(T)) {
196 T->eraseFromParent();
231 if (isa<CXXDestructorDecl>(MD))
236 MD->getLocation(), MD->getLocation());
240 CXXThisValue = CXXABIThisValue;
257 "Please use a new CGF for this thunk");
272 MD,
"non-trivial argument copy for return-adjusting thunk");
283 if (isa<CXXDestructorDecl>(MD))
298 assert(isa<CXXDestructorDecl>(MD) ||
299 similar(CallFnInfo.getReturnInfo(), CallFnInfo.getReturnType(),
303 assert(
similar(CallFnInfo.arg_begin()[i].info,
304 CallFnInfo.arg_begin()[i].type,
322 llvm::Instruction *CallOrInvoke;
328 else if (llvm::CallInst* Call = dyn_cast<llvm::CallInst>(CallOrInvoke))
329 Call->setTailCallKind(llvm::CallInst::TCK_Tail);
349 for (llvm::Argument &A :
CurFn->args())
357 llvm::Type *ThisType = Args[ThisArgNo]->getType();
358 if (ThisType != AdjustedThisPtr->getType())
360 Args[ThisArgNo] = AdjustedThisPtr;
362 assert(ThisAI.
isInAlloca() &&
"this is passed directly or inalloca");
364 llvm::Type *ThisType = ThisAddr.getElementType();
365 if (ThisType != AdjustedThisPtr->getType())
372 llvm::CallInst *Call =
Builder.CreateCall(Callee, Args);
373 Call->setTailCallKind(llvm::CallInst::TCK_MustTail);
380 llvm::AttributeSet Attrs =
382 Call->setAttributes(Attrs);
383 Call->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
385 if (Call->getType()->isVoidTy())
416 llvm::GlobalValue *Entry;
419 if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(C)) {
420 assert(CE->getOpcode() == llvm::Instruction::BitCast);
421 Entry = cast<llvm::GlobalValue>(CE->getOperand(0));
423 Entry = cast<llvm::GlobalValue>(C);
428 if (Entry->getType()->getElementType() !=
430 llvm::GlobalValue *OldThunkFn = Entry;
433 assert(OldThunkFn->isDeclaration() &&
434 "Shouldn't replace non-declaration");
437 OldThunkFn->setName(StringRef());
441 if (!OldThunkFn->use_empty()) {
442 llvm::Constant *NewPtrForOldDecl =
443 llvm::ConstantExpr::getBitCast(Entry, OldThunkFn->getType());
444 OldThunkFn->replaceAllUsesWith(NewPtrForOldDecl);
448 OldThunkFn->eraseFromParent();
451 llvm::Function *ThunkFn = cast<llvm::Function>(Entry);
453 bool UseAvailableExternallyLinkage = ForVTable && ABIHasKeyFunctions;
455 if (!ThunkFn->isDeclaration()) {
456 if (!ABIHasKeyFunctions || UseAvailableExternallyLinkage) {
467 if (ThunkFn->isVarArg()) {
473 if (UseAvailableExternallyLinkage)
485 void CodeGenVTables::maybeEmitThunkForVTable(
GlobalDecl GD,
501 emitThunk(GD, Thunk,
true);
516 if (!ThunkInfoVector)
519 for (
const ThunkInfo& Thunk : *ThunkInfoVector)
520 emitThunk(GD, Thunk,
false);
526 unsigned NumVTableThunks, llvm::Constant *RTTI) {
534 unsigned NextVTableThunkIndex = 0;
536 llvm::Constant *PureVirtualFn =
nullptr, *DeletedVirtualFn =
nullptr;
538 for (
unsigned I = 0;
I != NumComponents; ++
I) {
541 llvm::Constant *Init =
nullptr;
545 Init = llvm::ConstantInt::get(PtrDiffTy,
547 Init = llvm::ConstantExpr::getIntToPtr(Init, Int8PtrTy);
550 Init = llvm::ConstantInt::get(PtrDiffTy,
552 Init = llvm::ConstantExpr::getIntToPtr(Init, Int8PtrTy);
555 Init = llvm::ConstantInt::get(PtrDiffTy,
557 Init = llvm::ConstantExpr::getIntToPtr(Init, Int8PtrTy);
560 Init = llvm::ConstantExpr::getBitCast(RTTI, Int8PtrTy);
570 llvm_unreachable(
"Unexpected vtable component kind");
589 bool CanEmitMethod = CGM.
getLangOpts().CUDAIsDevice
590 ? MD->hasAttr<CUDADeviceAttr>()
591 : (MD->hasAttr<CUDAHostAttr>() ||
592 !MD->hasAttr<CUDADeviceAttr>());
593 if (!CanEmitMethod) {
594 Init = llvm::ConstantExpr::getNullValue(Int8PtrTy);
600 if (cast<CXXMethodDecl>(GD.
getDecl())->isPure()) {
602 if (!PureVirtualFn) {
603 llvm::FunctionType *Ty =
604 llvm::FunctionType::get(CGM.
VoidTy,
false);
607 if (
auto *F = dyn_cast<llvm::Function>(PureVirtualFn))
608 F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
609 PureVirtualFn = llvm::ConstantExpr::getBitCast(PureVirtualFn,
612 Init = PureVirtualFn;
613 }
else if (cast<CXXMethodDecl>(GD.
getDecl())->isDeleted()) {
614 if (!DeletedVirtualFn) {
615 llvm::FunctionType *Ty =
616 llvm::FunctionType::get(CGM.
VoidTy,
false);
617 StringRef DeletedCallName =
620 if (
auto *F = dyn_cast<llvm::Function>(DeletedVirtualFn))
621 F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
622 DeletedVirtualFn = llvm::ConstantExpr::getBitCast(DeletedVirtualFn,
625 Init = DeletedVirtualFn;
628 if (NextVTableThunkIndex < NumVTableThunks &&
629 VTableThunks[NextVTableThunkIndex].first ==
I) {
630 const ThunkInfo &Thunk = VTableThunks[NextVTableThunkIndex].second;
632 maybeEmitThunkForVTable(GD, Thunk);
635 NextVTableThunkIndex++;
642 Init = llvm::ConstantExpr::getBitCast(Init, Int8PtrTy);
648 Init = llvm::ConstantExpr::getNullValue(Int8PtrTy);
652 Inits.push_back(Init);
655 llvm::ArrayType *
ArrayType = llvm::ArrayType::get(Int8PtrTy, NumComponents);
656 return llvm::ConstantArray::get(ArrayType, Inits);
659 llvm::GlobalVariable *
663 llvm::GlobalVariable::LinkageTypes
Linkage,
664 VTableAddressPointsMapTy& AddressPoints) {
666 DI->completeClassData(Base.
getBase());
668 std::unique_ptr<VTableLayout> VTLayout(
673 AddressPoints = VTLayout->getAddressPoints();
677 llvm::raw_svector_ostream Out(OutName);
681 StringRef
Name = OutName.str();
684 llvm::ArrayType::get(CGM.
Int8PtrTy, VTLayout->getNumVTableComponents());
691 if (Linkage == llvm::GlobalVariable::AvailableExternallyLinkage)
695 llvm::GlobalVariable *VTable =
700 VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
707 Base.
getBase(), VTLayout->vtable_component_begin(),
708 VTLayout->getNumVTableComponents(), VTLayout->vtable_thunk_begin(),
709 VTLayout->getNumVTableThunks(), RTTI);
710 VTable->setInitializer(Init);
726 llvm::GlobalVariable::LinkageTypes
734 if (keyFunction && !RD->hasAttr<DLLImportAttr>()) {
739 keyFunction = cast<CXXMethodDecl>(def);
744 assert((def || CodeGenOpts.OptimizationLevel > 0) &&
745 "Shouldn't query vtable linkage without key function or "
747 if (!def && CodeGenOpts.OptimizationLevel > 0)
748 return llvm::GlobalVariable::AvailableExternallyLinkage;
752 llvm::GlobalVariable::LinkOnceODRLinkage :
759 llvm::GlobalVariable::LinkOnceODRLinkage :
764 llvm::GlobalVariable::WeakODRLinkage :
768 llvm_unreachable(
"Should not have been asked to emit this");
777 llvm::GlobalVariable::LinkageTypes DiscardableODRLinkage =
778 llvm::GlobalValue::LinkOnceODRLinkage;
779 llvm::GlobalVariable::LinkageTypes NonDiscardableODRLinkage =
780 llvm::GlobalValue::WeakODRLinkage;
781 if (RD->hasAttr<DLLExportAttr>()) {
783 DiscardableODRLinkage = NonDiscardableODRLinkage;
784 }
else if (RD->hasAttr<DLLImportAttr>()) {
786 DiscardableODRLinkage = llvm::GlobalVariable::AvailableExternallyLinkage;
787 NonDiscardableODRLinkage = llvm::GlobalVariable::AvailableExternallyLinkage;
794 return DiscardableODRLinkage;
800 return DiscardableODRLinkage;
802 ? llvm::GlobalVariable::AvailableExternallyLinkage
806 return NonDiscardableODRLinkage;
809 llvm_unreachable(
"Invalid TemplateSpecializationKind!");
825 DI->completeClassData(RD);
844 assert(RD->
isDynamicClass() &&
"Non-dynamic classes have no VTable.");
871 return !keyFunction->
hasBody();
890 void CodeGenModule::EmitDeferredVTables() {
894 size_t savedSize = DeferredVTables.size();
901 assert(savedSize == DeferredVTables.size() &&
902 "deferred extra vtables during vtable emission?");
903 DeferredVTables.clear();
911 if (RD->hasAttr<LTOVisibilityPublicAttr>() || RD->hasAttr<UuidAttr>())
915 if (RD->hasAttr<DLLExportAttr>() || RD->hasAttr<DLLImportAttr>())
925 auto *D = cast<Decl>(DC);
927 if (isa<TranslationUnitDecl>(DC->getRedeclContext())) {
928 if (
auto *ND = dyn_cast<NamespaceDecl>(D))
930 if (II->isStr(
"std") || II->isStr(
"stdext"))
948 typedef std::pair<const CXXRecordDecl *, unsigned> BSEntry;
949 std::vector<BSEntry> BitsetEntries;
952 BitsetEntries.push_back(std::make_pair(AP.first.getBase(), AP.second));
955 std::sort(BitsetEntries.begin(), BitsetEntries.end(),
956 [
this](
const BSEntry &E1,
const BSEntry &E2) {
961 llvm::raw_string_ostream O1(S1);
963 QualType(E1.first->getTypeForDecl(), 0), O1);
967 llvm::raw_string_ostream O2(S2);
969 QualType(E2.first->getTypeForDecl(), 0), O2);
977 return E1.second < E2.second;
980 for (
auto BitsetEntry : BitsetEntries)
ReturnValueSlot - Contains the address where the return value of a function can be stored...
static const Decl * getCanonicalDecl(const Decl *D)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
External linkage, which indicates that the entity can be referred to from other translation units...
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()
CanQualType getReturnType() const
CharUnits getOffsetToTop() const
virtual void EmitReturnFromThunk(CodeGenFunction &CGF, RValue RV, QualType ResultType)
llvm::Module & getModule() const
virtual void addImplicitStructorParams(CodeGenFunction &CGF, QualType &ResTy, FunctionArgList &Params)=0
Insert any ABI-specific implicit parameters into the parameter list for a function.
CharUnits getClassPointerAlignment(const CXXRecordDecl *CD)
Returns the assumed alignment of an opaque pointer to the given class.
FunctionType - C99 6.7.5.3 - Function Declarators.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
virtual const ThunkInfoVectorTy * getThunkInfo(GlobalDecl GD)
virtual llvm::Value * performThisAdjustment(CodeGenFunction &CGF, Address This, const ThisAdjustment &TA)=0
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
llvm::Value * LoadCXXThis()
LoadCXXThis - Load the value of 'this'.
void setFunctionLinkage(GlobalDecl GD, llvm::Function *F)
Represents an array type, per C99 6.7.5.2 - Array Declarators.
virtual StringRef GetDeletedVirtualCallName()=0
Gets the deleted virtual member call name.
llvm::Function * GenerateVarArgsThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo, GlobalDecl GD, const ThunkInfo &Thunk)
bool isFuncTypeConvertible(const FunctionType *FT)
isFuncTypeConvertible - Utility to check whether a function type can be converted to an LLVM type (i...
bool HasHiddenLTOVisibility(const CXXRecordDecl *RD)
Returns whether the given record has hidden LTO visibility and therefore may participate in (single-m...
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
Objects with "hidden" visibility are not seen by the dynamic linker.
CGDebugInfo * getModuleDebugInfo()
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
ParmVarDecl - Represents a parameter to a function.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
virtual bool hasMostDerivedReturn(GlobalDecl GD) const
Visibility getVisibility() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
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. ...
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
static bool shouldEmitAvailableExternallyVTable(const CodeGenModule &CGM, const CXXRecordDecl *RD)
static void setThunkVisibility(CodeGenModule &CGM, const CXXMethodDecl *MD, const ThunkInfo &Thunk, llvm::Function *Fn)
bool isReferenceType() const
RValue EmitCall(const CGFunctionInfo &FnInfo, llvm::Value *Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, CGCalleeInfo CalleeInfo=CGCalleeInfo(), llvm::Instruction **callOrInvoke=nullptr)
EmitCall - Generate a call of the given function, expecting the given result type, and using the given argument list which specifies both the LLVM arguments and the types they were derived from.
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
const Decl * getDecl() const
Linkage getLinkage() const
virtual void EmitInstanceFunctionProlog(CodeGenFunction &CGF)=0
Emit the ABI-specific prolog for the function.
const CXXMethodDecl * getFunctionDecl() const
static bool hasScalarEvaluationKind(QualType T)
const TargetInfo & getTargetInfo() const
virtual void emitVTableDefinitions(CodeGenVTables &CGVT, const CXXRecordDecl *RD)=0
Emits the VTable definitions required for the given record type.
const LangOptions & getLangOpts() const
CharUnits - This is an opaque type for sizes expressed in character units.
CharUnits getVCallOffset() const
QualType getReturnType() const
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
unsigned getCallingConvention() const
getCallingConvention - Return the user specified calling convention, which has been translated into a...
virtual bool canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const =0
Determine whether it's possible to emit a vtable for RD, even though we do not know that the vtable h...
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
ItaniumVTableContext & getItaniumVTableContext()
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const
Set the visibility for the given LLVM GlobalValue.
detail::InMemoryDirectory::const_iterator I
const CGFunctionInfo & arrangeGlobalDeclaration(GlobalDecl GD)
param_iterator param_begin()
Represents a prototype with parameter type info, e.g.
const TargetInfo & getTarget() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
void EmitDelegateCallArg(CallArgList &args, const VarDecl *param, SourceLocation loc)
EmitDelegateCallArg - We are performing a delegate call; that is, the current function is delegating ...
bool isVTableExternal(const CXXRecordDecl *RD)
At this point in the translation unit, does it appear that can we rely on the vtable being defined el...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const CXXRecordDecl * getBase() const
getBase - Returns the base class declaration.
static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk, llvm::Function *ThunkFn, bool ForVTable, GlobalDecl GD)
llvm::Value * getPointer() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
static bool similar(const ABIArgInfo &infoL, CanQualType typeL, const ABIArgInfo &infoR, CanQualType typeR)
CXXDtorType getDtorType() const
CGCXXABI & getCXXABI() const
bool usesInAlloca() const
Return true if this function uses inalloca arguments.
Represents a C++ destructor within a class.
virtual StringRef GetPureVirtualCallName()=0
Gets the pure virtual member call function.
ASTContext & getContext() const
void add(RValue rvalue, QualType type, bool needscopy=false)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
llvm::LLVMContext & getLLVMContext()
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
bool hasKeyFunctions() const
Does this ABI use key functions? If so, class data such as the vtable is emitted with strong linkage ...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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...
bool isExternallyVisible(Linkage L)
bool isExternallyVisible() const
unsigned getRegParm() const
This template specialization was implicitly instantiated from a template.
virtual void adjustCallArgsForDestructorThunk(CodeGenFunction &CGF, GlobalDecl GD, CallArgList &CallArgs)
void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset, const CXXRecordDecl *RD)
Create and attach type metadata for the given vtable.
void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo, GlobalDecl GD, const ThunkInfo &Thunk)
Generate a thunk for the given method.
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 * GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk)
Get the address of the thunk for the given global decl.
The l-value was considered opaque, so the alignment was determined from a type.
virtual void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, const ThisAdjustment &ThisAdjustment, raw_ostream &)=0
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
llvm::Constant * CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeSet ExtraAttrs=llvm::AttributeSet())
Create a new runtime function with the specified type and name.
ASTContext & getContext() const
const TemplateArgument * iterator
void EmitCallAndReturnForThunk(llvm::Value *Callee, const ThunkInfo *Thunk)
Represents a single component in a vtable.
Represents a static or instance method of a struct/union/class.
ArrayRef< ParmVarDecl * > parameters() const
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
CodeGenVTables(CodeGenModule &CGM)
const CXXDestructorDecl * getDestructorDecl() const
const CodeGenOptions & getCodeGenOpts() const
LinkageInfo getLinkageAndVisibility() const
Determines the linkage and visibility of this entity.
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.
const LangOptions & getLangOpts() const
void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F)
Set the LLVM function attributes which only apply to a function definition.
const T * castAs() const
Member-template castAs<specific type>.
virtual void emitVirtualInheritanceTables(const CXXRecordDecl *RD)=0
Emit any tables needed to implement virtual inheritance.
MangleContext & getMangleContext()
Gets the mangle context.
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
const CGFunctionInfo & arrangeCXXMethodCall(const CallArgList &args, const FunctionProtoType *type, RequiredArgs required)
Arrange a call to a C++ method, passing the given arguments.
const CGFunctionInfo * CurFnInfo
bool isDynamicClass() const
llvm::GlobalVariable * GenerateConstructionVTable(const CXXRecordDecl *RD, const BaseSubobject &Base, bool BaseIsVirtual, llvm::GlobalVariable::LinkageTypes Linkage, VTableAddressPointsMapTy &AddressPoints)
GenerateConstructionVTable - Generate a construction vtable for the given base subobject.
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
virtual void mangleTypeName(QualType T, raw_ostream &)=0
Generates a unique string for an externally visible type for use with TBAA or type uniquing...
bool isSRetAfterThis() const
FunctionArgList - Type for representing both the decl and type of parameters to a function...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
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.
ThisAdjustment This
The this pointer adjustment.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
void EmitVTableTypeMetadata(llvm::GlobalVariable *VTable, const VTableLayout &VTLayout)
Emit type metadata for the given vtable using the given layout.
This template specialization was instantiated from a template due to an explicit instantiation declar...
CharUnits getVBaseOffset() const
void buildThisParam(CodeGenFunction &CGF, FunctionArgList &Params)
Build a parameter variable suitable for 'this'.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
const llvm::Triple & getTriple() const
void EmitThunks(GlobalDecl GD)
EmitThunks - Emit the associated thunks for the given global decl.
param_iterator param_end()
llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD)
Return the appropriate linkage for the vtable, VTT, and type information of the given class...
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
const T * getAs() const
Member-template getAs<specific type>'.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
llvm::PointerType * Int8PtrTy
static bool shouldEmitVTableAtEndOfTranslationUnit(CodeGenModule &CGM, const CXXRecordDecl *RD)
Given that we're currently at the end of the translation unit, and we've emitted a reference to the v...
void GenerateClassData(const CXXRecordDecl *RD)
GenerateClassData - Generate all the class data required to be generated upon definition of a KeyFunc...
ReturnAdjustment Return
The return adjustment.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
ABIArgInfo & getReturnInfo()
void StartThunk(llvm::Function *Fn, GlobalDecl GD, const CGFunctionInfo &FnInfo)
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
Address LoadCXXThisAddress()
llvm::Type * GetFunctionTypeForVTable(GlobalDecl GD)
GetFunctionTypeForVTable - Get the LLVM function type for use in a vtable, given a CXXMethodDecl...
static RValue PerformReturnAdjustment(CodeGenFunction &CGF, QualType ResultType, RValue RV, const ThunkInfo &Thunk)
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or NULL if there isn't one...
Represents a C++ struct/union/class.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, raw_ostream &)=0
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
llvm::Constant * CreateVTableInitializer(const CXXRecordDecl *RD, const VTableComponent *Components, unsigned NumComponents, const VTableLayout::VTableThunkTy *VTableThunks, unsigned NumVTableThunks, llvm::Constant *RTTI)
CreateVTableInitializer - Create a vtable initializer for the given record decl.
std::pair< uint64_t, ThunkInfo > VTableThunkTy
bool AutoreleaseResult
In ARC, whether we should autorelease the return value.
const_arg_iterator arg_begin() const
A pointer to the deleting destructor.
static RValue get(llvm::Value *V)
unsigned arg_size() const
static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, unsigned additional, const FunctionDecl *FD)
Compute the arguments required by the given formal prototype, given that there may be some additional...
virtual llvm::Value * performReturnAdjustment(CodeGenFunction &CGF, Address Ret, const ReturnAdjustment &RA)=0
Kind getKind() const
Get the kind of this vtable component.
const AddressPointsMapTy & getAddressPoints() const
CodeGenVTables & getVTables()
CharUnits getBaseOffset() const
getBaseOffset - Returns the base class offset.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
bool CurFuncIsThunk
In C++, whether we are code generating a thunk.
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 * GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty=nullptr, bool ForVTable=false, bool DontDefer=false, bool IsForDefinition=false)
Return the address of the given function.
CallArgList - Type for representing both the value and type of arguments in a call.
A pointer to the complete destructor.
An entry that is never used.
virtual void setThunkLinkage(llvm::Function *Thunk, bool ForVTable, GlobalDecl GD, bool ReturnAdjustment)=0
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...
AttributeList - Represents a syntactic attribute.
void EmitMustTailThunk(const CXXMethodDecl *MD, llvm::Value *AdjustedThisPtr, llvm::Value *Callee)
Emit a musttail call for a thunk with a potentially adjusted this pointer.
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.