Lines Matching refs:CGF
60 llvm::Value *adjustToCompleteObject(CodeGenFunction &CGF,
70 void EmitBadTypeidCall(CodeGenFunction &CGF) override;
71 llvm::Value *EmitTypeid(CodeGenFunction &CGF, QualType SrcRecordTy,
78 llvm::Value *EmitDynamicCastCall(CodeGenFunction &CGF, llvm::Value *Value,
83 llvm::Value *EmitDynamicCastToVoid(CodeGenFunction &CGF, llvm::Value *Value,
87 bool EmitBadCastCall(CodeGenFunction &CGF) override;
90 GetVirtualBaseClassOffset(CodeGenFunction &CGF, llvm::Value *This,
99 EmitCtorCompleteObjectHandler(CodeGenFunction &CGF,
102 void initializeHiddenVirtualInheritanceMembers(CodeGenFunction &CGF,
171 adjustThisArgumentForVirtualFunctionCall(CodeGenFunction &CGF, GlobalDecl GD,
175 void addImplicitStructorParams(CodeGenFunction &CGF, QualType &ResTy,
179 CodeGenFunction &CGF, GlobalDecl GD, llvm::Value *This) override;
181 void EmitInstanceFunctionProlog(CodeGenFunction &CGF) override;
183 unsigned addImplicitConstructorArgs(CodeGenFunction &CGF,
189 void EmitDestructorCall(CodeGenFunction &CGF, const CXXDestructorDecl *DD,
197 CodeGenFunction &CGF, const CXXRecordDecl *VTableClass,
208 llvm::Value *getVirtualFunctionPointer(CodeGenFunction &CGF, GlobalDecl GD,
212 void EmitVirtualDestructorCall(CodeGenFunction &CGF,
217 void adjustCallArgsForDestructorThunk(CodeGenFunction &CGF, GlobalDecl GD,
221 CallArgs.add(RValue::get(getStructorImplicitParamValue(CGF)),
250 llvm::Value *performThisAdjustment(CodeGenFunction &CGF, llvm::Value *This,
253 llvm::Value *performReturnAdjustment(CodeGenFunction &CGF, llvm::Value *Ret,
256 void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D,
287 llvm::Value *InitializeArrayCookie(CodeGenFunction &CGF,
292 llvm::Value *readArrayCookieImpl(CodeGenFunction &CGF,
434 llvm::Value *GetVBaseOffsetFromVBPtr(CodeGenFunction &CGF,
440 llvm::Value *GetVBaseOffsetFromVBPtr(CodeGenFunction &CGF,
447 return GetVBaseOffsetFromVBPtr(CGF, Base, VBPOffset, VBTOffset, VBPtr);
452 llvm::Value *AdjustVirtualBase(CodeGenFunction &CGF, const Expr *E,
472 void EmitVBPtrStores(CodeGenFunction &CGF, const CXXRecordDecl *RD);
494 llvm::Value *EmitMemberPointerComparison(CodeGenFunction &CGF,
500 llvm::Value *EmitMemberPointerIsNotNull(CodeGenFunction &CGF,
505 EmitMemberDataPointerAddress(CodeGenFunction &CGF, const Expr *E,
509 llvm::Value *EmitMemberPointerConversion(CodeGenFunction &CGF,
517 EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF, const Expr *E,
610 llvm::Value *MicrosoftCXXABI::adjustToCompleteObject(CodeGenFunction &CGF,
619 static llvm::Value *getPolymorphicOffset(CodeGenFunction &CGF,
626 return CGF.CGM.getCXXABI().GetVirtualBaseClassOffset(
627 CGF, Value, RD, Base.getType()->getAsCXXRecordDecl());
632 performBaseAdjustment(CodeGenFunction &CGF, llvm::Value *Value,
634 Value = CGF.Builder.CreateBitCast(Value, CGF.Int8PtrTy);
637 if (CGF.getContext().getASTRecordLayout(SrcDecl).hasExtendableVFPtr())
638 return std::make_pair(Value, llvm::ConstantInt::get(CGF.Int32Ty, 0));
641 llvm::Value *Offset = getPolymorphicOffset(CGF, SrcDecl, Value);
642 Value = CGF.Builder.CreateInBoundsGEP(Value, Offset);
643 Offset = CGF.Builder.CreateTrunc(Offset, CGF.Int32Ty);
654 static llvm::CallSite emitRTtypeidCall(CodeGenFunction &CGF,
656 llvm::Type *ArgTypes[] = {CGF.Int8PtrTy};
658 llvm::FunctionType::get(CGF.Int8PtrTy, ArgTypes, false);
660 llvm::Constant *Fn = CGF.CGM.CreateRuntimeFunction(FTy, "__RTtypeid");
661 return CGF.EmitRuntimeCallOrInvoke(Fn, Args);
664 void MicrosoftCXXABI::EmitBadTypeidCall(CodeGenFunction &CGF) {
666 emitRTtypeidCall(CGF, llvm::Constant::getNullValue(CGM.VoidPtrTy));
668 CGF.Builder.CreateUnreachable();
671 llvm::Value *MicrosoftCXXABI::EmitTypeid(CodeGenFunction &CGF,
676 std::tie(ThisPtr, Offset) = performBaseAdjustment(CGF, ThisPtr, SrcRecordTy);
677 return CGF.Builder.CreateBitCast(
678 emitRTtypeidCall(CGF, ThisPtr).getInstruction(), StdTypeInfoPtrTy);
689 CodeGenFunction &CGF, llvm::Value *Value, QualType SrcRecordTy,
691 llvm::Type *DestLTy = CGF.ConvertType(DestTy);
694 CGF.CGM.GetAddrOfRTTIDescriptor(SrcRecordTy.getUnqualifiedType());
696 CGF.CGM.GetAddrOfRTTIDescriptor(DestRecordTy.getUnqualifiedType());
699 std::tie(Value, Offset) = performBaseAdjustment(CGF, Value, SrcRecordTy);
707 llvm::Type *ArgTypes[] = {CGF.Int8PtrTy, CGF.Int32Ty, CGF.Int8PtrTy,
708 CGF.Int8PtrTy, CGF.Int32Ty};
709 llvm::Constant *Function = CGF.CGM.CreateRuntimeFunction(
710 llvm::FunctionType::get(CGF.Int8PtrTy, ArgTypes, false),
714 llvm::ConstantInt::get(CGF.Int32Ty, DestTy->isReferenceType())};
715 Value = CGF.EmitRuntimeCallOrInvoke(Function, Args).getInstruction();
716 return CGF.Builder.CreateBitCast(Value, DestLTy);
720 MicrosoftCXXABI::EmitDynamicCastToVoid(CodeGenFunction &CGF, llvm::Value *Value,
724 std::tie(Value, Offset) = performBaseAdjustment(CGF, Value, SrcRecordTy);
728 llvm::Type *ArgTypes[] = {CGF.Int8PtrTy};
729 llvm::Constant *Function = CGF.CGM.CreateRuntimeFunction(
730 llvm::FunctionType::get(CGF.Int8PtrTy, ArgTypes, false),
733 return CGF.EmitRuntimeCall(Function, Args);
736 bool MicrosoftCXXABI::EmitBadCastCall(CodeGenFunction &CGF) {
741 MicrosoftCXXABI::GetVirtualBaseClassOffset(CodeGenFunction &CGF,
756 GetVBaseOffsetFromVBPtr(CGF, This, VBPtrOffset, VBTableOffset);
758 CGF.Builder.CreateSExtOrBitCast(VBPtrToNewBase, CGM.PtrDiffTy);
759 return CGF.Builder.CreateNSWAdd(VBPtrOffset, VBPtrToNewBase);
805 CGF,
807 llvm::Value *IsMostDerivedClass = getStructorImplicitParamValue(CGF);
811 CGF.Builder.CreateIsNotNull(IsMostDerivedClass, "is_complete_object");
813 llvm::BasicBlock *CallVbaseCtorsBB = CGF.createBasicBlock("ctor.init_vbases");
814 llvm::BasicBlock *SkipVbaseCtorsBB = CGF.createBasicBlock("ctor.skip_vbases");
815 CGF.Builder.CreateCondBr(IsCompleteObject,
818 CGF.EmitBlock(CallVbaseCtorsBB);
821 EmitVBPtrStores(CGF, RD);
823 // CGF will put the base ctor calls in this basic block for us later.
829 CodeGenFunction &CGF, const CXXRecordDecl *RD) {
846 CGBuilderTy &Builder = CGF.Builder;
849 cast<llvm::PointerType>(getThisValue(CGF)->getType())->getAddressSpace();
858 GetVirtualBaseClassOffset(CGF, getThisValue(CGF), RD, I->first);
861 VBaseOffset = Builder.CreateTruncOrBitCast(VBaseOffset, CGF.Int32Ty);
871 Int8This = Builder.CreateBitCast(getThisValue(CGF),
872 CGF.Int8Ty->getPointerTo(AS));
877 VtorDispPtr, CGF.Int32Ty->getPointerTo(AS), "vtordisp.ptr");
888 void MicrosoftCXXABI::EmitVBPtrStores(CodeGenFunction &CGF,
891 CGF.Builder.CreateBitCast(getThisValue(CGF), CGM.Int8PtrTy, "this.int8");
905 CGF.Builder.CreateConstInBoundsGEP1_64(ThisInt8Ptr, Offs.getQuantity());
906 VBPtr = CGF.Builder.CreateBitCast(VBPtr, GV->getType()->getPointerTo(0),
908 CGF.Builder.CreateStore(GV, VBPtr);
970 CodeGenFunction &CGF, GlobalDecl GD, llvm::Value *This, bool VirtualCall) {
979 llvm::Type *charPtrTy = CGF.Int8Ty->getPointerTo(AS);
980 This = CGF.Builder.CreateBitCast(This, charPtrTy);
982 return CGF.Builder.CreateConstGEP1_32(This, Adjustment.getQuantity());
1003 llvm::Type *charPtrTy = CGF.Int8Ty->getPointerTo(AS);
1013 This = CGF.Builder.CreateBitCast(This, charPtrTy);
1015 GetVirtualBaseClassOffset(CGF, This, MD->getParent(), ML.VBase);
1016 This = CGF.Builder.CreateInBoundsGEP(This, VBaseOffset);
1020 This = CGF.Builder.CreateBitCast(This, charPtrTy);
1026 This = CGF.Builder.CreateConstGEP1_32(This, StaticOffset.getQuantity());
1028 This = CGF.Builder.CreateConstInBoundsGEP1_32(This,
1043 void MicrosoftCXXABI::addImplicitStructorParams(CodeGenFunction &CGF,
1047 const CXXMethodDecl *MD = cast<CXXMethodDecl>(CGF.CurGD.getDecl());
1052 CGF.CurGD.getDecl()->getLocation(),
1062 getStructorImplicitParamDecl(CGF) = IsMostDerived;
1063 } else if (IsDeletingDtor(CGF.CurGD)) {
1066 CGF.CurGD.getDecl()->getLocation(),
1070 getStructorImplicitParamDecl(CGF) = ShouldDelete;
1075 CodeGenFunction &CGF, GlobalDecl GD, llvm::Value *This) {
1086 llvm::Type *charPtrTy = CGF.Int8Ty->getPointerTo(AS),
1089 This = CGF.Builder.CreateBitCast(This, charPtrTy);
1092 CGF.Builder.CreateConstInBoundsGEP1_32(This, -Adjustment.getQuantity());
1093 return CGF.Builder.CreateBitCast(This, thisTy);
1096 void MicrosoftCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) {
1097 EmitThisParam(CGF);
1107 if (HasThisReturn(CGF.CurGD))
1108 CGF.Builder.CreateStore(getThisValue(CGF), CGF.ReturnValue);
1110 const CXXMethodDecl *MD = cast<CXXMethodDecl>(CGF.CurGD.getDecl());
1112 assert(getStructorImplicitParamDecl(CGF) &&
1114 getStructorImplicitParamValue(CGF)
1115 = CGF.Builder.CreateLoad(
1116 CGF.GetAddrOfLocalVar(getStructorImplicitParamDecl(CGF)),
1120 if (IsDeletingDtor(CGF.CurGD)) {
1121 assert(getStructorImplicitParamDecl(CGF) &&
1123 getStructorImplicitParamValue(CGF)
1124 = CGF.Builder.CreateLoad(
1125 CGF.GetAddrOfLocalVar(getStructorImplicitParamDecl(CGF)),
1131 CodeGenFunction &CGF, const CXXConstructorDecl *D, CXXCtorType Type,
1155 void MicrosoftCXXABI::EmitDestructorCall(CodeGenFunction &CGF,
1164 This = adjustThisArgumentForVirtualFunctionCall(CGF, GlobalDecl(DD, Type),
1169 CGF.EmitCXXMemberCall(DD, SourceLocation(), Callee, ReturnValueSlot(), This,
1198 CodeGenFunction &CGF, const CXXRecordDecl *VTableClass, BaseSubobject Base,
1360 llvm::Value *MicrosoftCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
1365 CGBuilderTy &Builder = CGF.Builder;
1369 adjustThisArgumentForVirtualFunctionCall(CGF, GD, This, true);
1370 llvm::Value *VTable = CGF.GetVTablePtr(VPtr, Ty);
1379 void MicrosoftCXXABI::EmitVirtualDestructorCall(CodeGenFunction &CGF,
1391 llvm::Type *Ty = CGF.CGM.getTypes().GetFunctionType(*FInfo);
1392 llvm::Value *Callee = getVirtualFunctionPointer(CGF, GD, This, Ty);
1394 ASTContext &Context = CGF.getContext();
1396 llvm::ConstantInt::get(llvm::IntegerType::getInt32Ty(CGF.getLLVMContext()),
1399 This = adjustThisArgumentForVirtualFunctionCall(CGF, GD, This, true);
1400 CGF.EmitCXXMemberCall(Dtor, CallLoc, Callee, ReturnValueSlot(), This,
1460 CodeGenFunction CGF(CGM);
1461 CGF.StartThunk(ThunkFn, MD, FnInfo);
1465 llvm::Value *This = CGF.LoadCXXThis();
1467 CGF.GetVTablePtr(This, ThunkTy->getPointerTo()->getPointerTo());
1469 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, ML.Index, "vfn");
1470 llvm::Value *Callee = CGF.Builder.CreateLoad(VFuncPtr);
1476 llvm::AttributeSet::get(CGF.getLLVMContext(), AttributeList);
1483 llvm::CallInst *Call = CGF.Builder.CreateCall(Callee, Args);
1489 CGF.Builder.CreateRetVoid();
1491 CGF.Builder.CreateRet(Call);
1495 CGF.EmitBlock(CGF.createBasicBlock());
1496 CGF.FinishFunction();
1586 llvm::Value *MicrosoftCXXABI::performThisAdjustment(CodeGenFunction &CGF,
1592 llvm::Value *V = CGF.Builder.CreateBitCast(This, CGF.Int8PtrTy);
1598 CGF.Builder.CreateConstGEP1_32(V, TA.Virtual.Microsoft.VtordispOffset);
1600 CGF.Builder.CreateBitCast(VtorDispPtr, CGF.Int32Ty->getPointerTo());
1601 llvm::Value *VtorDisp = CGF.Builder.CreateLoad(VtorDispPtr, "vtordisp");
1602 V = CGF.Builder.CreateGEP(V, CGF.Builder.CreateNeg(VtorDisp));
1612 GetVBaseOffsetFromVBPtr(CGF, V, -TA.Virtual.Microsoft.VBPtrOffset,
1614 V = CGF.Builder.CreateInBoundsGEP(VBPtr, VBaseOffset);
1622 V = CGF.Builder.CreateConstGEP1_32(V, TA.NonVirtual);
1630 MicrosoftCXXABI::performReturnAdjustment(CodeGenFunction &CGF, llvm::Value *Ret,
1635 llvm::Value *V = CGF.Builder.CreateBitCast(Ret, CGF.Int8PtrTy);
1643 GetVBaseOffsetFromVBPtr(CGF, V, RA.Virtual.Microsoft.VBPtrOffset,
1645 V = CGF.Builder.CreateInBoundsGEP(VBPtr, VBaseOffset);
1649 V = CGF.Builder.CreateConstInBoundsGEP1_32(V, RA.NonVirtual);
1652 return CGF.Builder.CreateBitCast(V, Ret->getType());
1676 llvm::Value *MicrosoftCXXABI::readArrayCookieImpl(CodeGenFunction &CGF,
1681 CGF.Builder.CreateBitCast(allocPtr, CGF.SizeTy->getPointerTo(AS));
1682 return CGF.Builder.CreateLoad(numElementsPtr);
1685 llvm::Value* MicrosoftCXXABI::InitializeArrayCookie(CodeGenFunction &CGF,
1701 = CGF.Builder.CreateBitCast(cookiePtr, CGF.SizeTy->getPointerTo(AS));
1702 CGF.Builder.CreateStore(numElements, numElementsPtr);
1706 return CGF.Builder.CreateConstInBoundsGEP1_64(newPtr,
1710 void MicrosoftCXXABI::EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D,
1717 CGF.CurFn->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage);
1718 CGF.EmitCXXGlobalVarDeclInit(D, GV, PerformInit);
1730 CGBuilderTy &Builder = CGF.Builder;
1731 llvm::IntegerType *GuardTy = CGF.Int32Ty;
1751 ErrorUnsupportedABI(CGF, "more than 32 guarded initializations");
1789 llvm::BasicBlock *InitBlock = CGF.createBasicBlock("init");
1790 llvm::BasicBlock *EndBlock = CGF.createBasicBlock("init.end");
1795 CGF.EmitBlock(InitBlock);
1797 CGF.EmitCXXGlobalVarDeclInit(D, GV, PerformInit);
1801 CGF.EmitBlock(EndBlock);
2002 MicrosoftCXXABI::EmitMemberPointerComparison(CodeGenFunction &CGF,
2007 CGBuilderTy &Builder = CGF.Builder;
2062 MicrosoftCXXABI::EmitMemberPointerIsNotNull(CodeGenFunction &CGF,
2065 CGBuilderTy &Builder = CGF.Builder;
2124 MicrosoftCXXABI::GetVBaseOffsetFromVBPtr(CodeGenFunction &CGF,
2129 CGBuilderTy &Builder = CGF.Builder;
2147 CodeGenFunction &CGF, const Expr *E, const CXXRecordDecl *RD,
2149 CGBuilderTy &Builder = CGF.Builder;
2161 VBaseAdjustBB = CGF.createBasicBlock("memptr.vadjust");
2162 SkipAdjustBB = CGF.createBasicBlock("memptr.skip_vadjust");
2167 CGF.EmitBlock(VBaseAdjustBB);
2175 DiagnosticsEngine &Diags = CGF.CGM.getDiags();
2187 GetVBaseOffsetFromVBPtr(CGF, Base, VBPtrOffset, VBTableOffset, &VBPtr);
2193 CGF.EmitBlock(SkipAdjustBB);
2203 CodeGenFunction &CGF, const Expr *E, llvm::Value *Base, llvm::Value *MemPtr,
2208 CGF.ConvertTypeForMem(MPT->getPointeeType())->getPointerTo(AS);
2209 CGBuilderTy &Builder = CGF.Builder;
2229 Base = AdjustVirtualBase(CGF, E, RD, Base, VirtualBaseAdjustmentOffset,
2251 MicrosoftCXXABI::EmitMemberPointerConversion(CodeGenFunction &CGF,
2280 CGBuilderTy &Builder = CGF.Builder;
2283 llvm::Value *IsNotNull = EmitMemberPointerIsNotNull(CGF, Src, SrcTy);
2296 llvm::BasicBlock *ConvertBB = CGF.createBasicBlock("memptr.convert");
2297 llvm::BasicBlock *ContinueBB = CGF.createBasicBlock("memptr.converted");
2299 CGF.EmitBlock(ConvertBB);
2358 CGF.EmitBlock(ContinueBB);
2438 CodeGenFunction &CGF, const Expr *E, llvm::Value *&This,
2447 CGBuilderTy &Builder = CGF.Builder;
2470 This = AdjustVirtualBase(CGF, E, RD, This, VirtualBaseAdjustmentOffset,