Lines Matching full:cgf
28 commonEmitCXXMemberOrOperatorCall(CodeGenFunction &CGF, const CXXMethodDecl *MD,
43 CGF.EmitTypeCheck(
46 CallLoc, This, CGF.getContext().getRecordType(MD->getParent()));
49 Args.add(RValue::get(This), MD->getThisType(CGF.getContext()));
63 CGF.EmitCallArgs(Args, FPT, drop_begin(CE->arguments(), ArgsToSkip),
352 static void EmitNullBaseClassInitialization(CodeGenFunction &CGF,
358 DestPtr = CGF.Builder.CreateElementBitCast(DestPtr, CGF.Int8Ty);
360 const ASTRecordLayout &Layout = CGF.getContext().getASTRecordLayout(Base);
370 CharUnits VBPtrWidth = CGF.getPointerSize();
372 CGF.CGM.getCXXABI().getVBPtrOffsets(Base);
400 llvm::Constant *NullConstantForBase = CGF.CGM.EmitNullConstantForBase(Base);
403 CGF.CGM.getModule(), NullConstantForBase->getType(),
411 Address SrcPtr = Address(CGF.EmitCastToVoidPtr(NullVariable), Align);
417 llvm::Value *StoreSizeVal = CGF.CGM.getSize(StoreSize);
418 CGF.Builder.CreateMemCpy(
419 CGF.Builder.CreateConstInBoundsByteGEP(DestPtr, StoreOffset),
420 CGF.Builder.CreateConstInBoundsByteGEP(SrcPtr, StoreOffset),
431 llvm::Value *StoreSizeVal = CGF.CGM.getSize(StoreSize);
432 CGF.Builder.CreateMemSet(
433 CGF.Builder.CreateConstInBoundsByteGEP(DestPtr, StoreOffset),
434 CGF.Builder.getInt8(0), StoreSizeVal);
534 static CharUnits CalculateCookiePadding(CodeGenFunction &CGF,
544 return CGF.CGM.getCXXABI().GetArrayCookieSize(E);
547 static llvm::Value *EmitCXXNewAllocSize(CodeGenFunction &CGF,
555 CharUnits typeSize = CGF.getContext().getTypeSizeInChars(type);
557 = llvm::ConstantInt::get(CGF.SizeTy, typeSize.getQuantity());
562 unsigned sizeWidth = CGF.SizeTy->getBitWidth();
566 CalculateCookiePadding(CGF, e).getQuantity());
571 numElements = CGF.EmitScalarExpr(e->getArraySize());
589 = CGF.getContext().getAsConstantArrayType(type)) {
594 CharUnits typeSize = CGF.getContext().getTypeSizeInChars(type);
631 numElements = llvm::ConstantInt::get(CGF.SizeTy,
644 sizeWithoutCookie = llvm::ConstantInt::get(CGF.SizeTy, allocationSize);
652 size = llvm::Constant::getAllOnesValue(CGF.SizeTy);
654 size = llvm::ConstantInt::get(CGF.SizeTy, allocationSize);
684 hasOverflow = CGF.Builder.CreateICmpUGE(numElements, thresholdV);
685 numElements = CGF.Builder.CreateTrunc(numElements, CGF.SizeTy);
690 numElements = CGF.Builder.CreateSExt(numElements, CGF.SizeTy);
698 hasOverflow = CGF.Builder.CreateICmpSLT(numElements,
699 llvm::ConstantInt::get(CGF.SizeTy, minElements));
703 numElements = CGF.Builder.CreateZExt(numElements, CGF.SizeTy);
706 assert(numElements->getType() == CGF.SizeTy);
711 hasOverflow = CGF.Builder.CreateICmpULT(numElements,
712 llvm::ConstantInt::get(CGF.SizeTy, minElements));
717 hasOverflow = CGF.Builder.CreateOr(hasOverflow,
718 CGF.Builder.CreateICmpULT(numElements,
719 llvm::ConstantInt::get(CGF.SizeTy, minElements)));
734 = CGF.CGM.getIntrinsic(llvm::Intrinsic::umul_with_overflow, CGF.SizeTy);
737 llvm::ConstantInt::get(CGF.SizeTy, typeSizeMultiplier);
739 CGF.Builder.CreateCall(umul_with_overflow, {size, tsmV});
741 llvm::Value *overflowed = CGF.Builder.CreateExtractValue(result, 1);
743 hasOverflow = CGF.Builder.CreateOr(hasOverflow, overflowed);
747 size = CGF.Builder.CreateExtractValue(result, 0);
760 llvm::ConstantInt::get(CGF.SizeTy, arraySizeMultiplier);
761 numElements = CGF.Builder.CreateMul(numElements, asmV);
774 = CGF.CGM.getIntrinsic(llvm::Intrinsic::uadd_with_overflow, CGF.SizeTy);
776 llvm::Value *cookieSizeV = llvm::ConstantInt::get(CGF.SizeTy, cookieSize);
778 CGF.Builder.CreateCall(uadd_with_overflow, {size, cookieSizeV});
780 llvm::Value *overflowed = CGF.Builder.CreateExtractValue(result, 1);
782 hasOverflow = CGF.Builder.CreateOr(hasOverflow, overflowed);
786 size = CGF.Builder.CreateExtractValue(result, 0);
793 size = CGF.Builder.CreateSelect(hasOverflow,
794 llvm::Constant::getAllOnesValue(CGF.SizeTy),
806 static void StoreAnyExprIntoOneUnit(CodeGenFunction &CGF, const Expr *Init,
809 switch (CGF.getEvaluationKind(AllocType)) {
811 CGF.EmitScalarInit(Init, nullptr,
812 CGF.MakeAddrLValue(NewPtr, AllocType), false);
815 CGF.EmitComplexExprIntoLValue(Init, CGF.MakeAddrLValue(NewPtr, AllocType),
824 CGF.EmitAggExpr(Init, Slot);
1098 static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E,
1102 ApplyDebugLocation DL(CGF, E);
1104 CGF.EmitNewArrayInitializer(E, ElementType, ElementTy, NewPtr, NumElements,
1107 StoreAnyExprIntoOneUnit(CGF, Init, E->getAllocatedType(), NewPtr);
1112 static RValue EmitNewDeleteCall(CodeGenFunction &CGF,
1117 llvm::Value *CalleeAddr = CGF.CGM.GetAddrOfFunction(Callee);
1119 CGF.EmitCall(CGF.CGM.getTypes().arrangeFreeFunctionCall(
1190 void Emit(CodeGenFunction &CGF, Flags flags) override {
1211 EmitNewDeleteCall(CGF, OperatorDelete, FPT, DeleteArgs);
1245 void Emit(CodeGenFunction &CGF, Flags flags) override {
1255 DeleteArgs.add(Ptr.restore(CGF), *AI++);
1259 RValue RV = AllocSize.restore(CGF);
1265 RValue RV = getPlacementArgs()[I].restore(CGF);
1270 EmitNewDeleteCall(CGF, OperatorDelete, FPT, DeleteArgs);
1277 static void EnterNewDeleteCleanup(CodeGenFunction &CGF,
1284 if (!CGF.isInConditionalBranch()) {
1285 CallDeleteDuringNew *Cleanup = CGF.EHStack
1299 DominatingValue<RValue>::save(CGF, RValue::get(NewPtr.getPointer()));
1301 DominatingValue<RValue>::save(CGF, RValue::get(AllocSize));
1303 CallDeleteDuringConditionalNew *Cleanup = CGF.EHStack
1311 DominatingValue<RValue>::save(CGF, NewArgs[I+1].RV));
1313 CGF.initFullExprCleanup();
1530 void Emit(CodeGenFunction &CGF, Flags flags) override {
1531 CGF.EmitDeleteCall(OperatorDelete, Ptr, ElementType);
1545 static void EmitObjectDelete(CodeGenFunction &CGF,
1558 CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
1569 CGF.EHStack.pushCleanup<CallObjectDelete>(NormalAndEHCleanup,
1574 CGF.EmitCXXDestructorCall(Dtor, Dtor_Complete,
1586 CGF.EmitARCDestroyStrong(Ptr, ARCPreciseLifetime);
1590 CGF.EmitARCDestroyWeak(Ptr);
1595 CGF.PopCleanupBlock();
1615 void Emit(CodeGenFunction &CGF, Flags flags) override {
1625 = CGF.Builder.CreateBitCast(Ptr, CGF
1632 = cast<llvm::IntegerType>(CGF.ConvertType(size_t));
1635 CGF.CGM.getContext().getTypeSizeInChars(ElementType);
1641 Size = CGF.Builder.CreateMul(Size, NumElements);
1647 Size = CGF.Builder.CreateAdd(Size, CookieSizeV);
1654 EmitNewDeleteCall(CGF, OperatorDelete, DeleteFTy, Args);
1660 static void EmitArrayDelete(CodeGenFunction &CGF,
1667 CGF.CGM.getCXXABI().ReadArrayCookie(CGF, deletedPtr, E, elementType,
1674 CGF.EHStack.pushCleanup<CallArrayDelete>(NormalAndEHCleanup,
1683 CharUnits elementSize = CGF.getContext().getTypeSizeInChars(elementType);
1689 CGF.Builder.CreateInBoundsGEP(arrayBegin, numElements, "delete.end");
1694 CGF.emitArrayDestroy(arrayBegin, arrayEnd, elementType, elementAlign,
1695 CGF.getDestroyer(dtorKind),
1697 CGF.needsEHCleanup(dtorKind));
1701 CGF.PopCleanupBlock();
1784 static llvm::Value *EmitTypeidFromVTable(CodeGenFunction &CGF, const Expr *E,
1787 Address ThisPtr = CGF.EmitLValue(E).getAddress();
1798 if (CGF.CGM.getCXXABI().shouldTypeidBeNullChecked(
1801 CGF.createBasicBlock("typeid.bad_typeid");
1802 llvm::BasicBlock *EndBlock = CGF.createBasicBlock("typeid.end");
1804 llvm::Value *IsNull = CGF.Builder.CreateIsNull(ThisPtr.getPointer());
1805 CGF.Builder.CreateCondBr(IsNull, BadTypeidBlock, EndBlock);
1807 CGF.EmitBlock(BadTypeidBlock);
1808 CGF.CGM.getCXXABI().EmitBadTypeidCall(CGF);
1809 CGF.EmitBlock(EndBlock);
1812 return CGF.CGM.getCXXABI().EmitTypeid(CGF, SrcRecordTy, ThisPtr,
1840 static llvm::Value *EmitDynamicCastToNull(CodeGenFunction &CGF,
1842 llvm::Type *DestLTy = CGF.ConvertType(DestTy);
1848 if (!CGF.CGM.getCXXABI().EmitBadCastCall(CGF))
1851 CGF.EmitBlock(CGF.createBasicBlock("dynamic_cast.end"));