Skip to content

Commit 74d77dc

Browse files
authored
[Clang][NFC] Rename UnqualPtrTy to DefaultPtrTy (#163207)
`UnqualPtrTy` didn't always match `llvm::PointerType::getUnqual`: sometimes it returned a pointer that is not in address space 0 (notably for SPIRV). Since `UnqualPtrTy` was used as the "generic" or "default" pointer type, this patch renames it to `DefaultPtrTy` to avoid confusion with LLVM's `PointerType::getUnqual`.
1 parent 154138c commit 74d77dc

File tree

14 files changed

+67
-67
lines changed

14 files changed

+67
-67
lines changed

clang/lib/CodeGen/CGAtomic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace {
8686
llvm::Value *StoragePtr = CGF.Builder.CreateConstGEP1_64(
8787
CGF.Int8Ty, BitFieldPtr, OffsetInChars.getQuantity());
8888
StoragePtr = CGF.Builder.CreateAddrSpaceCast(
89-
StoragePtr, CGF.UnqualPtrTy, "atomic_bitfield_base");
89+
StoragePtr, CGF.DefaultPtrTy, "atomic_bitfield_base");
9090
BFI = OrigBFI;
9191
BFI.Offset = Offset;
9292
BFI.StorageSize = AtomicSizeInBits;

clang/lib/CodeGen/CGBlocks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr *E,
12071207
} else {
12081208
// Bitcast the block literal to a generic block literal.
12091209
BlockPtr =
1210-
Builder.CreatePointerCast(BlockPtr, UnqualPtrTy, "block.literal");
1210+
Builder.CreatePointerCast(BlockPtr, DefaultPtrTy, "block.literal");
12111211
// Get pointer to the block invoke function
12121212
FuncPtr = Builder.CreateStructGEP(GenBlockTy, BlockPtr, 3);
12131213

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ static llvm::Value *EmitX86BitTestIntrinsic(CodeGenFunction &CGF,
16731673
CGF.getLLVMContext(),
16741674
CGF.getContext().getTypeSize(E->getArg(1)->getType()));
16751675
llvm::FunctionType *FTy =
1676-
llvm::FunctionType::get(CGF.Int8Ty, {CGF.UnqualPtrTy, IntType}, false);
1676+
llvm::FunctionType::get(CGF.Int8Ty, {CGF.DefaultPtrTy, IntType}, false);
16771677

16781678
llvm::InlineAsm *IA =
16791679
llvm::InlineAsm::get(FTy, Asm, Constraints, /*hasSideEffects=*/true);

clang/lib/CodeGen/CGCUDANV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ CGNVCUDARuntime::CGNVCUDARuntime(CodeGenModule &CGM)
230230
IntTy = CGM.IntTy;
231231
SizeTy = CGM.SizeTy;
232232
VoidTy = CGM.VoidTy;
233-
PtrTy = CGM.UnqualPtrTy;
233+
PtrTy = CGM.DefaultPtrTy;
234234

235235
if (CGM.getLangOpts().OffloadViaLLVM)
236236
Prefix = "llvm";

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ LValue CodeGenFunction::EmitUnsupportedLValue(const Expr *E,
17561756
const char *Name) {
17571757
ErrorUnsupported(E, Name);
17581758
llvm::Type *ElTy = ConvertType(E->getType());
1759-
llvm::Type *Ty = UnqualPtrTy;
1759+
llvm::Type *Ty = DefaultPtrTy;
17601760
return MakeAddrLValue(
17611761
Address(llvm::UndefValue::get(Ty), ElTy, CharUnits::One()), E->getType());
17621762
}
@@ -4270,7 +4270,7 @@ void CodeGenFunction::EmitCfiCheckFail() {
42704270
llvm::StructType::get(Int8Ty, SourceLocationTy, VoidPtrTy);
42714271

42724272
llvm::Value *V = Builder.CreateConstGEP2_32(
4273-
CfiCheckFailDataTy, Builder.CreatePointerCast(Data, UnqualPtrTy), 0, 0);
4273+
CfiCheckFailDataTy, Builder.CreatePointerCast(Data, DefaultPtrTy), 0, 0);
42744274

42754275
Address CheckKindAddr(V, Int8Ty, getIntAlign());
42764276
llvm::Value *CheckKind = Builder.CreateLoad(CheckKindAddr);
@@ -5711,7 +5711,7 @@ std::optional<LValue> HandleConditionalOperatorLValueSimpleCase(
57115711
if (auto *ThrowExpr = dyn_cast<CXXThrowExpr>(Live->IgnoreParens())) {
57125712
CGF.EmitCXXThrowExpr(ThrowExpr);
57135713
llvm::Type *ElemTy = CGF.ConvertType(Dead->getType());
5714-
llvm::Type *Ty = CGF.UnqualPtrTy;
5714+
llvm::Type *Ty = CGF.DefaultPtrTy;
57155715
return CGF.MakeAddrLValue(
57165716
Address(llvm::UndefValue::get(Ty), ElemTy, CharUnits::One()),
57175717
Dead->getType());

clang/lib/CodeGen/CGObjCMac.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -338,39 +338,39 @@ class ObjCCommonTypesHelper {
338338
/// GcReadWeakFn -- LLVM objc_read_weak (id *src) function.
339339
llvm::FunctionCallee getGcReadWeakFn() {
340340
// id objc_read_weak (id *)
341-
llvm::Type *args[] = {CGM.UnqualPtrTy};
341+
llvm::Type *args[] = {CGM.DefaultPtrTy};
342342
llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
343343
return CGM.CreateRuntimeFunction(FTy, "objc_read_weak");
344344
}
345345

346346
/// GcAssignWeakFn -- LLVM objc_assign_weak function.
347347
llvm::FunctionCallee getGcAssignWeakFn() {
348348
// id objc_assign_weak (id, id *)
349-
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
349+
llvm::Type *args[] = {ObjectPtrTy, CGM.DefaultPtrTy};
350350
llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
351351
return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak");
352352
}
353353

354354
/// GcAssignGlobalFn -- LLVM objc_assign_global function.
355355
llvm::FunctionCallee getGcAssignGlobalFn() {
356356
// id objc_assign_global(id, id *)
357-
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
357+
llvm::Type *args[] = {ObjectPtrTy, CGM.DefaultPtrTy};
358358
llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
359359
return CGM.CreateRuntimeFunction(FTy, "objc_assign_global");
360360
}
361361

362362
/// GcAssignThreadLocalFn -- LLVM objc_assign_threadlocal function.
363363
llvm::FunctionCallee getGcAssignThreadLocalFn() {
364364
// id objc_assign_threadlocal(id src, id * dest)
365-
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
365+
llvm::Type *args[] = {ObjectPtrTy, CGM.DefaultPtrTy};
366366
llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
367367
return CGM.CreateRuntimeFunction(FTy, "objc_assign_threadlocal");
368368
}
369369

370370
/// GcAssignIvarFn -- LLVM objc_assign_ivar function.
371371
llvm::FunctionCallee getGcAssignIvarFn() {
372372
// id objc_assign_ivar(id, id *, ptrdiff_t)
373-
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy, CGM.PtrDiffTy};
373+
llvm::Type *args[] = {ObjectPtrTy, CGM.DefaultPtrTy, CGM.PtrDiffTy};
374374
llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
375375
return CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar");
376376
}
@@ -386,7 +386,7 @@ class ObjCCommonTypesHelper {
386386
/// GcAssignStrongCastFn -- LLVM objc_assign_strongCast function.
387387
llvm::FunctionCallee getGcAssignStrongCastFn() {
388388
// id objc_assign_strongCast(id, id *)
389-
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
389+
llvm::Type *args[] = {ObjectPtrTy, CGM.DefaultPtrTy};
390390
llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
391391
return CGM.CreateRuntimeFunction(FTy, "objc_assign_strongCast");
392392
}
@@ -517,23 +517,23 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper {
517517

518518
/// ExceptionTryEnterFn - LLVM objc_exception_try_enter function.
519519
llvm::FunctionCallee getExceptionTryEnterFn() {
520-
llvm::Type *params[] = {CGM.UnqualPtrTy};
520+
llvm::Type *params[] = {CGM.DefaultPtrTy};
521521
return CGM.CreateRuntimeFunction(
522522
llvm::FunctionType::get(CGM.VoidTy, params, false),
523523
"objc_exception_try_enter");
524524
}
525525

526526
/// ExceptionTryExitFn - LLVM objc_exception_try_exit function.
527527
llvm::FunctionCallee getExceptionTryExitFn() {
528-
llvm::Type *params[] = {CGM.UnqualPtrTy};
528+
llvm::Type *params[] = {CGM.DefaultPtrTy};
529529
return CGM.CreateRuntimeFunction(
530530
llvm::FunctionType::get(CGM.VoidTy, params, false),
531531
"objc_exception_try_exit");
532532
}
533533

534534
/// ExceptionExtractFn - LLVM objc_exception_extract function.
535535
llvm::FunctionCallee getExceptionExtractFn() {
536-
llvm::Type *params[] = {CGM.UnqualPtrTy};
536+
llvm::Type *params[] = {CGM.DefaultPtrTy};
537537
return CGM.CreateRuntimeFunction(
538538
llvm::FunctionType::get(ObjectPtrTy, params, false),
539539
"objc_exception_extract");
@@ -550,7 +550,7 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper {
550550
/// SetJmpFn - LLVM _setjmp function.
551551
llvm::FunctionCallee getSetJmpFn() {
552552
// This is specifically the prototype for x86.
553-
llvm::Type *params[] = {CGM.UnqualPtrTy};
553+
llvm::Type *params[] = {CGM.DefaultPtrTy};
554554
return CGM.CreateRuntimeFunction(
555555
llvm::FunctionType::get(CGM.Int32Ty, params, false), "_setjmp",
556556
llvm::AttributeList::get(CGM.getLLVMContext(),
@@ -1927,7 +1927,7 @@ CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) {
19271927
// If we don't already have it, construct the type for a constant NSString.
19281928
if (!NSConstantStringType) {
19291929
NSConstantStringType =
1930-
llvm::StructType::create({CGM.UnqualPtrTy, CGM.Int8PtrTy, CGM.IntTy},
1930+
llvm::StructType::create({CGM.DefaultPtrTy, CGM.Int8PtrTy, CGM.IntTy},
19311931
"struct.__builtin_NSString");
19321932
}
19331933

@@ -5959,7 +5959,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(
59595959
Int8PtrTy, PropertyListPtrTy);
59605960

59615961
// ImpnfABITy - LLVM for id (*)(id, SEL, ...)
5962-
ImpnfABITy = CGM.UnqualPtrTy;
5962+
ImpnfABITy = CGM.DefaultPtrTy;
59635963

59645964
// struct _class_t {
59655965
// struct _class_t *isa;
@@ -6380,7 +6380,7 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
63806380
CGM.getModule(), ObjCTypes.ImpnfABITy, false,
63816381
llvm::GlobalValue::ExternalLinkage, nullptr, "_objc_empty_vtable");
63826382
else
6383-
ObjCEmptyVtableVar = llvm::ConstantPointerNull::get(CGM.UnqualPtrTy);
6383+
ObjCEmptyVtableVar = llvm::ConstantPointerNull::get(CGM.DefaultPtrTy);
63846384
}
63856385

63866386
// FIXME: Is this correct (that meta class size is never computed)?

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,12 +1714,12 @@ llvm::Function *CGOpenMPRuntime::emitThreadPrivateVarDefinition(
17141714
// Copying constructor for the threadprivate variable.
17151715
// Must be NULL - reserved by runtime, but currently it requires that this
17161716
// parameter is always NULL. Otherwise it fires assertion.
1717-
CopyCtor = llvm::Constant::getNullValue(CGM.UnqualPtrTy);
1717+
CopyCtor = llvm::Constant::getNullValue(CGM.DefaultPtrTy);
17181718
if (Ctor == nullptr) {
1719-
Ctor = llvm::Constant::getNullValue(CGM.UnqualPtrTy);
1719+
Ctor = llvm::Constant::getNullValue(CGM.DefaultPtrTy);
17201720
}
17211721
if (Dtor == nullptr) {
1722-
Dtor = llvm::Constant::getNullValue(CGM.UnqualPtrTy);
1722+
Dtor = llvm::Constant::getNullValue(CGM.DefaultPtrTy);
17231723
}
17241724
if (!CGF) {
17251725
auto *InitFunctionTy =

clang/lib/CodeGen/CGPointerAuth.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ CodeGenModule::getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key,
426426
llvm::ConstantInt *OtherDiscriminator) {
427427
llvm::Constant *AddressDiscriminator;
428428
if (StorageAddress) {
429-
assert(StorageAddress->getType() == UnqualPtrTy);
429+
assert(StorageAddress->getType() == DefaultPtrTy);
430430
AddressDiscriminator = StorageAddress;
431431
} else {
432-
AddressDiscriminator = llvm::Constant::getNullValue(UnqualPtrTy);
432+
AddressDiscriminator = llvm::Constant::getNullValue(DefaultPtrTy);
433433
}
434434

435435
llvm::ConstantInt *IntegerDiscriminator;

clang/lib/CodeGen/CodeGenTypeCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct CodeGenTypeCache {
5353

5454
/// void*, void** in the target's default address space (often 0)
5555
union {
56-
llvm::PointerType *UnqualPtrTy;
56+
llvm::PointerType *DefaultPtrTy;
5757
llvm::PointerType *VoidPtrTy;
5858
llvm::PointerType *Int8PtrTy;
5959
llvm::PointerType *VoidPtrPtrTy;

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
774774
} else {
775775
llvm::Value *VFPAddr =
776776
CGF.Builder.CreateGEP(CGF.Int8Ty, VTable, VTableOffset);
777-
VirtualFn = CGF.Builder.CreateAlignedLoad(CGF.UnqualPtrTy, VFPAddr,
777+
VirtualFn = CGF.Builder.CreateAlignedLoad(CGF.DefaultPtrTy, VFPAddr,
778778
CGF.getPointerAlign(),
779779
"memptr.virtualfn");
780780
}
@@ -816,7 +816,7 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
816816
// function pointer.
817817
CGF.EmitBlock(FnNonVirtual);
818818
llvm::Value *NonVirtualFn =
819-
Builder.CreateIntToPtr(FnAsInt, CGF.UnqualPtrTy, "memptr.nonvirtualfn");
819+
Builder.CreateIntToPtr(FnAsInt, CGF.DefaultPtrTy, "memptr.nonvirtualfn");
820820

821821
// Check the function pointer if CFI on member function pointers is enabled.
822822
if (ShouldEmitCFICheck) {
@@ -856,7 +856,7 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
856856

857857
// We're done.
858858
CGF.EmitBlock(FnEnd);
859-
llvm::PHINode *CalleePtr = Builder.CreatePHI(CGF.UnqualPtrTy, 2);
859+
llvm::PHINode *CalleePtr = Builder.CreatePHI(CGF.DefaultPtrTy, 2);
860860
CalleePtr->addIncoming(VirtualFn, FnVirtual);
861861
CalleePtr->addIncoming(NonVirtualFn, FnNonVirtual);
862862

@@ -1403,7 +1403,7 @@ void ItaniumCXXABI::emitVirtualObjectDelete(CodeGenFunction &CGF,
14031403

14041404
// Grab the vtable pointer as an intptr_t*.
14051405
auto *ClassDecl = ElementType->castAsCXXRecordDecl();
1406-
llvm::Value *VTable = CGF.GetVTablePtr(Ptr, CGF.UnqualPtrTy, ClassDecl);
1406+
llvm::Value *VTable = CGF.GetVTablePtr(Ptr, CGF.DefaultPtrTy, ClassDecl);
14071407

14081408
// Track back to entry -2 and pull out the offset there.
14091409
llvm::Value *OffsetPtr = CGF.Builder.CreateConstInBoundsGEP1_64(
@@ -1749,7 +1749,7 @@ llvm::Value *ItaniumCXXABI::emitExactDynamicCast(
17491749
auto AuthenticateVTable = [&](Address ThisAddr, const CXXRecordDecl *Decl) {
17501750
if (!CGF.getLangOpts().PointerAuthCalls)
17511751
return;
1752-
(void)CGF.GetVTablePtr(ThisAddr, CGF.UnqualPtrTy, Decl,
1752+
(void)CGF.GetVTablePtr(ThisAddr, CGF.DefaultPtrTy, Decl,
17531753
CodeGenFunction::VTableAuthMode::MustTrap);
17541754
};
17551755

@@ -1775,7 +1775,7 @@ llvm::Value *ItaniumCXXABI::emitExactDynamicCast(
17751775
if (PerformPostCastAuthentication)
17761776
VTable = CGF.EmitPointerAuthAuth(StrippingAuthInfo, VTable);
17771777
} else
1778-
VTable = CGF.GetVTablePtr(ThisAddr, CGF.UnqualPtrTy, SrcDecl);
1778+
VTable = CGF.GetVTablePtr(ThisAddr, CGF.DefaultPtrTy, SrcDecl);
17791779

17801780
// Compare the vptr against the expected vptr for the destination type at
17811781
// this offset.
@@ -1828,7 +1828,7 @@ llvm::Value *ItaniumCXXABI::emitDynamicCastToVoid(CodeGenFunction &CGF,
18281828
if (CGM.getItaniumVTableContext().isRelativeLayout()) {
18291829
// Get the vtable pointer.
18301830
llvm::Value *VTable =
1831-
CGF.GetVTablePtr(ThisAddr, CGF.UnqualPtrTy, ClassDecl);
1831+
CGF.GetVTablePtr(ThisAddr, CGF.DefaultPtrTy, ClassDecl);
18321832

18331833
// Get the offset-to-top from the vtable.
18341834
OffsetToTop =
@@ -1841,7 +1841,7 @@ llvm::Value *ItaniumCXXABI::emitDynamicCastToVoid(CodeGenFunction &CGF,
18411841

18421842
// Get the vtable pointer.
18431843
llvm::Value *VTable =
1844-
CGF.GetVTablePtr(ThisAddr, CGF.UnqualPtrTy, ClassDecl);
1844+
CGF.GetVTablePtr(ThisAddr, CGF.DefaultPtrTy, ClassDecl);
18451845

18461846
// Get the offset-to-top from the vtable.
18471847
OffsetToTop =
@@ -2578,7 +2578,7 @@ llvm::Value *ItaniumCXXABI::readArrayCookieImpl(CodeGenFunction &CGF,
25782578
// We can't simply ignore this load using nosanitize metadata because
25792579
// the metadata may be lost.
25802580
llvm::FunctionType *FTy =
2581-
llvm::FunctionType::get(CGF.SizeTy, CGF.UnqualPtrTy, false);
2581+
llvm::FunctionType::get(CGF.SizeTy, CGF.DefaultPtrTy, false);
25822582
llvm::FunctionCallee F =
25832583
CGM.CreateRuntimeFunction(FTy, "__asan_load_cxx_array_cookie");
25842584
return CGF.Builder.CreateCall(F, numElementsPtr.emitRawPointer(CGF));
@@ -2921,7 +2921,7 @@ static void emitGlobalDtorWithCXAAtExit(CodeGenFunction &CGF,
29212921

29222922
// We're assuming that the destructor function is something we can
29232923
// reasonably call with the default CC.
2924-
llvm::Type *dtorTy = CGF.UnqualPtrTy;
2924+
llvm::Type *dtorTy = CGF.DefaultPtrTy;
29252925

29262926
// Preserve address space of addr.
29272927
auto AddrAS = addr ? addr->getType()->getPointerAddressSpace() : 0;
@@ -5035,7 +5035,7 @@ static void InitCatchParam(CodeGenFunction &CGF,
50355035
auto catchRD = CatchType->getAsCXXRecordDecl();
50365036
CharUnits caughtExnAlignment = CGF.CGM.getClassPointerAlignment(catchRD);
50375037

5038-
llvm::Type *PtrTy = CGF.UnqualPtrTy; // addrspace 0 ok
5038+
llvm::Type *PtrTy = CGF.DefaultPtrTy;
50395039

50405040
// Check for a copy expression. If we don't have a copy expression,
50415041
// that means a trivial copy is okay.
@@ -5244,7 +5244,7 @@ void XLCXXABI::registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,
52445244
llvm::FunctionCallee Dtor,
52455245
llvm::Constant *Addr) {
52465246
if (D.getTLSKind() != VarDecl::TLS_None) {
5247-
llvm::PointerType *PtrTy = CGF.UnqualPtrTy;
5247+
llvm::PointerType *PtrTy = CGF.DefaultPtrTy;
52485248

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

0 commit comments

Comments
 (0)