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,
162 Fn->replaceAllUsesWith(NewFn);
164 Fn->eraseFromParent();
171 llvm::Function::arg_iterator AI = Fn->arg_begin();
178 llvm::BasicBlock *EntryBB = &Fn->front();
180 std::find_if(EntryBB->begin(), EntryBB->end(), [&](llvm::Instruction &
I) {
181 return isa<llvm::StoreInst>(
I) &&
184 assert(ThisStore != EntryBB->end() &&
185 "Store of this should be in entry block?");
187 Builder.SetInsertPoint(&*ThisStore);
190 ThisStore->setOperand(0, AdjustedThisPtr);
194 for (llvm::BasicBlock &BB : *Fn) {
195 llvm::Instruction *T = BB.getTerminator();
196 if (isa<llvm::ReturnInst>(T)) {
198 T->eraseFromParent();
233 if (isa<CXXDestructorDecl>(MD))
242 CXXThisValue = CXXABIThisValue;
259 "Please use a new CGF for this thunk");
274 MD,
"non-trivial argument copy for return-adjusting thunk");
285 if (isa<CXXDestructorDecl>(MD))
301 assert(isa<CXXDestructorDecl>(MD) ||
302 similar(CallFnInfo.getReturnInfo(), CallFnInfo.getReturnType(),
306 assert(
similar(CallFnInfo.arg_begin()[i].info,
307 CallFnInfo.arg_begin()[i].type,
325 llvm::Instruction *CallOrInvoke;
331 else if (llvm::CallInst* Call = dyn_cast<llvm::CallInst>(CallOrInvoke))
332 Call->setTailCallKind(llvm::CallInst::TCK_Tail);
352 for (llvm::Argument &A :
CurFn->args())
360 llvm::Type *ThisType = Args[ThisArgNo]->getType();
361 if (ThisType != AdjustedThisPtr->getType())
363 Args[ThisArgNo] = AdjustedThisPtr;
365 assert(ThisAI.
isInAlloca() &&
"this is passed directly or inalloca");
367 llvm::Type *ThisType = ThisAddr.getElementType();
368 if (ThisType != AdjustedThisPtr->getType())
375 llvm::CallInst *Call =
Builder.CreateCall(Callee, Args);
376 Call->setTailCallKind(llvm::CallInst::TCK_MustTail);
383 llvm::AttributeSet Attrs =
385 Call->setAttributes(Attrs);
386 Call->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
388 if (Call->getType()->isVoidTy())
419 llvm::GlobalValue *Entry;
422 if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(C)) {
423 assert(CE->getOpcode() == llvm::Instruction::BitCast);
424 Entry = cast<llvm::GlobalValue>(CE->getOperand(0));
426 Entry = cast<llvm::GlobalValue>(
C);
431 if (Entry->getType()->getElementType() !=
433 llvm::GlobalValue *OldThunkFn = Entry;
436 assert(OldThunkFn->isDeclaration() &&
437 "Shouldn't replace non-declaration");
440 OldThunkFn->setName(StringRef());
444 if (!OldThunkFn->use_empty()) {
445 llvm::Constant *NewPtrForOldDecl =
446 llvm::ConstantExpr::getBitCast(Entry, OldThunkFn->getType());
447 OldThunkFn->replaceAllUsesWith(NewPtrForOldDecl);
451 OldThunkFn->eraseFromParent();
454 llvm::Function *ThunkFn = cast<llvm::Function>(Entry);
456 bool UseAvailableExternallyLinkage = ForVTable && ABIHasKeyFunctions;
458 if (!ThunkFn->isDeclaration()) {
459 if (!ABIHasKeyFunctions || UseAvailableExternallyLinkage) {
470 if (ThunkFn->isVarArg()) {
476 if (UseAvailableExternallyLinkage)
488 void CodeGenVTables::maybeEmitThunkForVTable(
GlobalDecl GD,
504 emitThunk(GD, Thunk,
true);
510 cast<CXXMethodDecl>(GD.
getDecl())->getCanonicalDecl();
519 if (!ThunkInfoVector)
522 for (
const ThunkInfo& Thunk : *ThunkInfoVector)
523 emitThunk(GD, Thunk,
false);
529 unsigned NumVTableThunks, llvm::Constant *RTTI) {
537 unsigned NextVTableThunkIndex = 0;
539 llvm::Constant *PureVirtualFn =
nullptr, *DeletedVirtualFn =
nullptr;
541 for (
unsigned I = 0;
I != NumComponents; ++
I) {
544 llvm::Constant *Init =
nullptr;
548 Init = llvm::ConstantInt::get(PtrDiffTy,
550 Init = llvm::ConstantExpr::getIntToPtr(Init, Int8PtrTy);
553 Init = llvm::ConstantInt::get(PtrDiffTy,
555 Init = llvm::ConstantExpr::getIntToPtr(Init, Int8PtrTy);
558 Init = llvm::ConstantInt::get(PtrDiffTy,
560 Init = llvm::ConstantExpr::getIntToPtr(Init, Int8PtrTy);
563 Init = llvm::ConstantExpr::getBitCast(RTTI, Int8PtrTy);
573 llvm_unreachable(
"Unexpected vtable component kind");
592 bool CanEmitMethod = CGM.
getLangOpts().CUDAIsDevice
593 ? MD->
hasAttr<CUDADeviceAttr>()
594 : (MD->
hasAttr<CUDAHostAttr>() ||
595 !MD->
hasAttr<CUDADeviceAttr>());
596 if (!CanEmitMethod) {
597 Init = llvm::ConstantExpr::getNullValue(Int8PtrTy);
603 if (cast<CXXMethodDecl>(GD.
getDecl())->isPure()) {
605 if (!PureVirtualFn) {
606 llvm::FunctionType *Ty =
607 llvm::FunctionType::get(CGM.
VoidTy,
false);
610 PureVirtualFn = llvm::ConstantExpr::getBitCast(PureVirtualFn,
613 Init = PureVirtualFn;
614 }
else if (cast<CXXMethodDecl>(GD.
getDecl())->isDeleted()) {
615 if (!DeletedVirtualFn) {
616 llvm::FunctionType *Ty =
617 llvm::FunctionType::get(CGM.
VoidTy,
false);
618 StringRef DeletedCallName =
621 DeletedVirtualFn = llvm::ConstantExpr::getBitCast(DeletedVirtualFn,
624 Init = DeletedVirtualFn;
627 if (NextVTableThunkIndex < NumVTableThunks &&
628 VTableThunks[NextVTableThunkIndex].first ==
I) {
629 const ThunkInfo &Thunk = VTableThunks[NextVTableThunkIndex].second;
631 maybeEmitThunkForVTable(GD, Thunk);
634 NextVTableThunkIndex++;
641 Init = llvm::ConstantExpr::getBitCast(Init, Int8PtrTy);
647 Init = llvm::ConstantExpr::getNullValue(Int8PtrTy);
651 Inits.push_back(Init);
654 llvm::ArrayType *
ArrayType = llvm::ArrayType::get(Int8PtrTy, NumComponents);
655 return llvm::ConstantArray::get(ArrayType, Inits);
658 llvm::GlobalVariable *
662 llvm::GlobalVariable::LinkageTypes
Linkage,
663 VTableAddressPointsMapTy& AddressPoints) {
665 DI->completeClassData(Base.
getBase());
667 std::unique_ptr<VTableLayout> VTLayout(
672 AddressPoints = VTLayout->getAddressPoints();
676 llvm::raw_svector_ostream Out(OutName);
680 StringRef
Name = OutName.str();
683 llvm::ArrayType::get(CGM.
Int8PtrTy, VTLayout->getNumVTableComponents());
690 if (Linkage == llvm::GlobalVariable::AvailableExternallyLinkage)
694 llvm::GlobalVariable *VTable =
699 VTable->setUnnamedAddr(
true);
706 Base.
getBase(), VTLayout->vtable_component_begin(),
707 VTLayout->getNumVTableComponents(), VTLayout->vtable_thunk_begin(),
708 VTLayout->getNumVTableThunks(), RTTI);
709 VTable->setInitializer(Init);
725 llvm::GlobalVariable::LinkageTypes
733 if (keyFunction && !RD->
hasAttr<DLLImportAttr>()) {
738 keyFunction = cast<CXXMethodDecl>(def);
743 assert((def || CodeGenOpts.OptimizationLevel > 0) &&
744 "Shouldn't query vtable linkage without key function or "
746 if (!def && CodeGenOpts.OptimizationLevel > 0)
747 return llvm::GlobalVariable::AvailableExternallyLinkage;
751 llvm::GlobalVariable::LinkOnceODRLinkage :
758 llvm::GlobalVariable::LinkOnceODRLinkage :
763 llvm::GlobalVariable::WeakODRLinkage :
767 llvm_unreachable(
"Should not have been asked to emit this");
776 llvm::GlobalVariable::LinkageTypes DiscardableODRLinkage =
777 llvm::GlobalValue::LinkOnceODRLinkage;
778 llvm::GlobalVariable::LinkageTypes NonDiscardableODRLinkage =
779 llvm::GlobalValue::WeakODRLinkage;
780 if (RD->
hasAttr<DLLExportAttr>()) {
782 DiscardableODRLinkage = NonDiscardableODRLinkage;
783 }
else if (RD->
hasAttr<DLLImportAttr>()) {
785 DiscardableODRLinkage = llvm::GlobalVariable::AvailableExternallyLinkage;
786 NonDiscardableODRLinkage = llvm::GlobalVariable::AvailableExternallyLinkage;
793 return DiscardableODRLinkage;
797 ? llvm::GlobalVariable::AvailableExternallyLinkage
801 return NonDiscardableODRLinkage;
804 llvm_unreachable(
"Invalid TemplateSpecializationKind!");
820 DI->completeClassData(RD);
839 assert(RD->
isDynamicClass() &&
"Non-dynamic classes have no VTable.");
861 return !keyFunction->
hasBody();
880 void CodeGenModule::EmitDeferredVTables() {
884 size_t savedSize = DeferredVTables.size();
891 assert(savedSize == DeferredVTables.size() &&
892 "deferred extra v-tables during v-table emission?");
893 DeferredVTables.clear();
898 getContext().getSanitizerBlacklist().isBlacklistedType(
"attr:uuid"))
907 if (!LangOpts.
Sanitize.
has(SanitizerKind::CFIVCall) &&
908 !LangOpts.
Sanitize.
has(SanitizerKind::CFINVCall) &&
909 !LangOpts.
Sanitize.
has(SanitizerKind::CFIDerivedCast) &&
910 !LangOpts.
Sanitize.
has(SanitizerKind::CFIUnrelatedCast))
916 typedef std::pair<const CXXRecordDecl *, unsigned> BSEntry;
917 std::vector<BSEntry> BitsetEntries;
923 BitsetEntries.push_back(std::make_pair(AP.first.getBase(), AP.second));
927 std::sort(BitsetEntries.begin(), BitsetEntries.end(),
928 [
this](
const BSEntry &E1,
const BSEntry &E2) {
933 llvm::raw_string_ostream O1(S1);
935 QualType(E1.first->getTypeForDecl(), 0), O1);
939 llvm::raw_string_ostream O2(S2);
941 QualType(E2.first->getTypeForDecl(), 0), O2);
949 return E1.second < E2.second;
952 llvm::NamedMDNode *BitsetsMD =
953 getModule().getOrInsertNamedMetadata(
"llvm.bitsets");
954 for (
auto BitsetEntry : BitsetEntries)
956 PointerWidth * BitsetEntry.second,
ReturnValueSlot - Contains the address where the return value of a function can be stored...
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.
SanitizerSet Sanitize
Set of enabled sanitizers.
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...
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
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
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
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
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 ...
const SanitizerBlacklist & getSanitizerBlacklist() const
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
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 ...
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() const
unsigned getRegParm() const
This template specialization was implicitly instantiated from a template.
virtual void adjustCallArgsForDestructorThunk(CodeGenFunction &CGF, GlobalDecl GD, CallArgList &CallArgs)
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
bool isBlacklistedType(StringRef MangledTypeName, StringRef Category=StringRef()) 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.
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
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...
void EmitVTableBitSetEntries(llvm::GlobalVariable *VTable, const VTableLayout &VTLayout)
Emit bit set entries for the given vtable using the given layout if vptr CFI is enabled.
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.
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
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)
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...
static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, unsigned additional)
Compute the arguments required by the given formal prototype, given that there may be some additional...
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
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
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.
std::string getQualifiedNameAsString() const
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.
bool IsCFIBlacklistedRecord(const CXXRecordDecl *RD)
Returns whether the given record is blacklisted from control flow integrity checks.
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.
void CreateVTableBitSetEntry(llvm::NamedMDNode *BitsetsMD, llvm::GlobalVariable *VTable, CharUnits Offset, const CXXRecordDecl *RD)
Create a bitset entry for the given vtable and add it to BitsetsMD.
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
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.
SourceLocation getLocation() const
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 v-table is required to be emitted in t...
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.