Skip to content

Commit 9162b69

Browse files
committed
[clang] Sync with community to use UnqualPtrTy
Remove leftover differences during opaque pointer transition.
1 parent 5c562c9 commit 9162b69

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,9 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
752752
} else {
753753
llvm::Value *VFPAddr =
754754
CGF.Builder.CreateGEP(CGF.Int8Ty, VTable, VTableOffset);
755-
VirtualFn = CGF.Builder.CreateAlignedLoad(
756-
llvm::PointerType::getUnqual(CGF.getLLVMContext()), VFPAddr,
757-
CGF.getPointerAlign(), "memptr.virtualfn");
755+
VirtualFn = CGF.Builder.CreateAlignedLoad(CGF.UnqualPtrTy, VFPAddr,
756+
CGF.getPointerAlign(),
757+
"memptr.virtualfn");
758758
}
759759
}
760760
assert(VirtualFn && "Virtual fuction pointer not created!");
@@ -794,9 +794,8 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
794794
// In the non-virtual path, the function pointer is actually a
795795
// function pointer.
796796
CGF.EmitBlock(FnNonVirtual);
797-
llvm::Value *NonVirtualFn = Builder.CreateIntToPtr(
798-
FnAsInt, llvm::PointerType::getUnqual(CGF.getLLVMContext()),
799-
"memptr.nonvirtualfn");
797+
llvm::Value *NonVirtualFn =
798+
Builder.CreateIntToPtr(FnAsInt, CGF.UnqualPtrTy, "memptr.nonvirtualfn");
800799

