https://github.com/JOE1994 created https://github.com/llvm/llvm-project/pull/110915
`llvm::Type::getPointerTo()` is to be deprecated & removed soon. >From 1aa33200fc6b9d6222fd160ae63d8ba2255e69d5 Mon Sep 17 00:00:00 2001 From: Youngsuk Kim <youngsuk....@hpe.com> Date: Wed, 2 Oct 2024 13:49:18 -0500 Subject: [PATCH] [clang][MicrosoftCXXABI] Avoid Type::getPointerTo() (NFC) `llvm::Type::getPointerTo()` is to be deprecated & removed soon. --- clang/lib/CodeGen/MicrosoftCXXABI.cpp | 51 +++++++++++---------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 79dcdc04b0996f..0b0b45ffead92f 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -518,7 +518,7 @@ class MicrosoftCXXABI : public CGCXXABI { CGM.IntTy, CGM.IntTy, CGM.IntTy, - getImageRelativeType(getClassHierarchyDescriptorType()->getPointerTo()), + getImageRelativeType(CGM.UnqualPtrTy), }; BaseClassDescriptorType = llvm::StructType::create( CGM.getLLVMContext(), FieldTypes, "rtti.BaseClassDescriptor"); @@ -531,13 +531,8 @@ class MicrosoftCXXABI : public CGCXXABI { // Forward-declare RTTIClassHierarchyDescriptor to break a cycle. ClassHierarchyDescriptorType = llvm::StructType::create( CGM.getLLVMContext(), "rtti.ClassHierarchyDescriptor"); - llvm::Type *FieldTypes[] = { - CGM.IntTy, - CGM.IntTy, - CGM.IntTy, - getImageRelativeType( - getBaseClassDescriptorType()->getPointerTo()->getPointerTo()), - }; + llvm::Type *FieldTypes[] = {CGM.IntTy, CGM.IntTy, CGM.IntTy, + getImageRelativeType(CGM.UnqualPtrTy)}; ClassHierarchyDescriptorType->setBody(FieldTypes); return ClassHierarchyDescriptorType; } @@ -552,7 +547,7 @@ class MicrosoftCXXABI : public CGCXXABI { CGM.IntTy, CGM.IntTy, getImageRelativeType(CGM.Int8PtrTy), - getImageRelativeType(getClassHierarchyDescriptorType()->getPointerTo()), + getImageRelativeType(CGM.UnqualPtrTy), getImageRelativeType(CompleteObjectLocatorType), }; llvm::ArrayRef<llvm::Type *> FieldTypesRef(FieldTypes); @@ -749,8 +744,7 @@ class MicrosoftCXXABI : public CGCXXABI { llvm::SmallString<23> CTATypeName("eh.CatchableTypeArray."); CTATypeName += llvm::utostr(NumEntries); - llvm::Type *CTType = - getImageRelativeType(getCatchableTypeType()->getPointerTo()); + llvm::Type *CTType = getImageRelativeType(CGM.UnqualPtrTy); llvm::Type *FieldTypes[] = { CGM.IntTy, // NumEntries llvm::ArrayType::get(CTType, NumEntries) // CatchableTypes @@ -777,7 +771,7 @@ class MicrosoftCXXABI : public CGCXXABI { llvm::FunctionCallee getThrowFn() { // _CxxThrowException is passed an exception object and a ThrowInfo object // which describes the exception. - llvm::Type *Args[] = {CGM.Int8PtrTy, getThrowInfoType()->getPointerTo()}; + llvm::Type *Args[] = {CGM.Int8PtrTy, CGM.UnqualPtrTy}; llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.VoidTy, Args, /*isVarArg=*/false); llvm::FunctionCallee Throw = @@ -909,9 +903,8 @@ void MicrosoftCXXABI::emitVirtualObjectDelete(CodeGenFunction &CGF, } void MicrosoftCXXABI::emitRethrow(CodeGenFunction &CGF, bool isNoReturn) { - llvm::Value *Args[] = { - llvm::ConstantPointerNull::get(CGM.Int8PtrTy), - llvm::ConstantPointerNull::get(getThrowInfoType()->getPointerTo())}; + llvm::Value *Args[] = {llvm::ConstantPointerNull::get(CGM.Int8PtrTy), + llvm::ConstantPointerNull::get(CGM.UnqualPtrTy)}; llvm::FunctionCallee Fn = getThrowFn(); if (isNoReturn) CGF.EmitNoreturnRuntimeCallOrInvoke(Fn, Args); @@ -1958,13 +1951,13 @@ CGCallee MicrosoftCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF, SourceLocation Loc) { CGBuilderTy &Builder = CGF.Builder; - Ty = Ty->getPointerTo(); + Ty = CGF.UnqualPtrTy; Address VPtr = adjustThisArgumentForVirtualFunctionCall(CGF, GD, This, true); auto *MethodDecl = cast<CXXMethodDecl>(GD.getDecl()); - llvm::Value *VTable = CGF.GetVTablePtr(VPtr, Ty->getPointerTo(), - MethodDecl->getParent()); + llvm::Value *VTable = + CGF.GetVTablePtr(VPtr, CGF.UnqualPtrTy, MethodDecl->getParent()); MicrosoftVTableContext &VFTContext = CGM.getMicrosoftVTableContext(); MethodVFTableLocation ML = VFTContext.getMethodVFTableLocation(GD); @@ -2125,9 +2118,9 @@ MicrosoftCXXABI::EmitVirtualMemPtrThunk(const CXXMethodDecl *MD, // Load the vfptr and then callee from the vftable. The callee should have // adjusted 'this' so that the vfptr is at offset zero. - llvm::Type *ThunkPtrTy = ThunkTy->getPointerTo(); - llvm::Value *VTable = CGF.GetVTablePtr( - getThisAddress(CGF), ThunkPtrTy->getPointerTo(), MD->getParent()); + llvm::Type *ThunkPtrTy = CGF.UnqualPtrTy; + llvm::Value *VTable = + CGF.GetVTablePtr(getThisAddress(CGF), CGF.UnqualPtrTy, MD->getParent()); llvm::Value *VFuncPtr = CGF.Builder.CreateConstInBoundsGEP1_64( ThunkPtrTy, VTable, ML.Index, "vfn"); @@ -2551,7 +2544,7 @@ static ConstantAddress getInitThreadEpochPtr(CodeGenModule &CGM) { static llvm::FunctionCallee getInitThreadHeaderFn(CodeGenModule &CGM) { llvm::FunctionType *FTy = llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), - CGM.IntTy->getPointerTo(), /*isVarArg=*/false); + CGM.UnqualPtrTy, /*isVarArg=*/false); return CGM.CreateRuntimeFunction( FTy, "_Init_thread_header", llvm::AttributeList::get(CGM.getLLVMContext(), @@ -2563,7 +2556,7 @@ static llvm::FunctionCallee getInitThreadHeaderFn(CodeGenModule &CGM) { static llvm::FunctionCallee getInitThreadFooterFn(CodeGenModule &CGM) { llvm::FunctionType *FTy = llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), - CGM.IntTy->getPointerTo(), /*isVarArg=*/false); + CGM.UnqualPtrTy, /*isVarArg=*/false); return CGM.CreateRuntimeFunction( FTy, "_Init_thread_footer", llvm::AttributeList::get(CGM.getLLVMContext(), @@ -2575,7 +2568,7 @@ static llvm::FunctionCallee getInitThreadFooterFn(CodeGenModule &CGM) { static llvm::FunctionCallee getInitThreadAbortFn(CodeGenModule &CGM) { llvm::FunctionType *FTy = llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), - CGM.IntTy->getPointerTo(), /*isVarArg=*/false); + CGM.UnqualPtrTy, /*isVarArg=*/false); return CGM.CreateRuntimeFunction( FTy, "_Init_thread_abort", llvm::AttributeList::get(CGM.getLLVMContext(), @@ -3157,8 +3150,8 @@ MicrosoftCXXABI::GetVBaseOffsetFromVBPtr(CodeGenFunction &CGF, VBPtrAlign = CGF.getPointerAlign(); } - llvm::Value *VBTable = Builder.CreateAlignedLoad( - CGM.Int32Ty->getPointerTo(0), VBPtr, VBPtrAlign, "vbtable"); + llvm::Value *VBTable = + Builder.CreateAlignedLoad(CGM.UnqualPtrTy, VBPtr, VBPtrAlign, "vbtable"); // Translate from byte offset to table index. It improves analyzability. llvm::Value *VBTableIndex = Builder.CreateAShr( @@ -3813,8 +3806,7 @@ MSRTTIBuilder::getBaseClassArray(SmallVectorImpl<MSRTTIClass> &Classes) { // mode) bytes of padding. We provide a pointer sized amount of padding by // adding +1 to Classes.size(). The sections have pointer alignment and are // marked pick-any so it shouldn't matter. - llvm::Type *PtrType = ABI.getImageRelativeType( - ABI.getBaseClassDescriptorType()->getPointerTo()); + llvm::Type *PtrType = ABI.getImageRelativeType(CGM.UnqualPtrTy); auto *ArrType = llvm::ArrayType::get(PtrType, Classes.size() + 1); auto *BCA = new llvm::GlobalVariable(Module, ArrType, @@ -4360,8 +4352,7 @@ llvm::GlobalVariable *MicrosoftCXXABI::getCatchableTypeArray(QualType T) { CatchableTypes.insert(getCatchableType(getContext().VoidPtrTy)); uint32_t NumEntries = CatchableTypes.size(); - llvm::Type *CTType = - getImageRelativeType(getCatchableTypeType()->getPointerTo()); + llvm::Type *CTType = getImageRelativeType(CGM.UnqualPtrTy); llvm::ArrayType *AT = llvm::ArrayType::get(CTType, NumEntries); llvm::StructType *CTAType = getCatchableTypeArrayType(NumEntries); llvm::Constant *Fields[] = { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits