Lines Matching refs:CGF
73 EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF,
80 EmitMemberDataPointerAddress(CodeGenFunction &CGF, const Expr *E,
85 llvm::Value *EmitMemberPointerConversion(CodeGenFunction &CGF,
100 llvm::Value *EmitMemberPointerComparison(CodeGenFunction &CGF,
105 llvm::Value *EmitMemberPointerIsNotNull(CodeGenFunction &CGF,
109 llvm::Value *adjustToCompleteObject(CodeGenFunction &CGF, llvm::Value *ptr,
117 void EmitBadTypeidCall(CodeGenFunction &CGF) override;
118 llvm::Value *EmitTypeid(CodeGenFunction &CGF, QualType SrcRecordTy,
125 llvm::Value *EmitDynamicCastCall(CodeGenFunction &CGF, llvm::Value *Value,
130 llvm::Value *EmitDynamicCastToVoid(CodeGenFunction &CGF, llvm::Value *Value,
134 bool EmitBadCastCall(CodeGenFunction &CGF) override;
137 GetVirtualBaseClassOffset(CodeGenFunction &CGF, llvm::Value *This,
161 void addImplicitStructorParams(CodeGenFunction &CGF, QualType &ResTy,
164 void EmitInstanceFunctionProlog(CodeGenFunction &CGF) override;
166 unsigned addImplicitConstructorArgs(CodeGenFunction &CGF,
172 void EmitDestructorCall(CodeGenFunction &CGF, const CXXDestructorDecl *DD,
180 CodeGenFunction &CGF, const CXXRecordDecl *VTableClass,
191 llvm::Value *getVirtualFunctionPointer(CodeGenFunction &CGF, GlobalDecl GD,
195 void EmitVirtualDestructorCall(CodeGenFunction &CGF,
210 llvm::Value *performThisAdjustment(CodeGenFunction &CGF, llvm::Value *This,
213 llvm::Value *performReturnAdjustment(CodeGenFunction &CGF, llvm::Value *Ret,
221 llvm::Value *InitializeArrayCookie(CodeGenFunction &CGF,
226 llvm::Value *readArrayCookieImpl(CodeGenFunction &CGF,
230 void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D,
233 void registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,
241 LValue EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF, const VarDecl *VD,
290 void EmitReturnFromThunk(CodeGenFunction &CGF, RValue RV,
294 llvm::Value *InitializeArrayCookie(CodeGenFunction &CGF,
299 llvm::Value *readArrayCookieImpl(CodeGenFunction &CGF, llvm::Value *allocPtr,
375 CodeGenFunction &CGF, const Expr *E, llvm::Value *&This,
377 CGBuilderTy &Builder = CGF.Builder;
390 llvm::BasicBlock *FnVirtual = CGF
391 llvm::BasicBlock *FnNonVirtual = CGF.createBasicBlock("memptr.nonvirtual");
392 llvm::BasicBlock *FnEnd = CGF.createBasicBlock("memptr.end");
424 CGF.EmitBlock(FnVirtual);
428 llvm::Value *VTable = CGF.GetVTablePtr(This, VTableTy);
439 CGF.EmitBranch(FnEnd);
443 CGF.EmitBlock(FnNonVirtual);
448 CGF.EmitBlock(FnEnd);
458 CodeGenFunction &CGF, const Expr *E, llvm::Value *Base, llvm::Value *MemPtr,
462 CGBuilderTy &Builder = CGF.Builder;
475 = CGF.ConvertTypeForMem(MPT->getPointeeType())->getPointerTo(AS);
503 ItaniumCXXABI::EmitMemberPointerConversion(CodeGenFunction &CGF,
520 CGBuilderTy &Builder = CGF.Builder;
712 ItaniumCXXABI::EmitMemberPointerComparison(CodeGenFunction &CGF,
717 CGBuilderTy &Builder = CGF.Builder;
786 ItaniumCXXABI::EmitMemberPointerIsNotNull(CodeGenFunction &CGF,
789 CGBuilderTy &Builder = CGF.Builder;
842 llvm::Value *ItaniumCXXABI::adjustToCompleteObject(CodeGenFunction &CGF,
846 llvm::Value *vtable = CGF.GetVTablePtr(ptr, CGF.IntPtrTy->getPointerTo());
850 CGF.Builder.CreateConstInBoundsGEP1_64(vtable, -2, "complete-offset.ptr");
851 llvm::LoadInst *offset = CGF.Builder.CreateLoad(offsetPtr);
852 offset->setAlignment(CGF.PointerAlignInBytes);
855 ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
856 return CGF.Builder.CreateInBoundsGEP(ptr, offset);
859 static llvm::Constant *getItaniumDynamicCastFn(CodeGenFunction &CGF) {
865 llvm::Type *Int8PtrTy = CGF.Int8PtrTy;
867 CGF.ConvertType(CGF.getContext().getPointerDiffType());
877 CGF.getLLVMContext(), llvm::AttributeSet::FunctionIndex, FuncAttrs);
879 return CGF.CGM.CreateRuntimeFunction(FTy, "__dynamic_cast", Attrs);
882 static llvm::Constant *getBadCastFn(CodeGenFunction &CGF) {
884 llvm::FunctionType *FTy = llvm::FunctionType::get(CGF.VoidTy, false);
885 return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_bad_cast");
940 static llvm::Constant *getBadTypeidFn(CodeGenFunction &CGF) {
942 llvm::FunctionType *FTy = llvm::FunctionType::get(CGF.VoidTy, false);
944 return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_bad_typeid");
952 void ItaniumCXXABI::EmitBadTypeidCall(CodeGenFunction &CGF) {
953 llvm::Value *Fn = getBadTypeidFn(CGF);
954 CGF.EmitRuntimeCallOrInvoke(Fn).setDoesNotReturn();
955 CGF.Builder.CreateUnreachable();
958 llvm::Value *ItaniumCXXABI::EmitTypeid(CodeGenFunction &CGF,
963 CGF.GetVTablePtr(ThisPtr, StdTypeInfoPtrTy->getPointerTo());
966 Value = CGF.Builder.CreateConstInBoundsGEP1_64(Value, -1ULL);
967 return CGF.Builder.CreateLoad(Value);
976 CodeGenFunction &CGF, llvm::Value *Value, QualType SrcRecordTy,
979 CGF.ConvertType(CGF.getContext().getPointerDiffType());
980 llvm::Type *DestLTy = CGF.ConvertType(DestTy);
983 CGF.CGM.GetAddrOfRTTIDescriptor(SrcRecordTy.getUnqualifiedType());
985 CGF.CGM.GetAddrOfRTTIDescriptor(DestRecordTy.getUnqualifiedType());
992 computeOffsetHint(CGF.getContext(), SrcDecl, DestDecl).getQuantity());
995 Value = CGF.EmitCastToVoidPtr(Value);
998 Value = CGF.EmitNounwindRuntimeCall(getItaniumDynamicCastFn(CGF), args);
999 Value = CGF.Builder.CreateBitCast(Value, DestLTy);
1005 CGF.createBasicBlock("dynamic_cast.bad_cast");
1007 llvm::Value *IsNull = CGF.Builder.CreateIsNull(Value);
1008 CGF.Builder.CreateCondBr(IsNull, BadCastBlock, CastEnd);
1010 CGF.EmitBlock(BadCastBlock);
1011 EmitBadCastCall(CGF);
1017 llvm::Value *ItaniumCXXABI::EmitDynamicCastToVoid(CodeGenFunction &CGF,
1022 CGF.ConvertType(CGF.getContext().getPointerDiffType());
1023 llvm::Type *DestLTy = CGF.ConvertType(DestTy);
1026 llvm::Value *VTable = CGF.GetVTablePtr(Value, PtrDiffLTy->getPointerTo());
1030 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, -2ULL);
1031 OffsetToTop = CGF.Builder.CreateLoad(OffsetToTop, "offset.to.top");
1034 Value = CGF.EmitCastToVoidPtr(Value);
1035 Value = CGF.Builder.CreateInBoundsGEP(Value, OffsetToTop);
1037 return CGF.Builder.CreateBitCast(Value, DestLTy);
1040 bool ItaniumCXXABI::EmitBadCastCall(CodeGenFunction &CGF) {
1041 llvm::Value *Fn = getBadCastFn(CGF);
1042 CGF.EmitRuntimeCallOrInvoke(Fn).setDoesNotReturn();
1043 CGF.Builder.CreateUnreachable();
1048 ItaniumCXXABI::GetVirtualBaseClassOffset(CodeGenFunction &CGF,
1052 llvm::Value *VTablePtr = CGF.GetVTablePtr(This, CGM.Int8PtrTy);
1058 CGF.Builder.CreateConstGEP1_64(VTablePtr, VBaseOffsetOffset.getQuantity(),
1060 VBaseOffsetPtr = CGF.Builder.CreateBitCast(VBaseOffsetPtr,
1064 CGF.Builder.CreateLoad(VBaseOffsetPtr, "vbase.offset");
1134 void ItaniumCXXABI::addImplicitStructorParams(CodeGenFunction &CGF,
1137 const CXXMethodDecl *MD = cast<CXXMethodDecl>(CGF.CurGD.getDecl());
1141 if (NeedsVTTParameter(CGF.CurGD)) {
1150 getStructorImplicitParamDecl(CGF) = VTTDecl;
1154 void ItaniumCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) {
1156 EmitThisParam(CGF);
1159 if (getStructorImplicitParamDecl(CGF)) {
1160 getStructorImplicitParamValue(CGF) = CGF.Builder.CreateLoad(
1161 CGF.GetAddrOfLocalVar(getStructorImplicitParamDecl(CGF)), "vtt");
1172 if (HasThisReturn(CGF.CurGD))
1173 CGF.Builder.CreateStore(getThisValue(CGF), CGF.ReturnValue);
1177 CodeGenFunction &CGF, const CXXConstructorDecl *D, CXXCtorType Type,
1184 CGF.GetVTTParameter(GlobalDecl(D, Type), ForVirtualBase, Delegating);
1191 void ItaniumCXXABI::EmitDestructorCall(CodeGenFunction &CGF,
1196 llvm::Value *VTT = CGF.GetVTTParameter(GD, ForVirtualBase, Delegating);
1201 Callee = CGF.BuildAppleKextVirtualDestructorCall(DD, Type, DD->getParent());
1207 CGF
1248 CodeGenFunction &CGF, const CXXRecordDecl *VTableClass, BaseSubobject Base,
1250 bool NeedsVTTParam = CGM.getCXXABI().NeedsVTTParameter(CGF.CurGD);
1260 llvm::Value *VTT = CGF.LoadCXXVTT();
1262 VTT = CGF.Builder.CreateConstInBoundsGEP1_64(VTT, VirtualPointerIndex);
1265 VTableAddressPoint = CGF.Builder.CreateLoad(VTT);
1273 CGF.Builder.CreateConstInBoundsGEP2_64(VTable, 0, AddressPoint);
1328 llvm::Value *ItaniumCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
1334 llvm::Value *VTable = CGF.GetVTablePtr(This, Ty);
1338 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
1339 return CGF.Builder.CreateLoad(VFuncPtr);
1342 void ItaniumCXXABI::EmitVirtualDestructorCall(CodeGenFunction &CGF,
1351 llvm::Type *Ty = CGF.CGM.getTypes().GetFunctionType(*FInfo);
1353 getVirtualFunctionPointer(CGF, GlobalDecl(Dtor, DtorType), This, Ty);
1355 CGF.EmitCXXMemberCall(Dtor, CallLoc, Callee, ReturnValueSlot(), This,
1366 static llvm::Value *performTypeAdjustment(CodeGenFunction &CGF,
1374 llvm::Type *Int8PtrTy = CGF.Int8PtrTy;
1375 llvm::Value *V = CGF.Builder.CreateBitCast(Ptr, Int8PtrTy);
1379 V = CGF.Builder.CreateConstInBoundsGEP1_64(V, NonVirtualAdjustment);
1384 CGF.ConvertType(CGF.getContext().getPointerDiffType());
1388 CGF.Builder.CreateBitCast(V, Int8PtrTy->getPointerTo());
1390 llvm::Value *VTablePtr = CGF.Builder.CreateLoad(VTablePtrPtr);
1393 CGF.Builder.CreateConstInBoundsGEP1_64(VTablePtr, VirtualAdjustment);
1395 OffsetPtr = CGF.Builder.CreateBitCast(OffsetPtr, PtrDiffTy->getPointerTo());
1398 llvm::Value *Offset = CGF.Builder.CreateLoad(OffsetPtr);
1401 V = CGF.Builder.CreateInBoundsGEP(V, Offset);
1406 V = CGF.Builder.CreateConstInBoundsGEP1_64(V, NonVirtualAdjustment);
1410 return CGF.Builder.CreateBitCast(V, Ptr->getType());
1413 llvm::Value *ItaniumCXXABI::performThisAdjustment(CodeGenFunction &CGF,
1416 return performTypeAdjustment(CGF, This, TA.NonVirtual,
1422 ItaniumCXXABI::performReturnAdjustment(CodeGenFunction &CGF, llvm::Value *Ret,
1424 return performTypeAdjustment(CGF, Ret, RA.NonVirtual,
1429 void ARMCXXABI::EmitReturnFromThunk(CodeGenFunction &CGF,
1431 if (!isa<CXXDestructorDecl>(CGF.CurGD.getDecl()))
1432 return ItaniumCXXABI::EmitReturnFromThunk(CGF, RV, ResultType);
1436 cast<llvm::PointerType>(CGF.ReturnValue->getType())->getElementType();
1438 return ItaniumCXXABI::EmitReturnFromThunk(CGF, Undef, ResultType);
1450 llvm::Value *ItaniumCXXABI::InitializeArrayCookie(CodeGenFunction &CGF,
1472 CookiePtr = CGF.Builder.CreateConstInBoundsGEP1_64(CookiePtr,
1477 = CGF.Builder.CreateBitCast(CookiePtr,
1478 CGF.ConvertType(SizeTy)->getPointerTo(AS));
1479 CGF.Builder.CreateStore(NumElements, NumElementsPtr);
1483 return CGF.Builder.CreateConstInBoundsGEP1_64(NewPtr,
1487 llvm::Value *ItaniumCXXABI::readArrayCookieImpl(CodeGenFunction &CGF,
1493 cookieSize - CharUnits::fromQuantity(CGF.SizeSizeInBytes);
1496 CGF.Builder.CreateConstInBoundsGEP1_64(numElementsPtr,
1501 CGF.Builder.CreateBitCast(numElementsPtr, CGF.SizeTy->getPointerTo(AS));
1502 return CGF.Builder.CreateLoad(numElementsPtr);
1518 llvm::Value *ARMCXXABI::InitializeArrayCookie(CodeGenFunction &CGF,
1532 cookie = CGF.Builder.CreateBitCast(cookie, CGF.SizeTy->getPointerTo(AS));
1533 llvm::Value *elementSize = llvm::ConstantInt::get(CGF.SizeTy,
1535 CGF.Builder.CreateStore(elementSize, cookie);
1538 cookie = CGF.Builder.CreateConstInBoundsGEP1_32(cookie, 1);
1539 CGF.Builder.CreateStore(numElements, cookie);
1544 return CGF.Builder.CreateConstInBoundsGEP1_64(newPtr,
1548 llvm::Value *ARMCXXABI::readArrayCookieImpl(CodeGenFunction &CGF,
1554 = CGF.Builder.CreateConstInBoundsGEP1_64(allocPtr, CGF.SizeSizeInBytes);
1558 CGF.Builder.CreateBitCast(numElementsPtr, CGF.SizeTy->getPointerTo(AS));
1559 return CGF.Builder.CreateLoad(numElementsPtr);
1603 void Emit(CodeGenFunction &CGF, Flags flags) override {
1604 CGF.EmitNounwindRuntimeCall(getGuardAbortFn(CGF.CGM, Guard->getType()),
1612 void ItaniumCXXABI::EmitGuardedInit(CodeGenFunction &CGF,
1616 CGBuilderTy &Builder = CGF.Builder;
1629 guardTy = CGF.Int8Ty;
1633 guardTy = (UseARMGuardVarABI ? CGF.SizeTy : CGF.Int64Ty);
1719 llvm::BasicBlock *InitCheckBlock = CGF.createBasicBlock("init.check");
1720 llvm::BasicBlock *EndBlock = CGF.createBasicBlock("init.end");
1725 CGF.EmitBlock(InitCheckBlock);
1731 = CGF.EmitNounwindRuntimeCall(getGuardAcquireFn(CGM, guardPtrTy), guard);
1733 llvm::BasicBlock *InitBlock = CGF.createBasicBlock("init");
1739 CGF.EHStack.pushCleanup<CallGuardAbort>(EHCleanup, guard);
1741 CGF.EmitBlock(InitBlock);
1745 CGF.EmitCXXGlobalVarDeclInit(D, var, shouldPerformInit);
1749 CGF.PopCleanupBlock();
1752 CGF.EmitNounwindRuntimeCall(getGuardReleaseFn(CGM, guardPtrTy), guard);
1757 CGF.EmitBlock(EndBlock);
1761 static void emitGlobalDtorWithCXAAtExit(CodeGenFunction &CGF,
1767 const llvm::Triple &T = CGF.getTarget().getTriple();
1775 llvm::FunctionType::get(CGF.VoidTy, CGF.Int8PtrTy, false)->getPointerTo();
1778 llvm::Type *paramTys[] = { dtorTy, CGF.Int8PtrTy, CGF.Int8PtrTy };
1780 llvm::FunctionType::get(CGF.IntTy, paramTys, false);
1783 llvm::Constant *atexit = CGF.CGM.CreateRuntimeFunction(atexitTy, Name);
1789 CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
1793 llvm::ConstantExpr::getBitCast(addr, CGF.Int8PtrTy),
1796 CGF.EmitNounwindRuntimeCall(atexit, args);
1800 void ItaniumCXXABI::registerGlobalDtor(CodeGenFunction &CGF,
1806 return emitGlobalDtorWithCXAAtExit(CGF, dtor, addr, D.getTLSKind());
1818 CGF.registerGlobalDtorWithAtExit(D, dtor, addr);
1943 LValue ItaniumCXXABI::EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF,
1947 llvm::Type *Ty = CGF.getTypes().ConvertTypeForMem(T);
1948 llvm::Value *Val = CGF.CGM.GetAddrOfGlobalVar(VD, Ty);
1952 Val = CGF.Builder.CreateCall(Wrapper);
1956 LV = CGF.MakeNaturalAlignAddrLValue(Val, LValType);
1958 LV = CGF.MakeAddrLValue(Val, LValType, CGF.getContext().getDeclAlign(VD));