801800
// Check the function pointer if CFI on member function pointers is enabled.
802801
if (ShouldEmitCFICheck) {
@@ -835,8 +834,7 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
835834

836835
// We're done.
837836
CGF.EmitBlock(FnEnd);
838-
llvm::PHINode *CalleePtr =
839-
Builder.CreatePHI(llvm::PointerType::getUnqual(CGF.getLLVMContext()), 2);
837+
llvm::PHINode *CalleePtr = Builder.CreatePHI(CGF.UnqualPtrTy, 2);
840838
CalleePtr->addIncoming(VirtualFn, FnVirtual);
841839
CalleePtr->addIncoming(NonVirtualFn, FnNonVirtual);
842840

@@ -1380,8 +1378,7 @@ void ItaniumCXXABI::emitVirtualObjectDelete(CodeGenFunction &CGF,
13801378
// Grab the vtable pointer as an intptr_t*.
13811379
auto *ClassDecl =
13821380
cast<CXXRecordDecl>(ElementType->castAs<RecordType>()->getDecl());
1383-
llvm::Value *VTable = CGF.GetVTablePtr(
1384-
Ptr, llvm::PointerType::getUnqual(CGF.getLLVMContext()), ClassDecl);
1381+
llvm::Value *VTable = CGF.GetVTablePtr(Ptr, CGF.UnqualPtrTy, ClassDecl);
13851382

13861383
// Track back to entry -2 and pull out the offset there.
13871384
llvm::Value *OffsetPtr = CGF.Builder.CreateConstInBoundsGEP1_64(
@@ -1754,9 +1751,8 @@ llvm::Value *ItaniumCXXABI::emitDynamicCastToVoid(CodeGenFunction &CGF,
17541751
llvm::Value *OffsetToTop;
17551752
if (CGM.getItaniumVTableContext().isRelativeLayout()) {
17561753
// Get the vtable pointer.
1757-
llvm::Value *VTable = CGF.GetVTablePtr(
1758-
ThisAddr, llvm::PointerType::getUnqual(CGF.getLLVMContext()),
1759-
ClassDecl);
1754+
llvm::Value *VTable =
1755+
CGF.GetVTablePtr(ThisAddr, CGF.UnqualPtrTy, ClassDecl);
17601756

17611757
// Get the offset-to-top from the vtable.
17621758
OffsetToTop =
@@ -1768,9 +1764,8 @@ llvm::Value *ItaniumCXXABI::emitDynamicCastToVoid(CodeGenFunction &CGF,
17681764
CGF.ConvertType(CGF.getContext().getPointerDiffType());
17691765

17701766
// Get the vtable pointer.
1771-
llvm::Value *VTable = CGF.GetVTablePtr(
1772-
ThisAddr, llvm::PointerType::getUnqual(CGF.getLLVMContext()),
1773-
ClassDecl);
1767+
llvm::Value *VTable =
1768+
CGF.GetVTablePtr(ThisAddr, CGF.UnqualPtrTy, ClassDecl);
17741769

17751770
// Get the offset-to-top from the vtable.
17761771
OffsetToTop =
@@ -2182,7 +2177,8 @@ llvm::GlobalVariable *ItaniumCXXABI::getAddrOfVTable(const CXXRecordDecl *RD,
21822177
}
21832178

21842179
CGCallee ItaniumCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
2185-
GlobalDecl GD, Address This,
2180+
GlobalDecl GD,
2181+
Address This,
21862182
llvm::Type *Ty,
21872183
SourceLocation Loc) {
21882184
llvm::Type *PtrTy = CGM.GlobalsInt8PtrTy;
@@ -2502,8 +2498,8 @@ llvm::Value *ItaniumCXXABI::readArrayCookieImpl(CodeGenFunction &CGF,
25022498
// cookie, otherwise return 0 to avoid an infinite loop calling DTORs.
25032499
// We can't simply ignore this load using nosanitize metadata because
25042500
// the metadata may be lost.
2505-
llvm::FunctionType *FTy = llvm::FunctionType::get(
2506-
CGF.SizeTy, llvm::PointerType::getUnqual(CGF.getLLVMContext()), false);
2501+
llvm::FunctionType *FTy =
2502+
llvm::FunctionType::get(CGF.SizeTy, CGF.UnqualPtrTy, false);
25072503
llvm::FunctionCallee F =
25082504
CGM.CreateRuntimeFunction(FTy, "__asan_load_cxx_array_cookie");
25092505
return CGF.Builder.CreateCall(F, numElementsPtr.emitRawPointer(CGF));
@@ -2846,7 +2842,7 @@ static void emitGlobalDtorWithCXAAtExit(CodeGenFunction &CGF,
28462842

28472843
// We're assuming that the destructor function is something we can
28482844
// reasonably call with the default CC.
2849-
llvm::Type *dtorTy = llvm::PointerType::getUnqual(CGF.getLLVMContext());
2845+
llvm::Type *dtorTy = CGF.UnqualPtrTy;
28502846

28512847
// Preserve address space of addr.
28522848
auto AddrAS = addr ? addr->getType()->getPointerAddressSpace() : 0;
@@ -4968,8 +4964,7 @@ static void InitCatchParam(CodeGenFunction &CGF,
49684964
auto catchRD = CatchType->getAsCXXRecordDecl();
49694965
CharUnits caughtExnAlignment = CGF.CGM.getClassPointerAlignment(catchRD);
49704966

4971-
llvm::Type *PtrTy =
4972-
llvm::PointerType::getUnqual(CGF.getLLVMContext()); // addrspace 0 ok
4967+
llvm::Type *PtrTy = CGF.UnqualPtrTy; // addrspace 0 ok
49734968

49744969
// Check for a copy expression. If we don't have a copy expression,
49754970
// that means a trivial copy is okay.
@@ -5169,8 +5164,7 @@ void XLCXXABI::registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,
51695164
llvm::FunctionCallee Dtor,
51705165
llvm::Constant *Addr) {
51715166
if (D.getTLSKind() != VarDecl::TLS_None) {
5172-
llvm::PointerType *PtrTy =
5173-
llvm::PointerType::getUnqual(CGF.getLLVMContext());
5167+
llvm::PointerType *PtrTy = CGF.UnqualPtrTy;
51745168

51755169
// extern "C" int __pt_atexit_np(int flags, int(*)(int,...), ...);
51765170
llvm::FunctionType *AtExitTy =

0 commit comments

Comments
 (0)