Lines Matching defs:CGM
54 ItaniumCXXABI(CodeGen::CodeGenModule &CGM,
57 CGCXXABI(CGM), UseARMMethodPtrABI(UseARMMethodPtrABI),
166 auto align = CGM.getContext().getTargetDefaultAlignForAttributeAligned();
167 return CGM.getContext().toCharUnitsFromBits(align);
329 CodeGenModule &CGM,
376 CGM.getItaniumVTableContext().getVTableLayout(RD);
391 CGM.getItaniumVTableContext().getVTableLayout(RD);
411 ARMCXXABI(CodeGen::CodeGenModule &CGM) :
412 ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true,
436 iOS64CXXABI(CodeGen::CodeGenModule &CGM) : ARMCXXABI(CGM) {}
444 explicit WebAssemblyCXXABI(CodeGen::CodeGenModule &CGM)
445 : ItaniumCXXABI(CGM, /*UseARMMethodPtrABI=*/true,
457 CodeGen::CGCXXABI *CodeGen::CreateItaniumCXXABI(CodeGenModule &CGM) {
458 switch (CGM.getTarget().getCXXABI().getKind()) {
464 return new ARMCXXABI(CGM);
467 return new iOS64CXXABI(CGM);
473 return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true,
477 return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true);
480 return new WebAssemblyCXXABI(CGM);
483 if (CGM.getContext().getTargetInfo().getTriple().getArch()
488 return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true,
491 return new ItaniumCXXABI(CGM);
502 return CGM.PtrDiffTy;
503 return llvm::StructType::get(CGM.PtrDiffTy, CGM.PtrDiffTy, nullptr);
537 llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(
538 CGM.getTypes().arrangeCXXMethodType(RD, FPT, /*FD=*/nullptr));
540 llvm::Constant *ptrdiff_1 = llvm::ConstantInt::get(CGM.PtrDiffTy, 1);
583 CGF.CGM.getDynamicOffsetAlignment(ThisAddr.getAlignment(), RD,
620 assert(MemPtr->getType() == CGM.PtrDiffTy);
770 return llvm::ConstantInt::get(CGM.PtrDiffTy, -1ULL, /*isSigned=*/true);
772 llvm::Constant *Zero = llvm::ConstantInt::get(CGM.PtrDiffTy, 0);
783 return llvm::ConstantInt::get(CGM.PtrDiffTy, offset.getQuantity());
796 CodeGenTypes &Types = CGM.getTypes();
801 uint64_t Index = CGM.getItaniumVTableContext().getMethodVTableIndex(MD);
815 MemPtr[0] = llvm::ConstantInt::get(CGM.PtrDiffTy, VTableOffset);
816 MemPtr[1] = llvm::ConstantInt::get(CGM.PtrDiffTy,
823 MemPtr[0] = llvm::ConstantInt::get(CGM.PtrDiffTy, VTableOffset + 1);
824 MemPtr[1] = llvm::ConstantInt::get(CGM.PtrDiffTy,
837 Ty = CGM.PtrDiffTy;
839 llvm::Constant *addr = CGM.GetAddrOfFunction(MD, Ty);
841 MemPtr[0] = llvm::ConstantExpr::getPtrToInt(addr, CGM.PtrDiffTy);
842 MemPtr[1] = llvm::ConstantInt::get(CGM.PtrDiffTy,
953 assert(MemPtr->getType() == CGM.PtrDiffTy);
988 auto Align = CGM.getContext().getTypeAlignInChars(FI.getReturnType());
1049 llvm::FunctionType::get(CGM.VoidTy, /*IsVarArgs=*/false);
1051 llvm::Constant *Fn = CGM.CreateRuntimeFunction(FTy, "__cxa_rethrow");
1059 static llvm::Constant *getAllocateExceptionFn(CodeGenModule &CGM) {
1063 llvm::FunctionType::get(CGM.Int8PtrTy, CGM.SizeTy, /*IsVarArgs=*/false);
1065 return CGM.CreateRuntimeFunction(FTy, "__cxa_allocate_exception");
1068 static llvm::Constant *getThrowFn(CodeGenModule &CGM) {
1072 llvm::Type *Args[3] = { CGM.Int8PtrTy, CGM.Int8PtrTy, CGM.Int8PtrTy };
1074 llvm::FunctionType::get(CGM.VoidTy, Args, /*IsVarArgs=*/false);
1076 return CGM.CreateRuntimeFunction(FTy, "__cxa_throw");
1085 llvm::Constant *AllocExceptionFn = getAllocateExceptionFn(CGM);
1093 llvm::Constant *TypeInfo = CGM.GetAddrOfRTTIDescriptor(ThrowType,
1103 Dtor = CGM.getAddrOfCXXStructor(DtorD, StructorType::Complete);
1104 Dtor = llvm::ConstantExpr::getBitCast(Dtor, CGM.Int8PtrTy);
1107 if (!Dtor) Dtor = llvm::Constant::getNullValue(CGM.Int8PtrTy);
1110 CGF.EmitNoreturnRuntimeCallOrInvoke(getThrowFn(CGM), args);
1133 return CGF.CGM.CreateRuntimeFunction(FTy, "__dynamic_cast", Attrs);
1139 return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_bad_cast");
1198 return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_bad_typeid");
1239 CGF.CGM.GetAddrOfRTTIDescriptor(SrcRecordTy.getUnqualifiedType());
1241 CGF.CGM.GetAddrOfRTTIDescriptor(DestRecordTy.getUnqualifiedType());
1315 llvm::Value *VTablePtr = CGF.GetVTablePtr(This, CGM.Int8PtrTy, ClassDecl);
1317 CGM.getItaniumVTableContext().getVirtualBaseOffsetOffset(ClassDecl,
1324 CGM.PtrDiffTy->getPointerTo());
1335 assert(CGM.getTarget().getCXXABI().hasConstructorVariants());
1339 CGM.EmitGlobal(GlobalDecl(D, Ctor_Base));
1345 CGM.EmitGlobal(GlobalDecl(D, Ctor_Complete));
1366 CGM.EmitGlobal(GlobalDecl(D, Dtor_Base));
1370 CGM.EmitGlobal(GlobalDecl(D, Dtor_Complete));
1376 CGM.EmitGlobal(GlobalDecl(D, Dtor_Deleting));
1449 Callee = CGM.getAddrOfCXXStructor(DD, getFromDtorType(Type));
1461 ItaniumVTableContext &VTContext = CGM.getItaniumVTableContext();
1463 llvm::GlobalVariable::LinkageTypes Linkage = CGM.getVTableLinkage(RD);
1465 CGM.GetAddrOfRTTIDescriptor(CGM.getContext().getTagDeclType(RD));
1476 if (CGM.supportsCOMDAT() && VTable->isWeakForLinker())
1477 VTable->setComdat(CGM.getModule().getOrInsertComdat(VTable->getName()));
1480 CGM.setGlobalVisibility(VTable, RD);
1485 unsigned PAlign = CGM.getTarget().getPointerAlign(0);
1499 CGM.EmitVTableBitSetEntries(VTable, VTLayout);
1527 uint64_t AddressPoint = CGM.getItaniumVTableContext()
1531 llvm::ConstantInt::get(CGM.Int64Ty, 0),
1532 llvm::ConstantInt::get(CGM.Int64Ty, AddressPoint)
1547 CGM.getVTables().getSecondaryVirtualPointerIndex(VTableClass, Base);
1572 CGM.addDeferredVTable(RD);
1578 ItaniumVTableContext &VTContext = CGM.getItaniumVTableContext();
1580 CGM.Int8PtrTy, VTContext.getVTableLayout(RD).getNumVTableComponents());
1582 VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
1608 uint64_t VTableIndex = CGM.getItaniumVTableContext().getMethodVTableIndex(GD);
1620 const CGFunctionInfo *FInfo = &CGM.getTypes().arrangeCXXStructorDeclaration(
1622 llvm::Type *Ty = CGF.CGM.getTypes().GetFunctionType(*FInfo);
1634 CodeGenVTables &VTables = CGM.getVTables();
1636 VTables.EmitVTTDefinition(VTT, CGM.getVTableLinkage(RD), RD);
1642 if (CGM.getLangOpts().AppleKext)
1734 return std::max(CharUnits::fromQuantity(CGM.SizeSizeInBytes),
1735 CGM.getContext().getTypeAlignInChars(elementType));
1767 if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0 &&
1770 CGM.getSanitizerMetadata()->disableSanitizerForInstruction(SI);
1772 llvm::FunctionType::get(CGM.VoidTy, NumElementsPtr.getType(), false);
1774 CGM.CreateRuntimeFunction(FTy, "__asan_poison_cxx_array_cookie");
1795 if (!CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) || AS != 0)
1805 CGM.CreateRuntimeFunction(FTy, "__asan_load_cxx_array_cookie");
1818 return std::max(CharUnits::fromQuantity(2 * CGM.SizeSizeInBytes),
1819 CGM.getContext().getTypeAlignInChars(elementType));
1862 static llvm::Constant *getGuardAcquireFn(CodeGenModule &CGM,
1866 llvm::FunctionType::get(CGM.getTypes().ConvertType(CGM.getContext().IntTy),
1868 return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_acquire",
1869 llvm::AttributeSet::get(CGM.getLLVMContext(),
1874 static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM,
1878 llvm::FunctionType::get(CGM.VoidTy, GuardPtrTy, /*isVarArg=*/false);
1879 return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release",
1880 llvm::AttributeSet::get(CGM.getLLVMContext(),
1885 static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM,
1889 llvm::FunctionType::get(CGM.VoidTy, GuardPtrTy, /*isVarArg=*/false);
1890 return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort",
1891 llvm::AttributeSet::get(CGM.getLLVMContext(),
1902 CGF.EmitNounwindRuntimeCall(getGuardAbortFn(CGF.CGM, Guard->getType()),
1939 CGM.getDataLayout().getABITypeAlignment(guardTy));
1946 llvm::GlobalVariable *guard = CGM.getStaticLocalDeclGuardAddress(&D);
1957 guard = new llvm::GlobalVariable(CGM.getModule(), guardTy,
1971 CGM.getTarget().getTriple().isOSBinFormatELF()) {
1974 } else if (CGM.supportsCOMDAT() && guard->isWeakForLinker()) {
1975 guard->setComdat(CGM.getModule().getOrInsertComdat(guard->getName()));
1978 CGM.setStaticLocalDeclGuardAddress(&D, guard);
2002 Builder.CreateLoad(Builder.CreateElementBitCast(guardAddr, CGM.Int8Ty));
2035 ? Builder.CreateAnd(LI, llvm::ConstantInt::get(CGM.Int8Ty, 1))
2051 = CGF.EmitNounwindRuntimeCall(getGuardAcquireFn(CGM, guardPtrTy), guard);
2072 CGF.EmitNounwindRuntimeCall(getGuardReleaseFn(CGM, guardPtrTy),
2104 llvm::Constant *atexit = CGF.CGM.CreateRuntimeFunction(atexitTy, Name);
2110 CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
2126 if (CGM.getCodeGenOpts().CXAAtExit)
2130 CGM.ErrorUnsupported(&D, "non-trivial TLS destruction");
2134 if (CGM.getLangOpts().AppleKext) {
2136 return CGM.AddCXXDtorEntry(dtor, addr);
2143 CodeGen::CodeGenModule &CGM) {
2148 CGM.getTarget().getTriple().isOSDarwin();
2155 getThreadLocalWrapperLinkage(const VarDecl *VD, CodeGen::CodeGenModule &CGM) {
2157 CGM.getLLVMLinkageVarDefinition(VD, /*isConstant=*/false);
2164 if (isThreadWrapperReplaceable(VD, CGM))
2181 if (llvm::Value *V = CGM.getModule().getNamedValue(WrapperName))
2190 llvm::Function::Create(FnTy, getThreadLocalWrapperLinkage(VD, CGM),
2191 WrapperName.str(), &CGM.getModule());
2193 if (!Wrapper->hasLocalLinkage() && !(isThreadWrapperReplaceable(VD, CGM) &&
2198 if (isThreadWrapperReplaceable(VD, CGM)) {
2206 CodeGenModule &CGM, ArrayRef<const VarDecl *> CXXThreadLocals,
2213 llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
2214 const CGFunctionInfo &FI = CGM.getTypes().arrangeNullaryFunction();
2215 InitFunc = CGM.CreateGlobalInitOrDestructFunction(FTy, "__tls_init", FI,
2219 CGM.getModule(), CGM.Int8Ty, /*isConstant=*/false,
2221 llvm::ConstantInt::get(CGM.Int8Ty, 0), "__tls_guard");
2227 CodeGenFunction(CGM)
2233 cast<llvm::GlobalVariable>(CGM.GetGlobalValue(CGM.getMangledName(VD)));
2238 if (isThreadWrapperReplaceable(VD, CGM) && !VD->hasDefinition())
2263 llvm::FunctionType *FnTy = llvm::FunctionType::get(CGM.VoidTy, false);
2266 &CGM.getModule());
2273 llvm::LLVMContext &Context = CGM.getModule().getContext();
2275 CGBuilderTy Builder(CGM, Entry);
2297 CharUnits Align = CGM.getContext().getDeclAlign(VD);
2310 llvm::Value *Val = CGF.CGM.GetAddrOfGlobalVar(VD);
2314 if (isThreadWrapperReplaceable(VD, CGF.CGM))
2349 CodeGenModule &CGM; // Per-module state.
2390 : CGM(ABI.CGM), VMContext(CGM.getModule().getContext()), CXXABI(ABI) {}
2440 CGM.getCXXABI().getMangleContext().mangleCXXRTTIName(Ty, Out);
2449 CGM.CreateOrReplaceCXXRuntimeVariable(Name, Init->getType(), Linkage);
2461 CGM.getCXXABI().getMangleContext().mangleCXXRTTI(Ty, Out);
2464 llvm::GlobalVariable *GV = CGM.getModule().getNamedGlobal(Name);
2468 GV = new llvm::GlobalVariable(CGM.getModule(), CGM.Int8PtrTy,
2479 return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
2591 static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM,
2593 ASTContext &Context = CGM.getContext();
2612 if (CGM.getVTables().isVTableExternal(RD))
2797 CGM.getModule().getOrInsertGlobal(VTableName, CGM.Int8PtrTy);
2800 CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType());
2805 llvm::ConstantExpr::getInBoundsGetElementPtr(CGM.Int8PtrTy, VTable, Two);
2806 VTable = llvm::ConstantExpr::getBitCast(VTable, CGM.Int8PtrTy);
2813 static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM,
2835 if (!CGM.getLangOpts().RTTI) {
2846 llvm::GlobalValue::LinkageTypes LT = CGM.getVTableLinkage(RD);
2864 Ty = CGM.getContext().getCanonicalType(Ty);
2869 CGM.getCXXABI().getMangleContext().mangleCXXRTTI(Ty, Out);
2871 llvm::GlobalVariable *OldGV = CGM.getModule().getNamedGlobal(Name);
2876 return llvm::ConstantExpr::getBitCast(OldGV, CGM.Int8PtrTy);
2881 if (!Force && (IsStdLib || ShouldUseExternalRTTIDescriptor(CGM, Ty)))
2889 Linkage = getTypeInfoLinkage(CGM, Ty);
2905 TypeNameField = llvm::ConstantExpr::getPtrToInt(TypeName, CGM.Int64Ty);
2907 llvm::ConstantInt::get(CGM.Int64Ty, ((uint64_t)1) << 63);
2910 llvm::ConstantExpr::getIntToPtr(TypeNameField, CGM.Int8PtrTy);
2912 TypeNameField = llvm::ConstantExpr::getBitCast(TypeName, CGM.Int8PtrTy);
3000 llvm::Module &M = CGM.getModule();
3014 if (CGM.supportsCOMDAT() && GV->isWeakForLinker())
3045 return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
3080 QualType SuperTy = CGM.getContext().getObjCInterfaceType(Super);
3164 CGM.getTypes().ConvertType(CGM.getContext().UnsignedIntTy);
3182 CGM.getTypes().ConvertType(CGM.getContext().LongTy);
3217 CGM.getItaniumVTableContext().getVirtualBaseOffsetOffset(RD, BaseDecl);
3219 const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
3241 CGM.getContext().getUnqualifiedArrayType(PointeeTy, Quals);
3255 CGM.getTypes().ConvertType(CGM.getContext().UnsignedIntTy);
3274 CGM.getContext().getUnqualifiedArrayType(PointeeTy, Quals);
3293 CGM.getTypes().ConvertType(CGM.getContext().UnsignedIntTy);
3372 static StructorCodegen getCodegenToUse(CodeGenModule &CGM,
3374 if (!CGM.getCodeGenOpts().CXXCtorDtorAliases)
3389 llvm::GlobalValue::LinkageTypes Linkage = CGM.getFunctionLinkage(AliasDecl);
3400 if (CGM.getTarget().getTriple().isOSBinFormatELF())
3408 static void emitConstructorDestructorAlias(CodeGenModule &CGM,
3411 llvm::GlobalValue::LinkageTypes Linkage = CGM.getFunctionLinkage(AliasDecl);
3413 StringRef MangledName = CGM.getMangledName(AliasDecl);
3414 llvm::GlobalValue *Entry = CGM.GetGlobalValue(MangledName);
3418 auto *Aliasee = cast<llvm::GlobalValue>(CGM.GetAddrOfGlobal(TargetDecl));
3435 CGM.setAliasAttributes(cast<NamedDecl>(AliasDecl.getDecl()), Alias);
3443 StructorCodegen CGType = getCodegenToUse(CGM, MD);
3457 emitConstructorDestructorAlias(CGM, CompleteDecl, BaseDecl);
3462 StringRef MangledName = CGM.getMangledName(CompleteDecl);
3463 auto *Aliasee = CGM.GetAddrOfGlobal(BaseDecl);
3464 CGM.addReplacement(MangledName, Aliasee);
3474 !CGM.TryEmitBaseDestructorAsAlias(DD))
3477 llvm::Function *Fn = CGM.codegenCXXStructor(MD, Type);
3486 llvm::Comdat *C = CGM.getModule().getOrInsertComdat(Out.str());
3489 CGM.maybeSetTrivialComdat(*MD, *Fn);
3493 static llvm::Constant *getBeginCatchFn(CodeGenModule &CGM) {
3496 CGM.Int8PtrTy, CGM.Int8PtrTy, /*IsVarArgs=*/false);
3498 return CGM.CreateRuntimeFunction(FTy, "__cxa_begin_catch");
3501 static llvm::Constant *getEndCatchFn(CodeGenModule &CGM) {
3504 llvm::FunctionType::get(CGM.VoidTy, /*IsVarArgs=*/false);
3506 return CGM.CreateRuntimeFunction(FTy, "__cxa_end_catch");
3509 static llvm::Constant *getGetExceptionPtrFn(CodeGenModule &CGM) {
3512 CGM.Int8PtrTy, CGM.Int8PtrTy, /*IsVarArgs=*/false);
3514 return CGM.CreateRuntimeFunction(FTy, "__cxa_get_exception_ptr");
3536 CGF.EmitNounwindRuntimeCall(getEndCatchFn(CGF.CGM));
3540 CGF.EmitRuntimeCallOrInvoke(getEndCatchFn(CGF.CGM));
3553 CGF.EmitNounwindRuntimeCall(getBeginCatchFn(CGF.CGM), Exn);
3570 CGF.CGM.getContext().getCanonicalType(CatchParam.getType());
3595 CGF.CGM.getTargetCodeGenInfo().getSizeOfUnwindException();
3688 CharUnits caughtExnAlignment = CGF.CGM.getClassPointerAlignment(catchRD);
3706 CGF.EmitNounwindRuntimeCall(getGetExceptionPtrFn(CGF.CGM), Exn);
3781 static llvm::Constant *getClangCallTerminateFn(CodeGenModule &CGM) {
3783 llvm::FunctionType::get(CGM.VoidTy, CGM.Int8PtrTy, /*IsVarArgs=*/false);
3785 CGM.CreateRuntimeFunction(fnTy, "__clang_call_terminate");
3801 if (CGM.supportsCOMDAT())
3802 fn->setComdat(CGM.getModule().getOrInsertComdat(fn->getName()));
3806 llvm::BasicBlock::Create(CGM.getLLVMContext(), "", fn);
3807 CGBuilderTy builder(CGM, entry);
3813 llvm::CallInst *catchCall = builder.CreateCall(getBeginCatchFn(CGM), exn);
3815 catchCall->setCallingConv(CGM.getRuntimeCC());
3818 llvm::CallInst *termCall = builder.CreateCall(CGM.getTerminateFn());
3821 termCall->setCallingConv(CGM.getRuntimeCC());
3835 assert(CGF.CGM.getLangOpts().CPlusPlus);
3836 return CGF.EmitNounwindRuntimeCall(getClangCallTerminateFn(CGF.CGM), Exn);
3838 return CGF.EmitNounwindRuntimeCall(CGF.CGM.getTerminateFn());