Lines Matching +full:max +full:- +full:adj
1 //===------- ItaniumCXXABI.cpp - Emit LLVM Code from ASTs for a Module ----===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 // https://itanium-cxx-abi.github.io/cxx-abi/abi.html
13 // https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
15 // It also supports the closely-related ARM ABI, documented at:
18 //===----------------------------------------------------------------------===//
47 /// VTables - All the vtables which have been defined.
75 if (!RD->canPassInRegisters()) in getRecordArgABI()
81 // The Itanium ABI has separate complete-object vs. base-object in isThisCompleteObject()
196 const CXXRecordDecl *RD = RecordTy->getAsCXXRecordDecl(); in hasUniqueVTablePointer()
198 // Under -fapple-kext, multiple definitions of the same vtable may be in hasUniqueVTablePointer()
219 if (CGM.GetLLVMVisibility(RD->getVisibility()) != in hasUniqueVTablePointer()
332 if (ForVTable && !Thunk->hasLocalLinkage()) in setThunkLinkage()
333 Thunk->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage); in setThunkLinkage()
350 return Args.size() - 1; in getSrcArgforCopyCtor()
402 /// What sort of unique-RTTI behavior should we use?
414 /// non-hidden visibility.
445 if (!Method->getCanonicalDecl()->isInlined()) in hasAnyUnusedVirtualInlineFunction()
455 if (!Entry || Entry->isDeclaration()) in hasAnyUnusedVirtualInlineFunction()
468 if (RTTIDecl->getVisibility() == Visibility::HiddenVisibility) in isVTableHidden()
472 if (Method->getVisibility() == Visibility::HiddenVisibility && in isVTableHidden()
473 !Method->isDefined()) in isVTableHidden()
508 // ARM64 libraries are prepared for non-unique RTTI.
555 // For IR-generation purposes, there's no significant difference in CreateItaniumCXXABI()
569 // include the other 32-bit ARM oddities: constructor/destructor return values in CreateItaniumCXXABI()
587 // For PNaCl, use ARM-style method pointers so that PNaCl code in CreateItaniumCXXABI()
595 llvm_unreachable("Microsoft ABI is not Itanium-based"); in CreateItaniumCXXABI()
602 if (MPT->isMemberDataPointer()) in ConvertMemberPointerType()
608 /// struct { ptrdiff_t ptr; ptrdiff_t adj; } memptr;
611 /// - method pointers are virtual if (memptr.ptr & 1) is nonzero
612 /// - the this-adjustment is (memptr.adj)
613 /// - the virtual offset is (memptr.ptr - 1)
616 /// - method pointers are virtual if (memptr.adj & 1) is nonzero
617 /// - the this-adjustment is (memptr.adj >> 1)
618 /// - the virtual offset is (memptr.ptr)
619 /// ARM uses 'adj' for the virtual flag because Thumb functions
620 /// may be only single-byte aligned.
625 /// If the member is non-virtual, memptr.ptr is the address of
634 MPT->getPointeeType()->castAs<FunctionProtoType>(); in EmitLoadOfMemberFunctionPointer()
636 cast<CXXRecordDecl>(MPT->getClass()->castAs<RecordType>()->getDecl()); in EmitLoadOfMemberFunctionPointer()
644 // Extract memptr.adj, which is in the second field. in EmitLoadOfMemberFunctionPointer()
645 llvm::Value *RawAdj = Builder.CreateExtractValue(MemFnPtr, 1, "memptr.adj"); in EmitLoadOfMemberFunctionPointer()
648 llvm::Value *Adj = RawAdj; in EmitLoadOfMemberFunctionPointer() local
650 Adj = Builder.CreateAShr(Adj, ptrdiff_1, "memptr.adj.shifted"); in EmitLoadOfMemberFunctionPointer()
655 This = Builder.CreateInBoundsGEP(Builder.getInt8Ty(), This, Adj); in EmitLoadOfMemberFunctionPointer()
673 // offset within the vtable (+1 for the virtual flag on non-ARM). in EmitLoadOfMemberFunctionPointer()
753 {VTableOffset->getType()}), in EmitLoadOfMemberFunctionPointer()
770 CheckSourceLocation = CGF.EmitCheckSourceLocation(E->getBeginLoc()); in EmitLoadOfMemberFunctionPointer()
783 llvm::MDString::get(CGM.getLLVMContext(), "all-vtables")); in EmitLoadOfMemberFunctionPointer()
797 // In the non-virtual path, the function pointer is actually a in EmitLoadOfMemberFunctionPointer()
805 CXXRecordDecl *RD = MPT->getClass()->getAsCXXRecordDecl(); in EmitLoadOfMemberFunctionPointer()
806 if (RD->hasDefinition()) { in EmitLoadOfMemberFunctionPointer()
819 MPT->getPointeeType(), in EmitLoadOfMemberFunctionPointer()
841 CalleePtr->addIncoming(VirtualFn, FnVirtual); in EmitLoadOfMemberFunctionPointer()
842 CalleePtr->addIncoming(NonVirtualFn, FnNonVirtual); in EmitLoadOfMemberFunctionPointer()
849 DiscriminatorPHI->addIncoming(llvm::ConstantInt::get(CGF.IntPtrTy, 0), in EmitLoadOfMemberFunctionPointer()
854 "Keys for virtual and non-virtual member functions must match"); in EmitLoadOfMemberFunctionPointer()
856 DiscriminatorPHI->addIncoming(NonVirtualDiscriminator, FnNonVirtual); in EmitLoadOfMemberFunctionPointer()
866 /// Compute an l-value by applying the given pointer-to-member to a
871 assert(MemPtr->getType() == CGM.PtrDiffTy); in EmitMemberDataPointerAddress()
875 // Apply the offset, which we assume is non-null. in EmitMemberDataPointerAddress()
889 assert(CPA->getKey()->getZExtValue() == CurAuthInfo.getKey() && in pointerAuthResignConstant()
890 CPA->getAddrDiscriminator()->isZeroValue() && in pointerAuthResignConstant()
891 CPA->getDiscriminator() == CurAuthInfo.getDiscriminator() && in pointerAuthResignConstant()
895 CPA->getPointer(), NewAuthInfo.getKey(), nullptr, in pointerAuthResignConstant()
899 /// Perform a bitcast, derived-to-base, or base-to-derived member pointer
902 /// Bitcast conversions are always a no-op under Itanium.
905 /// <-- offset --> <-- adjustment -->
906 /// |--------------------------|----------------------|--------------------|
920 /// This is why -1 is a reasonable choice for null data member
930 assert(E->getCastKind() == CK_DerivedToBaseMemberPointer || in EmitMemberPointerConversion()
931 E->getCastKind() == CK_BaseToDerivedMemberPointer || in EmitMemberPointerConversion()
932 E->getCastKind() == CK_ReinterpretMemberPointer); in EmitMemberPointerConversion()
935 QualType DstType = E->getType(); in EmitMemberPointerConversion()
937 if (DstType->isMemberFunctionPointerType()) { in EmitMemberPointerConversion()
940 QualType SrcType = E->getSubExpr()->getType(); in EmitMemberPointerConversion()
941 assert(SrcType->isMemberFunctionPointerType()); in EmitMemberPointerConversion()
944 llvm::Type *OrigTy = MemFnPtr->getType(); in EmitMemberPointerConversion()
952 llvm::Value *Adj = Builder.CreateExtractValue(src, 1, "memptr.adj"); in EmitMemberPointerConversion() local
954 llvm::Value *AndVal = Builder.CreateAnd(Adj, Ptrdiff_1); in EmitMemberPointerConversion()
970 llvm::PHINode *NewSrc = Builder.CreatePHI(src->getType(), 2); in EmitMemberPointerConversion()
971 NewSrc->addIncoming(src, StartBB); in EmitMemberPointerConversion()
972 NewSrc->addIncoming(ResignedVal, ResignBB); in EmitMemberPointerConversion()
978 if (E->getCastKind() == CK_ReinterpretMemberPointer) return src; in EmitMemberPointerConversion()
980 llvm::Constant *adj = getMemberPointerAdjustment(E); in EmitMemberPointerConversion() local
981 if (!adj) return src; in EmitMemberPointerConversion()
983 bool isDerivedToBase = (E->getCastKind() == CK_DerivedToBaseMemberPointer); in EmitMemberPointerConversion()
986 E->getType()->castAs<MemberPointerType>(); in EmitMemberPointerConversion()
989 // offset if the source is non-null. in EmitMemberPointerConversion()
990 if (destTy->isMemberDataPointer()) { in EmitMemberPointerConversion()
993 dst = Builder.CreateNSWSub(src, adj, "adj"); in EmitMemberPointerConversion()
995 dst = Builder.CreateNSWAdd(src, adj, "adj"); in EmitMemberPointerConversion()
998 llvm::Value *null = llvm::Constant::getAllOnesValue(src->getType()); in EmitMemberPointerConversion()
1003 // The this-adjustment is left-shifted by 1 on ARM. in EmitMemberPointerConversion()
1005 uint64_t offset = cast<llvm::ConstantInt>(adj)->getZExtValue(); in EmitMemberPointerConversion()
1007 adj = llvm::ConstantInt::get(adj->getType(), offset); in EmitMemberPointerConversion()
1010 llvm::Value *srcAdj = Builder.CreateExtractValue(src, 1, "src.adj"); in EmitMemberPointerConversion()
1013 dstAdj = Builder.CreateNSWSub(srcAdj, adj, "adj"); in EmitMemberPointerConversion()
1015 dstAdj = Builder.CreateNSWAdd(srcAdj, adj, "adj"); in EmitMemberPointerConversion()
1023 assert(DestType->isMemberFunctionPointerType() && in pointerAuthResignMemberFunctionPointer()
1024 SrcType->isMemberFunctionPointerType() && in pointerAuthResignMemberFunctionPointer()
1035 llvm::Constant *MemFnPtr = Src->getAggregateElement(0u); in pointerAuthResignMemberFunctionPointer()
1036 if (MemFnPtr->getNumOperands() == 0) { in pointerAuthResignMemberFunctionPointer()
1043 cast<llvm::User>(MemFnPtr)->getOperand(0), CurAuthInfo, NewAuthInfo, CGM); in pointerAuthResignMemberFunctionPointer()
1044 ConstPtr = llvm::ConstantExpr::getPtrToInt(ConstPtr, MemFnPtr->getType()); in pointerAuthResignMemberFunctionPointer()
1051 assert(E->getCastKind() == CK_DerivedToBaseMemberPointer || in EmitMemberPointerConversion()
1052 E->getCastKind() == CK_BaseToDerivedMemberPointer || in EmitMemberPointerConversion()
1053 E->getCastKind() == CK_ReinterpretMemberPointer); in EmitMemberPointerConversion()
1055 QualType DstType = E->getType(); in EmitMemberPointerConversion()
1057 if (DstType->isMemberFunctionPointerType()) in EmitMemberPointerConversion()
1059 src, DstType, E->getSubExpr()->getType(), CGM); in EmitMemberPointerConversion()
1062 if (E->getCastKind() == CK_ReinterpretMemberPointer) return src; in EmitMemberPointerConversion()
1065 llvm::Constant *adj = getMemberPointerAdjustment(E); in EmitMemberPointerConversion() local
1066 if (!adj) return src; in EmitMemberPointerConversion()
1068 bool isDerivedToBase = (E->getCastKind() == CK_DerivedToBaseMemberPointer); in EmitMemberPointerConversion()
1071 E->getType()->castAs<MemberPointerType>(); in EmitMemberPointerConversion()
1074 // offset if the source is non-null. in EmitMemberPointerConversion()
1075 if (destTy->isMemberDataPointer()) { in EmitMemberPointerConversion()
1077 if (src->isAllOnesValue()) return src; in EmitMemberPointerConversion()
1080 return llvm::ConstantExpr::getNSWSub(src, adj); in EmitMemberPointerConversion()
1082 return llvm::ConstantExpr::getNSWAdd(src, adj); in EmitMemberPointerConversion()
1085 // The this-adjustment is left-shifted by 1 on ARM. in EmitMemberPointerConversion()
1087 uint64_t offset = cast<llvm::ConstantInt>(adj)->getZExtValue(); in EmitMemberPointerConversion()
1089 adj = llvm::ConstantInt::get(adj->getType(), offset); in EmitMemberPointerConversion()
1092 llvm::Constant *srcAdj = src->getAggregateElement(1); in EmitMemberPointerConversion()
1095 dstAdj = llvm::ConstantExpr::getNSWSub(srcAdj, adj); in EmitMemberPointerConversion()
1097 dstAdj = llvm::ConstantExpr::getNSWAdd(srcAdj, adj); in EmitMemberPointerConversion()
1107 // A NULL pointer is represented as -1. in EmitNullMemberPointer()
1108 if (MPT->isMemberDataPointer()) in EmitNullMemberPointer()
1109 return llvm::ConstantInt::get(CGM.PtrDiffTy, -1ULL, /*isSigned=*/true); in EmitNullMemberPointer()
1132 assert(MD->isInstance() && "Member function must not be static!"); in BuildMemberPointer()
1138 if (MD->isVirtual()) { in BuildMemberPointer()
1142 // Multiply by 4-byte relative offsets. in BuildMemberPointer()
1153 // This ABI specifies that adj contains twice the this in BuildMemberPointer()
1155 // least significant bit of adj then makes exactly the same in BuildMemberPointer()
1164 // and store it as if it were a non-virtual member function. This means in BuildMemberPointer()
1167 // a best-effort attempt to re-use the thunk. in BuildMemberPointer()
1180 // Don't set the LSB of adj to 1 if pointer authentication for member in BuildMemberPointer()
1194 const FunctionProtoType *FPT = MD->getType()->castAs<FunctionProtoType>(); in BuildMemberPointer()
1201 // Use an arbitrary non-function type to tell GetAddrOfFunction that the in BuildMemberPointer()
1218 const MemberPointerType *MPT = MPType->castAs<MemberPointerType>(); in EmitMemberPointer()
1228 MD->getType(), MD->getParent()->getTypeForDecl()); in EmitMemberPointer()
1240 /// ARM is different here only because null-ness is more complicated.
1263 if (MPT->isMemberDataPointer()) in EmitMemberPointerComparison()
1268 // (L == R) <==> (L.ptr == R.ptr && (L.ptr == 0 || L.adj == R.adj)) in EmitMemberPointerComparison()
1271 // (L.adj == R.adj || in EmitMemberPointerComparison()
1272 // (L.ptr == 0 && ((L.adj|R.adj) & 1) == 0))) in EmitMemberPointerComparison()
1286 llvm::Value *Zero = llvm::Constant::getNullValue(LPtr->getType()); in EmitMemberPointerComparison()
1289 // This condition tests whether L.adj == R.adj. If this isn't in EmitMemberPointerComparison()
1291 llvm::Value *LAdj = Builder.CreateExtractValue(L, 1, "lhs.memptr.adj"); in EmitMemberPointerComparison()
1292 llvm::Value *RAdj = Builder.CreateExtractValue(R, 1, "rhs.memptr.adj"); in EmitMemberPointerComparison()
1293 llvm::Value *AdjEq = Builder.CreateICmp(Eq, LAdj, RAdj, "cmp.adj"); in EmitMemberPointerComparison()
1295 // Null member function pointers on ARM clear the low bit of Adj, in EmitMemberPointerComparison()
1298 llvm::Value *One = llvm::ConstantInt::get(LPtr->getType(), 1); in EmitMemberPointerComparison()
1300 // Compute (l.adj | r.adj) & 1 and test it against zero. in EmitMemberPointerComparison()
1301 llvm::Value *OrAdj = Builder.CreateOr(LAdj, RAdj, "or.adj"); in EmitMemberPointerComparison()
1304 "cmp.or.adj"); in EmitMemberPointerComparison()
1321 /// For member data pointers, this is just a check against -1. in EmitMemberPointerIsNotNull()
1322 if (MPT->isMemberDataPointer()) { in EmitMemberPointerIsNotNull()
1323 assert(MemPtr->getType() == CGM.PtrDiffTy); in EmitMemberPointerIsNotNull()
1325 llvm::Constant::getAllOnesValue(MemPtr->getType()); in EmitMemberPointerIsNotNull()
1332 llvm::Constant *Zero = llvm::ConstantInt::get(Ptr->getType(), 0); in EmitMemberPointerIsNotNull()
1335 // On ARM, a member function pointer is also non-null if the low bit of 'adj' in EmitMemberPointerIsNotNull()
1338 llvm::Constant *One = llvm::ConstantInt::get(Ptr->getType(), 1); in EmitMemberPointerIsNotNull()
1339 llvm::Value *Adj = Builder.CreateExtractValue(MemPtr, 1, "memptr.adj"); in EmitMemberPointerIsNotNull() local
1340 llvm::Value *VirtualBit = Builder.CreateAnd(Adj, One, "memptr.virtualbit"); in EmitMemberPointerIsNotNull()
1350 const CXXRecordDecl *RD = FI.getReturnType()->getAsCXXRecordDecl(); in classifyReturnType()
1355 if (!RD->canPassInRegisters()) { in classifyReturnType()
1363 /// The Itanium ABI requires non-zero initialization only for data
1366 return MPT->isMemberFunctionPointer(); in isZeroInitializable()
1370 /// at entry -2 in the vtable.
1376 bool UseGlobalDelete = DE->isGlobalDelete(); in emitVirtualObjectDelete()
1378 // Derive the complete-object pointer, which is what we need in emitVirtualObjectDelete()
1383 cast<CXXRecordDecl>(ElementType->castAs<RecordType>()->getDecl()); in emitVirtualObjectDelete()
1386 // Track back to entry -2 and pull out the offset there. in emitVirtualObjectDelete()
1388 CGF.IntPtrTy, VTable, -2, "complete-offset.ptr"); in emitVirtualObjectDelete()
1399 CGF.pushCallObjectDeleteCleanup(DE->getOperatorDelete(), CompletePtr, in emitVirtualObjectDelete()
1447 QualType ThrowType = E->getSubExpr()->getType(); in emitThrow()
1458 E->getSubExpr(), Address(ExceptionPtr, CGM.Int8Ty, ExnAlign)); in emitThrow()
1467 if (const RecordType *RecordTy = ThrowType->getAs<RecordType>()) { in emitThrow()
1468 CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordTy->getDecl()); in emitThrow()
1469 if (!Record->hasTrivialDestructor()) { in emitThrow()
1477 CXXDestructorDecl *DtorD = Record->getDestructor(); in emitThrow()
1530 if (!Dst->isDerivedFrom(Src, Paths)) in computeOffsetHint()
1531 return CharUnits::fromQuantity(-2ULL); in computeOffsetHint()
1538 if (Path.Access != AS_public) // Ignore non-public inheritance. in computeOffsetHint()
1545 // -1: no hint. in computeOffsetHint()
1546 if (PathElement.Base->isVirtual()) in computeOffsetHint()
1547 return CharUnits::fromQuantity(-1ULL); in computeOffsetHint()
1555 PathElement.Base->getType()->getAsCXXRecordDecl()); in computeOffsetHint()
1559 // -2: Src is not a public base of Dst. in computeOffsetHint()
1561 return CharUnits::fromQuantity(-2ULL); in computeOffsetHint()
1563 // -3: Src is a multiple public base type but never a virtual base type. in computeOffsetHint()
1565 return CharUnits::fromQuantity(-3ULL); in computeOffsetHint()
1586 Call->setDoesNotReturn(); in EmitBadTypeidCall()
1595 cast<CXXRecordDecl>(SrcRecordTy->castAs<RecordType>()->getDecl()); in EmitTypeid()
1603 {Value, llvm::ConstantInt::get(CGM.Int32Ty, -4)}); in EmitTypeid()
1607 CGF.Builder.CreateConstInBoundsGEP1_64(StdTypeInfoPtrTy, Value, -1ULL); in EmitTypeid()
1630 const CXXRecordDecl *SrcDecl = SrcRecordTy->getAsCXXRecordDecl(); in emitDynamicCastCall()
1631 const CXXRecordDecl *DestDecl = DestRecordTy->getAsCXXRecordDecl(); in emitDynamicCastCall()
1639 // We perform a no-op load of the vtable pointer here to force an in emitDynamicCastCall()
1641 // authentication this is a an actual no-op that will be elided. When in emitDynamicCastCall()
1656 if (DestTy->isReferenceType()) { in emitDynamicCastCall()
1677 const CXXRecordDecl *SrcDecl = SrcRecordTy->getAsCXXRecordDecl(); in emitExactDynamicCast()
1678 const CXXRecordDecl *DestDecl = DestRecordTy->getAsCXXRecordDecl(); in emitExactDynamicCast()
1681 (void)DestDecl->isDerivedFrom(SrcDecl, Paths); in emitExactDynamicCast()
1695 PathElement.Base->getType()->getAsCXXRecordDecl(); in emitExactDynamicCast()
1696 if (PathElement.Base->isVirtual()) { in emitExactDynamicCast()
1711 // Base appears in at least two different places. Find the most-derived in emitExactDynamicCast()
1712 // object and see if it's a DestDecl. Note that the most-derived object in emitExactDynamicCast()
1740 if (!Offset->isZero()) in emitExactDynamicCast()
1743 {llvm::ConstantInt::get(CGF.PtrDiffTy, -Offset->getQuantity())}); in emitExactDynamicCast()
1752 cast<CXXRecordDecl>(SrcRecordTy->castAs<RecordType>()->getDecl()); in emitDynamicCastToVoid()
1759 // Get the offset-to-top from the vtable. in emitDynamicCastToVoid()
1761 CGF.Builder.CreateConstInBoundsGEP1_32(CGM.Int32Ty, VTable, -2U); in emitDynamicCastToVoid()
1772 // Get the offset-to-top from the vtable. in emitDynamicCastToVoid()
1774 CGF.Builder.CreateConstInBoundsGEP1_64(PtrDiffLTy, VTable, -2ULL); in emitDynamicCastToVoid()
1786 Call->setDoesNotReturn(); in EmitBadCastCall()
1827 if (!D->getParent()->isAbstract()) { in EmitCXXConstructors()
1844 cast<CXXMethodDecl>(GD.getDecl())->getParent()->getNumVBases() != 0) { in buildStructorSignature()
1859 // The destructor used for destructing this as a most-derived class; in EmitCXXDestructors()
1866 if (D->isVirtual()) in EmitCXXDestructors()
1885 Context, /*DC=*/nullptr, MD->getLocation(), &Context.Idents.get("vtt"), in addImplicitStructorParams()
1894 if (CGF.CurFuncDecl && CGF.CurFuncDecl->hasAttr<NakedAttr>()) in EmitInstanceFunctionProlog()
1955 Type != Dtor_Base && DD->isVirtual()) in EmitDestructorCall()
1956 Callee = CGF.BuildAppleKextVirtualDestructorCall(DD, Type, DD->getParent()); in EmitDestructorCall()
1964 // Check if any non-inline method has the specified attribute.
1967 for (const auto *D : RD->noload_decls()) { in CXXRecordNonInlineHasAttr()
1969 if (FD->isInlined() || FD->doesThisDeclarationHaveABody() || in CXXRecordNonInlineHasAttr()
1970 FD->isPureVirtual()) in CXXRecordNonInlineHasAttr()
1972 if (D->hasAttr<T>()) in CXXRecordNonInlineHasAttr()
1983 if (VTable->getDLLStorageClass() != in setVTableSelectiveDLLImportExport()
1985 RD->hasAttr<DLLImportAttr>() || RD->hasAttr<DLLExportAttr>()) in setVTableSelectiveDLLImportExport()
1990 VTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); in setVTableSelectiveDLLImportExport()
1992 VTable->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); in setVTableSelectiveDLLImportExport()
1998 if (VTable->hasInitializer()) in emitVTableDefinitions()
2015 VTable->setLinkage(Linkage); in emitVTableDefinitions()
2017 if (CGM.supportsCOMDAT() && VTable->isWeakForLinker()) in emitVTableDefinitions()
2018 VTable->setComdat(CGM.getModule().getOrInsertComdat(VTable->getName())); in emitVTableDefinitions()
2029 const DeclContext *DC = RD->getDeclContext(); in emitVTableDefinitions()
2030 if (RD->getIdentifier() && in emitVTableDefinitions()
2031 RD->getIdentifier()->isStr("__fundamental_type_info") && in emitVTableDefinitions()
2032 isa<NamespaceDecl>(DC) && cast<NamespaceDecl>(DC)->getIdentifier() && in emitVTableDefinitions()
2033 cast<NamespaceDecl>(DC)->getIdentifier()->isStr("__cxxabiv1") && in emitVTableDefinitions()
2034 DC->getParent()->isTranslationUnit()) in emitVTableDefinitions()
2037 // Always emit type metadata on non-available_externally definitions, and on in emitVTableDefinitions()
2042 if (!VTable->isDeclarationForLinker() || in emitVTableDefinitions()
2048 if (VTable->isDeclarationForLinker()) { in emitVTableDefinitions()
2056 if (!VTable->isDSOLocal()) in emitVTableDefinitions()
2057 CGVT.GenerateRelativeVTableAlias(VTable, VTable->getName()); in emitVTableDefinitions()
2072 if ((Base.getBase()->getNumVBases() || NearestVBase != nullptr) && in getVTableAddressPointInStructor()
2104 llvm::ConstantRange InRange(llvm::APInt(32, -Offset, true), in getVTableAddressPoint()
2105 llvm::APInt(32, VTableSize - Offset, true)); in getVTableAddressPoint()
2107 VTable->getValueType(), VTable, Indices, /*InBounds=*/true, InRange); in getVTableAddressPoint()
2113 assert((Base.getBase()->getNumVBases() || NearestVBase != nullptr) && in getVTableAddressPointInStructorWithVTT()
2171 VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); in getAddrOfVTable()
2187 llvm::Value *VTable = CGF.GetVTablePtr(This, PtrTy, MethodDecl->getParent()); in getVirtualFunctionPointer()
2192 if (!Schema && CGF.ShouldEmitVTableTypeCheckedLoad(MethodDecl->getParent())) { in getVirtualFunctionPointer()
2194 MethodDecl->getParent(), VTable, PtrTy, in getVirtualFunctionPointer()
2199 CGF.EmitTypeMetadataCodeForVCall(MethodDecl->getParent(), VTable, Loc); in getVirtualFunctionPointer()
2215 // It's safe to add it without -fstrict-vtable-pointers, but it would not in getVirtualFunctionPointer()
2218 // happen without enabled devirtualization with -fstrict-vtable-pointers. in getVirtualFunctionPointer()
2222 VFuncLoadInstr->setMetadata( in getVirtualFunctionPointer()
2247 assert(CE == nullptr || CE->arg_begin() == CE->arg_end()); in EmitVirtualDestructorCall()
2258 ThisTy = CE->getObjectType(); in EmitVirtualDestructorCall()
2260 ThisTy = D->getDestroyedType(); in EmitVirtualDestructorCall()
2276 // We don't emit available_externally vtables if we are in -fapple-kext mode in canSpeculativelyEmitVTableAsBaseClass()
2299 // need to be able to emit non-virtual base vtables. in canSpeculativelyEmitVTableAsBaseClass()
2300 if (RD->getNumVBases()) { in canSpeculativelyEmitVTableAsBaseClass()
2301 for (const auto &B : RD->bases()) { in canSpeculativelyEmitVTableAsBaseClass()
2302 auto *BRD = B.getType()->getAsCXXRecordDecl(); in canSpeculativelyEmitVTableAsBaseClass()
2304 if (B.isVirtual() || !BRD->isDynamicClass()) in canSpeculativelyEmitVTableAsBaseClass()
2318 if (RD->shouldEmitInExternalSource()) in canSpeculativelyEmitVTable()
2321 // For a complete-object vtable (or more specifically, for the VTT), we need in canSpeculativelyEmitVTable()
2323 for (const auto &B : RD->vbases()) { in canSpeculativelyEmitVTable()
2324 auto *BRD = B.getType()->getAsCXXRecordDecl(); in canSpeculativelyEmitVTable()
2326 if (!BRD->isDynamicClass()) in canSpeculativelyEmitVTable()
2345 // In a base-to-derived cast, the non-virtual adjustment is applied first. in performTypeAdjustment()
2361 // Load the adjustment offset from the vtable as a 32-bit int. in performTypeAdjustment()
2380 // In a derived-to-base conversion, the non-virtual adjustment is in performTypeAdjustment()
2423 // The cookie is actually right-justified in that space. in getArrayCookieSizeImpl()
2424 return std::max(CharUnits::fromQuantity(CGM.SizeSizeInBytes), in getArrayCookieSizeImpl()
2442 std::max(SizeSize, Ctx.getPreferredTypeAlignInChars(ElementType)); in InitializeArrayCookie()
2447 CharUnits CookieOffset = CookieSize - SizeSize; in InitializeArrayCookie()
2457 (expr->getOperatorNew()->isReplaceableGlobalAllocationFunction() || in InitializeArrayCookie()
2460 SI->setNoSanitizeMetadata(); in InitializeArrayCookie()
2476 // The element size is right-justified in the cookie. in readArrayCookieImpl()
2478 CharUnits numElementsOffset = cookieSize - CGF.getSizeSize(); in readArrayCookieImpl()
2488 // run-time deal with it: if the shadow is properly poisoned return the in readArrayCookieImpl()
2506 // 8, so we can dismiss this as typical ABI-author blindness to in getArrayCookieSizeImpl()
2508 return std::max(CharUnits::fromQuantity(2 * CGM.SizeSizeInBytes), in getArrayCookieSizeImpl()
2595 CGF.EmitNounwindRuntimeCall(getGuardAbortFn(CGF.CGM, Guard->getType()), in Emit()
2602 /// just special-case it at particular places.
2610 // partially-ordered initialization within their translation unit. in EmitGuardedInit()
2615 // We only need to use thread-safe statics for local non-TLS variables and in EmitGuardedInit()
2616 // inline variables; other global initialization is always single-threaded in EmitGuardedInit()
2622 // If we have a global variable with internal linkage and thread-safe statics in EmitGuardedInit()
2624 bool useInt8GuardVariable = !threadsafe && var->hasInternalLinkage(); in EmitGuardedInit()
2633 // (i.e. 32-bit on AArch32, 64-bit on AArch64). in EmitGuardedInit()
2648 // might if we're double-emitting this function body). in EmitGuardedInit()
2658 // Create the guard variable with a zero-initializer. in EmitGuardedInit()
2662 false, var->getLinkage(), in EmitGuardedInit()
2665 guard->setDSOLocal(var->isDSOLocal()); in EmitGuardedInit()
2666 guard->setVisibility(var->getVisibility()); in EmitGuardedInit()
2667 guard->setDLLStorageClass(var->getDLLStorageClass()); in EmitGuardedInit()
2668 // If the variable is thread-local, so is its guard variable. in EmitGuardedInit()
2669 guard->setThreadLocalMode(var->getThreadLocalMode()); in EmitGuardedInit()
2670 guard->setAlignment(guardAlignment.getAsAlign()); in EmitGuardedInit()
2674 // non-ELF and non-Wasm object formats, so only do it for ELF and Wasm. in EmitGuardedInit()
2675 llvm::Comdat *C = var->getComdat(); in EmitGuardedInit()
2679 guard->setComdat(C); in EmitGuardedInit()
2680 } else if (CGM.supportsCOMDAT() && guard->isWeakForLinker()) { in EmitGuardedInit()
2681 guard->setComdat(CGM.getModule().getOrInsertComdat(guard->getName())); in EmitGuardedInit()
2687 Address guardAddr = Address(guard, guard->getValueType(), guardAlignment); in EmitGuardedInit()
2692 // The following is pseudo-code showing how these functions can be used: in EmitGuardedInit()
2718 // An implementation supporting thread-safety on multiprocessor in EmitGuardedInit()
2724 LI->setAtomic(llvm::AtomicOrdering::Acquire); in EmitGuardedInit()
2732 // guard variable to be a 4-byte aligned, 4-byte word with the in EmitGuardedInit()
2762 // storage duration depends on whether they are declared at block-scope. The in EmitGuardedInit()
2763 // initialization of such variables at block-scope can be aborted with an in EmitGuardedInit()
2766 // [stmt.dcl]p4). For such variables declared at non-block scope, exceptions in EmitGuardedInit()
2770 // long as they avoid touching memory. As a result, block-scope variables must in EmitGuardedInit()
2772 // the mark is reverted following an exception), but non-block-scope variables in EmitGuardedInit()
2776 // Variables used when coping with thread-safe statics and exceptions. in EmitGuardedInit()
2792 // For non-local variables, store 1 into the first byte of the guard in EmitGuardedInit()
2803 // Pop the guard-abort cleanup if we pushed one. in EmitGuardedInit()
2839 auto AddrAS = addr ? addr->getType()->getPointerAddressSpace() : 0; in emitGlobalDtorWithCXAAtExit()
2846 auto *GV = cast<llvm::GlobalValue>(handle->stripPointerCasts()); in emitGlobalDtorWithCXAAtExit()
2847 GV->setVisibility(llvm::GlobalValue::HiddenVisibility); in emitGlobalDtorWithCXAAtExit()
2850 llvm::Type *paramTys[] = {dtorTy, AddrPtrTy, handle->getType()}; in emitGlobalDtorWithCXAAtExit()
2857 fn->setDoesNotThrow(); in emitGlobalDtorWithCXAAtExit()
2907 // Destructor functions are run/unregistered in non-ascending in unregisterGlobalDtorsWithUnAtExit()
2933 CI->setCallingConv(Dtor->getCallingConv()); in unregisterGlobalDtorsWithUnAtExit()
2959 // Since constructor functions are run in non-descending order of their in registerGlobalDtorsWithAtExit()
2960 // priorities, destructors are registered in non-descending order of their in registerGlobalDtorsWithAtExit()
2962 // of their registration, destructor functions are run in non-ascending in registerGlobalDtorsWithAtExit()
2995 // not strictly 1-to-1 with using `atexit` because we no longer tear down in registerGlobalDtor()
3001 // or __cxa_atexit depending on whether this VarDecl is a thread-local storage in registerGlobalDtor()
3019 assert(!VD->isStaticLocal() && "static local VarDecls don't need wrappers!"); in isThreadWrapperReplaceable()
3022 return VD->getTLSKind() == VarDecl::TLS_Dynamic && in isThreadWrapperReplaceable()
3061 QualType RetQT = VD->getType(); in getOrCreateThreadLocalWrapper()
3062 if (RetQT->isReferenceType()) in getOrCreateThreadLocalWrapper()
3073 if (CGM.supportsCOMDAT() && Wrapper->isWeakForLinker()) in getOrCreateThreadLocalWrapper()
3074 Wrapper->setComdat(CGM.getModule().getOrInsertComdat(Wrapper->getName())); in getOrCreateThreadLocalWrapper()
3079 if (!Wrapper->hasLocalLinkage()) in getOrCreateThreadLocalWrapper()
3081 llvm::GlobalVariable::isLinkOnceLinkage(Wrapper->getLinkage()) || in getOrCreateThreadLocalWrapper()
3082 llvm::GlobalVariable::isWeakODRLinkage(Wrapper->getLinkage()) || in getOrCreateThreadLocalWrapper()
3083 VD->getVisibility() == HiddenVisibility) in getOrCreateThreadLocalWrapper()
3084 Wrapper->setVisibility(llvm::GlobalValue::HiddenVisibility); in getOrCreateThreadLocalWrapper()
3087 Wrapper->setCallingConv(llvm::CallingConv::CXX_FAST_TLS); in getOrCreateThreadLocalWrapper()
3088 Wrapper->addFnAttr(llvm::Attribute::NoUnwind); in getOrCreateThreadLocalWrapper()
3101 // Separate initializers into those with ordered (or partially-ordered) in EmitThreadLocalInitFuncs()
3107 CXXThreadLocalInitVars[I]->getTemplateSpecializationKind())) in EmitThreadLocalInitFuncs()
3108 UnorderedInits[CXXThreadLocalInitVars[I]->getCanonicalDecl()] = in EmitThreadLocalInitFuncs()
3126 Guard->setThreadLocal(true); in EmitThreadLocalInitFuncs()
3127 Guard->setThreadLocalMode(CGM.GetDefaultLLVMTLSModel()); in EmitThreadLocalInitFuncs()
3130 Guard->setAlignment(GuardAlign.getAsAlign()); in EmitThreadLocalInitFuncs()
3136 InitFunc->setCallingConv(llvm::CallingConv::CXX_FAST_TLS); in EmitThreadLocalInitFuncs()
3137 InitFunc->addFnAttr(llvm::Attribute::NoUnwind); in EmitThreadLocalInitFuncs()
3141 // Create declarations for thread wrappers for all thread-local variables in EmitThreadLocalInitFuncs()
3142 // with non-discardable definitions in this translation unit. in EmitThreadLocalInitFuncs()
3144 if (VD->hasDefinition() && in EmitThreadLocalInitFuncs()
3161 if (!VD->hasDefinition()) { in EmitThreadLocalInitFuncs()
3163 Wrapper->setLinkage(llvm::Function::ExternalLinkage); in EmitThreadLocalInitFuncs()
3169 if (Wrapper->getLinkage() == llvm::Function::WeakODRLinkage) in EmitThreadLocalInitFuncs()
3170 Wrapper->setLinkage(llvm::Function::LinkOnceODRLinkage); in EmitThreadLocalInitFuncs()
3192 } else if (VD->hasDefinition()) { in EmitThreadLocalInitFuncs()
3195 if (isTemplateInstantiation(VD->getTemplateSpecializationKind())) in EmitThreadLocalInitFuncs()
3196 InitFuncToUse = UnorderedInits.lookup(VD->getCanonicalDecl()); in EmitThreadLocalInitFuncs()
3198 Init = llvm::GlobalAlias::create(Var->getLinkage(), InitFnName.str(), in EmitThreadLocalInitFuncs()
3214 Init->setVisibility(Var->getVisibility()); in EmitThreadLocalInitFuncs()
3216 if (!CGM.getTriple().isOSWindows() || !Init->hasExternalWeakLinkage()) in EmitThreadLocalInitFuncs()
3217 Init->setDSOLocal(Var->isDSOLocal()); in EmitThreadLocalInitFuncs()
3227 if (CGM.getTriple().isOSAIX() && VD->hasDefinition() && in EmitThreadLocalInitFuncs()
3230 // Init should be null. If it were non-null, then the logic above would in EmitThreadLocalInitFuncs()
3237 InitFnTy, Var->getLinkage(), InitFnName.str(), &CGM.getModule()); in EmitThreadLocalInitFuncs()
3256 CallVal->setCallingConv(llvm::CallingConv::CXX_FAST_TLS); in EmitThreadLocalInitFuncs()
3258 cast<llvm::Function>(cast<llvm::GlobalAlias>(Init)->getAliasee()); in EmitThreadLocalInitFuncs()
3259 Fn->setCallingConv(llvm::CallingConv::CXX_FAST_TLS); in EmitThreadLocalInitFuncs()
3264 // (possibly multi-dimensional) array of class type, thread_local vars in EmitThreadLocalInitFuncs()
3266 // const-initialized. Since the routine is guaranteed to exist, we can in EmitThreadLocalInitFuncs()
3289 if (VD->getType()->isReferenceType()) { in EmitThreadLocalInitFuncs()
3291 Val = Builder.CreateAlignedLoad(Var->getValueType(), Val, Align); in EmitThreadLocalInitFuncs()
3305 CallVal->setCallingConv(Wrapper->getCallingConv()); in EmitThreadLocalVarDeclLValue()
3308 if (VD->getType()->isReferenceType()) in EmitThreadLocalVarDeclLValue()
3323 if (!MD->getParent()->getNumVBases()) in NeedsVTTParameter()
3352 MD->isExternallyVisible() ? llvm::GlobalValue::LinkOnceODRLinkage in getOrCreateVirtualFunctionPointerThunk()
3357 ThunkFn->setVisibility(llvm::GlobalValue::HiddenVisibility); in getOrCreateVirtualFunctionPointerThunk()
3358 assert(ThunkFn->getName() == ThunkName && "name was uniqued!"); in getOrCreateVirtualFunctionPointerThunk()
3364 ThunkFn->removeFnAttr(llvm::Attribute::StackProtect); in getOrCreateVirtualFunctionPointerThunk()
3365 ThunkFn->removeFnAttr(llvm::Attribute::StackProtectStrong); in getOrCreateVirtualFunctionPointerThunk()
3366 ThunkFn->removeFnAttr(llvm::Attribute::StackProtectReq); in getOrCreateVirtualFunctionPointerThunk()
3378 FunctionArgs, MD->getLocation(), SourceLocation()); in getOrCreateVirtualFunctionPointerThunk()
3386 const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>(); in getOrCreateVirtualFunctionPointerThunk()
3396 Call->setTailCallKind(llvm::CallInst::TCK_MustTail); in getOrCreateVirtualFunctionPointerThunk()
3397 if (Call->getType()->isVoidTy()) in getOrCreateVirtualFunctionPointerThunk()
3411 CodeGenModule &CGM; // Per-module state.
3413 const ItaniumCXXABI &CXXABI; // Per-module state.
3415 /// Fields - The fields of the RTTI descriptor currently being built.
3418 /// GetAddrOfTypeName - Returns the mangled type name of the given type.
3422 /// GetAddrOfExternalRTTIDescriptor - Returns the constant for the RTTI
3426 /// BuildVTablePointer - Build the vtable pointer for the given type.
3429 /// BuildSIClassTypeInfo - Build an abi::__si_class_type_info, used for single
3433 /// BuildVMIClassTypeInfo - Build an abi::__vmi_class_type_info, used for
3438 /// BuildPointerTypeInfo - Build an abi::__pointer_type_info struct, used
3442 /// BuildObjCObjectTypeInfo - Build the appropriate kind of
3446 /// BuildPointerToMemberTypeInfo - Build an abi::__pointer_to_member_type_info
3456 /// PTI_Const - Type has const qualifier.
3459 /// PTI_Volatile - Type has volatile qualifier.
3462 /// PTI_Restrict - Type has restrict qualifier.
3465 /// PTI_Incomplete - Type is incomplete.
3468 /// PTI_ContainingClassIncomplete - Containing class is incomplete.
3472 /// PTI_TransactionSafe - Pointee is transaction_safe function (C++ TM TS).
3475 /// PTI_Noexcept - Pointee is noexcept function (C++1z).
3481 /// VMI_NonDiamondRepeat - Class has non-diamond repeated inheritance.
3484 /// VMI_DiamondShaped - Class is diamond shaped.
3490 /// BCTI_Virtual - Base class is virtual.
3493 /// BCTI_Public - Base class is public.
3497 /// BuildTypeInfo - Build the RTTI type info struct for the given type, or
3501 /// BuildTypeInfo - Build the RTTI type info struct for the given type.
3524 Name, Init->getType(), Linkage, Align.getAsAlign()); in GetAddrOfTypeName()
3526 GV->setInitializer(Init); in GetAddrOfTypeName()
3549 const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); in GetAddrOfExternalRTTIDescriptor()
3551 // Import the typeinfo symbol when all non-inline virtual methods are in GetAddrOfExternalRTTIDescriptor()
3555 GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass); in GetAddrOfExternalRTTIDescriptor()
3564 /// TypeInfoIsInStandardLibrary - Given a builtin type, returns whether the type
3569 // the run-time support library. Specifically, the run-time support in TypeInfoIsInStandardLibrary()
3575 // half-precision floating point types. in TypeInfoIsInStandardLibrary()
3581 switch (Ty->getKind()) { in TypeInfoIsInStandardLibrary()
3673 llvm_unreachable("FIXME: Objective-C types are unsupported!"); in TypeInfoIsInStandardLibrary()
3680 QualType PointeeTy = PointerTy->getPointeeType(); in TypeInfoIsInStandardLibrary()
3695 /// IsStandardLibraryRTTIDescriptor - Returns whether the type
3710 /// ShouldUseExternalRTTIDescriptor - Returns whether the type information for
3713 /// standard-library type.
3723 const CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl()); in ShouldUseExternalRTTIDescriptor()
3724 if (!RD->hasDefinition()) in ShouldUseExternalRTTIDescriptor()
3727 if (!RD->isDynamicClass()) in ShouldUseExternalRTTIDescriptor()
3734 bool IsDLLImport = RD->hasAttr<DLLImportAttr>(); in ShouldUseExternalRTTIDescriptor()
3755 /// IsIncompleteClassType - Returns whether the given record type is incomplete.
3757 return !RecordTy->getDecl()->isCompleteDefinition(); in IsIncompleteClassType()
3760 /// ContainsIncompleteClassType - Returns whether the given type contains an
3778 return ContainsIncompleteClassType(PointerTy->getPointeeType()); in ContainsIncompleteClassType()
3783 const RecordType *ClassType = cast<RecordType>(MemberPointerTy->getClass()); in ContainsIncompleteClassType()
3787 return ContainsIncompleteClassType(MemberPointerTy->getPointeeType()); in ContainsIncompleteClassType()
3793 // CanUseSingleInheritance - Return whether the given record decl has a "single,
3794 // public, non-virtual base at offset zero (i.e. the derived class is dynamic
3798 if (RD->getNumBases() != 1) in CanUseSingleInheritance()
3802 CXXRecordDecl::base_class_const_iterator Base = RD->bases_begin(); in CanUseSingleInheritance()
3805 if (Base->isVirtual()) in CanUseSingleInheritance()
3809 if (Base->getAccessSpecifier() != AS_public) in CanUseSingleInheritance()
3814 cast<CXXRecordDecl>(Base->getType()->castAs<RecordType>()->getDecl()); in CanUseSingleInheritance()
3815 if (!BaseDecl->isEmpty() && in CanUseSingleInheritance()
3816 BaseDecl->isDynamicClass() != RD->isDynamicClass()) in CanUseSingleInheritance()
3835 switch (Ty->getTypeClass()) { in BuildVTablePointer()
3842 llvm_unreachable("Non-canonical and dependent types shouldn't get here"); in BuildVTablePointer()
3892 cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl()); in BuildVTablePointer()
3894 if (!RD->hasDefinition() || !RD->getNumBases()) { in BuildVTablePointer()
3907 Ty = cast<ObjCObjectType>(Ty)->getBaseType().getTypePtr(); in BuildVTablePointer()
3919 if (cast<ObjCInterfaceType>(Ty)->getDecl()->getSuperClass()) { in BuildVTablePointer()
3948 CGM.setDSOLocal(cast<llvm::GlobalValue>(VTable->stripPointerCasts())); in BuildVTablePointer()
3989 switch (Ty->getLinkage()) { in getTypeInfoLinkage()
4007 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl()); in getTypeInfoLinkage()
4008 if (RD->hasAttr<WeakAttr>()) in getTypeInfoLinkage()
4011 if (RD->hasAttr<DLLImportAttr>() && in getTypeInfoLinkage()
4015 if (RD->isDynamicClass() && in getTypeInfoLinkage()
4039 if (OldGV && !OldGV->isDeclaration()) { in BuildTypeInfo()
4040 assert(!OldGV->hasAvailableExternallyLinkage() && in BuildTypeInfo()
4064 llvmVisibility = CodeGenModule::GetLLVMVisibility(Ty->getVisibility()); in BuildTypeInfo()
4068 if (auto RD = Ty->getAsCXXRecordDecl()) { in BuildTypeInfo()
4070 RD->hasAttr<DLLExportAttr>()) || in BuildTypeInfo()
4097 // for global pointers. This is very ARM64-specific. in BuildTypeInfo()
4109 switch (Ty->getTypeClass()) { in BuildTypeInfo()
4116 llvm_unreachable("Non-canonical and dependent types shouldn't get here"); in BuildTypeInfo()
4164 cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl()); in BuildTypeInfo()
4165 if (!RD->hasDefinition() || !RD->getNumBases()) { in BuildTypeInfo()
4184 BuildPointerTypeInfo(cast<ObjCObjectPointerType>(Ty)->getPointeeType()); in BuildTypeInfo()
4188 BuildPointerTypeInfo(cast<PointerType>(Ty)->getPointeeType()); in BuildTypeInfo()
4208 new llvm::GlobalVariable(M, Init->getType(), in BuildTypeInfo()
4216 const CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl()); in BuildTypeInfo()
4217 if (RD->hasAttr<DLLExportAttr>() || in BuildTypeInfo()
4225 GV->takeName(OldGV); in BuildTypeInfo()
4226 OldGV->replaceAllUsesWith(GV); in BuildTypeInfo()
4227 OldGV->eraseFromParent(); in BuildTypeInfo()
4230 if (CGM.supportsCOMDAT() && GV->isWeakForLinker()) in BuildTypeInfo()
4231 GV->setComdat(M.getOrInsertComdat(GV->getName())); in BuildTypeInfo()
4235 GV->setAlignment(Align.getAsAlign()); in BuildTypeInfo()
4243 // of the object addresses. However, the language's built-in uses in BuildTypeInfo()
4252 TypeName->setVisibility(Visibility); in BuildTypeInfo()
4255 GV->setVisibility(Visibility); in BuildTypeInfo()
4258 TypeName->setDLLStorageClass(DLLStorageClass); in BuildTypeInfo()
4259 GV->setDLLStorageClass(GVDLLStorageClass); in BuildTypeInfo()
4261 TypeName->setPartition(CGM.getCodeGenOpts().SymbolPartition); in BuildTypeInfo()
4262 GV->setPartition(CGM.getCodeGenOpts().SymbolPartition); in BuildTypeInfo()
4267 /// BuildObjCObjectTypeInfo - Build the appropriate kind of type_info
4268 /// for the given Objective-C object type.
4271 const Type *T = OT->getBaseType().getTypePtr(); in BuildObjCObjectTypeInfo()
4278 ObjCInterfaceDecl *Class = cast<ObjCInterfaceType>(T)->getDecl(); in BuildObjCObjectTypeInfo()
4279 ObjCInterfaceDecl *Super = Class->getSuperClass(); in BuildObjCObjectTypeInfo()
4292 /// BuildSIClassTypeInfo - Build an abi::__si_class_type_info, used for single
4299 ItaniumRTTIBuilder(CXXABI).BuildTypeInfo(RD->bases_begin()->getType()); in BuildSIClassTypeInfo()
4304 /// SeenBases - Contains virtual and non-virtual bases seen when traversing
4312 /// ComputeVMIClassTypeInfoFlags - Compute the value of the flags member in
4321 cast<CXXRecordDecl>(Base->getType()->castAs<RecordType>()->getDecl()); in ComputeVMIClassTypeInfoFlags()
4323 if (Base->isVirtual()) { in ComputeVMIClassTypeInfoFlags()
4334 // Mark the non-virtual base as seen. in ComputeVMIClassTypeInfoFlags()
4336 // If this non-virtual base has been seen before, then the class has non- in ComputeVMIClassTypeInfoFlags()
4346 for (const auto &I : BaseDecl->bases()) in ComputeVMIClassTypeInfoFlags()
4357 for (const auto &I : RD->bases()) in ComputeVMIClassTypeInfoFlags()
4363 /// BuildVMIClassTypeInfo - Build an abi::__vmi_class_type_info, used for
4380 Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, RD->getNumBases())); in BuildVMIClassTypeInfo()
4382 if (!RD->getNumBases()) in BuildVMIClassTypeInfo()
4388 // __base_info[] is an array of base class descriptions -- one for every in BuildVMIClassTypeInfo()
4416 for (const auto &Base : RD->bases()) { in BuildVMIClassTypeInfo()
4421 cast<CXXRecordDecl>(Base.getType()->castAs<RecordType>()->getDecl()); in BuildVMIClassTypeInfo()
4426 // For a non-virtual base, this is the offset in the object of the base in BuildVMIClassTypeInfo()
4440 // The low-order byte of __offset_flags contains flags, as given by the in BuildVMIClassTypeInfo()
4470 if (auto *Proto = Type->getAs<FunctionProtoType>()) { in extractPBaseFlags()
4471 if (Proto->isNothrow()) { in extractPBaseFlags()
4480 /// BuildPointerTypeInfo - Build an abi::__pointer_type_info struct,
4484 // __flags is a flag word describing the cv-qualification and other in BuildPointerTypeInfo()
4500 /// BuildPointerToMemberTypeInfo - Build an abi::__pointer_to_member_type_info
4504 QualType PointeeTy = Ty->getPointeeType(); in BuildPointerToMemberTypeInfo()
4507 // __flags is a flag word describing the cv-qualification and other in BuildPointerToMemberTypeInfo()
4511 const RecordType *ClassType = cast<RecordType>(Ty->getClass()); in BuildPointerToMemberTypeInfo()
4556 RD->hasAttr<DLLExportAttr>() || CGM.shouldMapVisibilityToDLLExport(RD) in EmitFundamentalRTTIDescriptors()
4560 CodeGenModule::GetLLVMVisibility(RD->getVisibility()); in EmitFundamentalRTTIDescriptors()
4585 if (CanTy->getVisibility() != DefaultVisibility) in classifyRTTIUniqueness()
4594 // enable string-comparisons. in classifyRTTIUniqueness()
4610 if (MD->getParent()->getNumVBases()) in getCodegenToUse()
4647 if (Entry && !Entry->isDeclaration()) in emitConstructorDestructorAlias()
4656 Alias->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); in emitConstructorDestructorAlias()
4660 assert(Entry->getType() == Aliasee->getType() && in emitConstructorDestructorAlias()
4662 Alias->takeName(Entry); in emitConstructorDestructorAlias()
4663 Entry->replaceAllUsesWith(Alias); in emitConstructorDestructorAlias()
4664 Entry->eraseFromParent(); in emitConstructorDestructorAlias()
4666 Alias->setName(MangledName); in emitConstructorDestructorAlias()
4702 // base class if there is exactly one non-virtual base class with a in emitCXXStructor()
4703 // non-trivial destructor, there are no fields with a non-trivial in emitCXXStructor()
4732 Fn->setComdat(C); in emitCXXStructor()
4766 /// - Catch-alls tell us nothing, so we have to conservatively
4768 /// - Catches by reference behave according to their base types.
4769 /// - Catches of non-record types will only trigger for exceptions
4770 /// of non-record types, which never have destructors.
4771 /// - Catches of record types can trigger for arbitrary subclasses
4791 /// __cxa_end_catch. If -fassume-nothrow-exception-dtor is specified, we assume
4795 /// \param EndMightThrow - true if __cxa_end_catch might throw
4825 QualType CaughtType = cast<ReferenceType>(CatchType)->getPointeeType(); in InitCatchParam()
4826 bool EndCatchMightThrow = CaughtType->isRecordType(); in InitCatchParam()
4835 QualType PointeeType = PT->getPointeeType(); in InitCatchParam()
4838 // this by-value pointer and use the exception object instead. in InitCatchParam()
4839 if (!PointeeType->isRecordType()) { in InitCatchParam()
4848 // However, if we're catching a pointer-to-record type that won't in InitCatchParam()
4852 // might have the wrong adjustment, but we can't use the by-value in InitCatchParam()
4858 // The better solution would be to filter out non-exact matches in InitCatchParam()
4890 if (CatchType->hasPointerRepresentation()) { in InitCatchParam()
4933 auto catchRD = CatchType->getAsCXXRecordDecl(); in InitCatchParam()
4995 // the exception-declaration in the handler. in emitBeginCatch()
5005 // - ExitCXXTryStmt opens a RunCleanupsScope in emitBeginCatch()
5006 // - EmitAutoVarAlloca creates the variable and debug info in emitBeginCatch()
5007 // - InitCatchParam initializes the variable from the exception in emitBeginCatch()
5008 // - CallBeginCatch calls __cxa_begin_catch in emitBeginCatch()
5009 // - CallBeginCatch enters the __cxa_end_catch cleanup in emitBeginCatch()
5010 // - EmitAutoVarCleanups enters the variable destructor cleanup in emitBeginCatch()
5011 // - EmitCXXTryStmt emits the code for the catch body in emitBeginCatch()
5012 // - EmitCXXTryStmt close the RunCleanupsScope in emitBeginCatch()
5014 VarDecl *CatchParam = S->getExceptionDecl(); in emitBeginCatch()
5023 InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF), S->getBeginLoc()); in emitBeginCatch()
5038 cast<llvm::Function>(fnRef.getCallee()->stripPointerCasts()); in getClangCallTerminateFn()
5039 if (fn->empty()) { in getClangCallTerminateFn()
5042 fn->setDoesNotThrow(); in getClangCallTerminateFn()
5043 fn->setDoesNotReturn(); in getClangCallTerminateFn()
5048 fn->addFnAttr(llvm::Attribute::NoInline); in getClangCallTerminateFn()
5052 fn->setLinkage(llvm::Function::LinkOnceODRLinkage); in getClangCallTerminateFn()
5053 fn->setVisibility(llvm::Function::HiddenVisibility); in getClangCallTerminateFn()
5055 fn->setComdat(CGM.getModule().getOrInsertComdat(fn->getName())); in getClangCallTerminateFn()
5063 llvm::Value *exn = &*fn->arg_begin(); in getClangCallTerminateFn()
5067 catchCall->setDoesNotThrow(); in getClangCallTerminateFn()
5068 catchCall->setCallingConv(CGM.getRuntimeCC()); in getClangCallTerminateFn()
5072 termCall->setDoesNotThrow(); in getClangCallTerminateFn()
5073 termCall->setDoesNotReturn(); in getClangCallTerminateFn()
5074 termCall->setCallingConv(CGM.getRuntimeCC()); in getClangCallTerminateFn()
5103 .findOriginalMethod(MD->getCanonicalDecl()) in getSignedVirtualMemberFunctionPointer()
5107 MD->getType(), MD->getParent()->getTypeForDecl()); in getSignedVirtualMemberFunctionPointer()
5113 if (CGF.getTarget().hasFeature("exception-handling")) in emitBeginCatch()
5188 D.getInit()->getExprLoc()); in emitCXXStermFinalizer()
5211 CI->setCallingConv(dtorStub->getCallingConv()); in emitCXXStermFinalizer()
5219 IPA->getPriority()); in emitCXXStermFinalizer()