Skip to content

Commit 8ee7d91

Browse files
authored
[clang][MicrosoftCXXABI] Avoid Type::getPointerTo() (NFC) (#110915)
`llvm::Type::getPointerTo()` is to be deprecated & removed soon.
1 parent 47ff13b commit 8ee7d91

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

clang/lib/CodeGen/MicrosoftCXXABI.cpp

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ class MicrosoftCXXABI : public CGCXXABI {
518518
CGM.IntTy,
519519
CGM.IntTy,
520520
CGM.IntTy,
521-
getImageRelativeType(getClassHierarchyDescriptorType()->getPointerTo()),
521+
getImageRelativeType(CGM.UnqualPtrTy),
522522
};
523523
BaseClassDescriptorType = llvm::StructType::create(
524524
CGM.getLLVMContext(), FieldTypes, "rtti.BaseClassDescriptor");
@@ -531,13 +531,8 @@ class MicrosoftCXXABI : public CGCXXABI {
531531
// Forward-declare RTTIClassHierarchyDescriptor to break a cycle.
532532
ClassHierarchyDescriptorType = llvm::StructType::create(
533533
CGM.getLLVMContext(), "rtti.ClassHierarchyDescriptor");
534-
llvm::Type *FieldTypes[] = {
535-
CGM.IntTy,
536-
CGM.IntTy,
537-
CGM.IntTy,
538-
getImageRelativeType(
539-
getBaseClassDescriptorType()->getPointerTo()->getPointerTo()),
540-
};
534+
llvm::Type *FieldTypes[] = {CGM.IntTy, CGM.IntTy, CGM.IntTy,
535+
getImageRelativeType(CGM.UnqualPtrTy)};
541536
ClassHierarchyDescriptorType->setBody(FieldTypes);
542537
return ClassHierarchyDescriptorType;
543538
}
@@ -552,7 +547,7 @@ class MicrosoftCXXABI : public CGCXXABI {
552547
CGM.IntTy,
553548
CGM.IntTy,
554549
getImageRelativeType(CGM.Int8PtrTy),
555-
getImageRelativeType(getClassHierarchyDescriptorType()->getPointerTo()),
550+
getImageRelativeType(CGM.UnqualPtrTy),
556551
getImageRelativeType(CompleteObjectLocatorType),
557552
};
558553
llvm::ArrayRef<llvm::Type *> FieldTypesRef(FieldTypes);
@@ -749,8 +744,7 @@ class MicrosoftCXXABI : public CGCXXABI {
749744

750745
llvm::SmallString<23> CTATypeName("eh.CatchableTypeArray.");
751746
CTATypeName += llvm::utostr(NumEntries);
752-
llvm::Type *CTType =
753-
getImageRelativeType(getCatchableTypeType()->getPointerTo());
747+
llvm::Type *CTType = getImageRelativeType(CGM.UnqualPtrTy);
754748
llvm::Type *FieldTypes[] = {
755749
CGM.IntTy, // NumEntries
756750
llvm::ArrayType::get(CTType, NumEntries) // CatchableTypes
@@ -777,7 +771,7 @@ class MicrosoftCXXABI : public CGCXXABI {
777771
llvm::FunctionCallee getThrowFn() {
778772
// _CxxThrowException is passed an exception object and a ThrowInfo object
779773
// which describes the exception.
780-
llvm::Type *Args[] = {CGM.Int8PtrTy, getThrowInfoType()->getPointerTo()};
774+
llvm::Type *Args[] = {CGM.Int8PtrTy, CGM.UnqualPtrTy};
781775
llvm::FunctionType *FTy =
782776
llvm::FunctionType::get(CGM.VoidTy, Args, /*isVarArg=*/false);
783777
llvm::FunctionCallee Throw =
@@ -909,9 +903,8 @@ void MicrosoftCXXABI::emitVirtualObjectDelete(CodeGenFunction &CGF,
909903
}
910904

911905
void MicrosoftCXXABI::emitRethrow(CodeGenFunction &CGF, bool isNoReturn) {
912-
llvm::Value *Args[] = {
913-
llvm::ConstantPointerNull::get(CGM.Int8PtrTy),
914-
llvm::ConstantPointerNull::get(getThrowInfoType()->getPointerTo())};
906+
llvm::Value *Args[] = {llvm::ConstantPointerNull::get(CGM.Int8PtrTy),
907+
llvm::ConstantPointerNull::get(CGM.UnqualPtrTy)};
915908
llvm::FunctionCallee Fn = getThrowFn();
916909
if (isNoReturn)
917910
CGF.EmitNoreturnRuntimeCallOrInvoke(Fn, Args);
@@ -1958,13 +1951,13 @@ CGCallee MicrosoftCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
19581951
SourceLocation Loc) {
19591952
CGBuilderTy &Builder = CGF.Builder;
19601953

1961-
Ty = Ty->getPointerTo();
1954+
Ty = CGF.UnqualPtrTy;
19621955
Address VPtr =
19631956
adjustThisArgumentForVirtualFunctionCall(CGF, GD, This, true);
19641957

19651958
auto *MethodDecl = cast<CXXMethodDecl>(GD.getDecl());
1966-
llvm::Value *VTable = CGF.GetVTablePtr(VPtr, Ty->getPointerTo(),
1967-
MethodDecl->getParent());
1959+
llvm::Value *VTable =
1960+
CGF.GetVTablePtr(VPtr, CGF.UnqualPtrTy, MethodDecl->getParent());
19681961

19691962
MicrosoftVTableContext &VFTContext = CGM.getMicrosoftVTableContext();
19701963
MethodVFTableLocation ML = VFTContext.getMethodVFTableLocation(GD);
@@ -2125,9 +2118,9 @@ MicrosoftCXXABI::EmitVirtualMemPtrThunk(const CXXMethodDecl *MD,
21252118

21262119
// Load the vfptr and then callee from the vftable. The callee should have
21272120
// adjusted 'this' so that the vfptr is at offset zero.
2128-
llvm::Type *ThunkPtrTy = ThunkTy->getPointerTo();
2129-
llvm::Value *VTable = CGF.GetVTablePtr(
2130-
getThisAddress(CGF), ThunkPtrTy->getPointerTo(), MD->getParent());
2121+
llvm::Type *ThunkPtrTy = CGF.UnqualPtrTy;
2122+
llvm::Value *VTable =
2123+
CGF.GetVTablePtr(getThisAddress(CGF), CGF.UnqualPtrTy, MD->getParent());
21312124

21322125
llvm::Value *VFuncPtr = CGF.Builder.CreateConstInBoundsGEP1_64(
21332126
ThunkPtrTy, VTable, ML.Index, "vfn");
@@ -2551,7 +2544,7 @@ static ConstantAddress getInitThreadEpochPtr(CodeGenModule &CGM) {
25512544
static llvm::FunctionCallee getInitThreadHeaderFn(CodeGenModule &CGM) {
25522545
llvm::FunctionType *FTy =
25532546
llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()),
2554-
CGM.IntTy->getPointerTo(), /*isVarArg=*/false);
2547+
CGM.UnqualPtrTy, /*isVarArg=*/false);
25552548
return CGM.CreateRuntimeFunction(
25562549
FTy, "_Init_thread_header",
25572550
llvm::AttributeList::get(CGM.getLLVMContext(),
@@ -2563,7 +2556,7 @@ static llvm::FunctionCallee getInitThreadHeaderFn(CodeGenModule &CGM) {
25632556
static llvm::FunctionCallee getInitThreadFooterFn(CodeGenModule &CGM) {
25642557
llvm::FunctionType *FTy =
25652558
llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()),
2566-
CGM.IntTy->getPointerTo(), /*isVarArg=*/false);
2559+
CGM.UnqualPtrTy, /*isVarArg=*/false);
25672560
return CGM.CreateRuntimeFunction(
25682561
FTy, "_Init_thread_footer",
25692562
llvm::AttributeList::get(CGM.getLLVMContext(),
@@ -2575,7 +2568,7 @@ static llvm::FunctionCallee getInitThreadFooterFn(CodeGenModule &CGM) {
25752568
static llvm::FunctionCallee getInitThreadAbortFn(CodeGenModule &CGM) {
25762569
llvm::FunctionType *FTy =
25772570
llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()),
2578-
CGM.IntTy->getPointerTo(), /*isVarArg=*/false);
2571+
CGM.UnqualPtrTy, /*isVarArg=*/false);
25792572
return CGM.CreateRuntimeFunction(
25802573
FTy, "_Init_thread_abort",
25812574
llvm::AttributeList::get(CGM.getLLVMContext(),
@@ -3157,8 +3150,8 @@ MicrosoftCXXABI::GetVBaseOffsetFromVBPtr(CodeGenFunction &CGF,
31573150
VBPtrAlign = CGF.getPointerAlign();
31583151
}
31593152

3160-
llvm::Value *VBTable = Builder.CreateAlignedLoad(
3161-
CGM.Int32Ty->getPointerTo(0), VBPtr, VBPtrAlign, "vbtable");
3153+
llvm::Value *VBTable =
3154+
Builder.CreateAlignedLoad(CGM.UnqualPtrTy, VBPtr, VBPtrAlign, "vbtable");
31623155

31633156
// Translate from byte offset to table index. It improves analyzability.
31643157
llvm::Value *VBTableIndex = Builder.CreateAShr(
@@ -3813,8 +3806,7 @@ MSRTTIBuilder::getBaseClassArray(SmallVectorImpl<MSRTTIClass> &Classes) {
38133806
// mode) bytes of padding. We provide a pointer sized amount of padding by
38143807
// adding +1 to Classes.size(). The sections have pointer alignment and are
38153808
// marked pick-any so it shouldn't matter.
3816-
llvm::Type *PtrType = ABI.getImageRelativeType(
3817-
ABI.getBaseClassDescriptorType()->getPointerTo());
3809+
llvm::Type *PtrType = ABI.getImageRelativeType(CGM.UnqualPtrTy);
38183810
auto *ArrType = llvm::ArrayType::get(PtrType, Classes.size() + 1);
38193811
auto *BCA =
38203812
new llvm::GlobalVariable(Module, ArrType,
@@ -4360,8 +4352,7 @@ llvm::GlobalVariable *MicrosoftCXXABI::getCatchableTypeArray(QualType T) {
43604352
CatchableTypes.insert(getCatchableType(getContext().VoidPtrTy));
43614353

43624354
uint32_t NumEntries = CatchableTypes.size();
4363-
llvm::Type *CTType =
4364-
getImageRelativeType(getCatchableTypeType()->getPointerTo());
4355+
llvm::Type *CTType = getImageRelativeType(CGM.UnqualPtrTy);
43654356
llvm::ArrayType *AT = llvm::ArrayType::get(CTType, NumEntries);
43664357
llvm::StructType *CTAType = getCatchableTypeArrayType(NumEntries);
43674358
llvm::Constant *Fields[] = {

0 commit comments

Comments
 (0)