[clang] 8a19af5 - [Clang] Remove uses of PointerType::getWithSamePointeeType (NFC)
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 12 03:18:37 PDT 2023
Author: Nikita Popov
Date: 2023-06-12T12:18:28+02:00
New Revision: 8a19af513d549c173b5919fe697828c84cecc396
URL: https://github.com/llvm/llvm-project/commit/8a19af513d549c173b5919fe697828c84cecc396
DIFF: https://github.com/llvm/llvm-project/commit/8a19af513d549c173b5919fe697828c84cecc396.diff
LOG: [Clang] Remove uses of PointerType::getWithSamePointeeType (NFC)
No longer relevant with opaque pointers.
Added:
Modified:
clang/lib/CodeGen/CGAtomic.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/TargetInfo.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index e2d23a7252613..95f943d4bd67f 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -1097,8 +1097,7 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
if (AS == LangAS::opencl_generic)
return V;
auto DestAS = getContext().getTargetAddressSpace(LangAS::opencl_generic);
- auto T = llvm::cast<llvm::PointerType>(V->getType());
- auto *DestType = llvm::PointerType::getWithSamePointeeType(T, DestAS);
+ auto *DestType = llvm::PointerType::get(getLLVMContext(), DestAS);
return getTargetHooks().performAddrSpaceCast(
*this, V, AS, LangAS::opencl_generic, DestType, false);
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index d39131828c066..8bb8e2bb3969e 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5130,9 +5130,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
I->copyInto(*this, AI);
} else {
// Skip the extra memcpy call.
- auto *T = llvm::PointerType::getWithSamePointeeType(
- cast<llvm::PointerType>(V->getType()),
- CGM.getDataLayout().getAllocaAddrSpace());
+ auto *T = llvm::PointerType::get(
+ CGM.getLLVMContext(), CGM.getDataLayout().getAllocaAddrSpace());
llvm::Value *Val = getTargetHooks().performAddrSpaceCast(
*this, V, LangAS::Default, CGM.getASTAllocaAddressSpace(), T,
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 3238c31d2451f..8a71289270e28 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2132,8 +2132,8 @@ void CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
if (SlotAS != ThisAS) {
unsigned TargetThisAS = getContext().getTargetAddressSpace(ThisAS);
- llvm::Type *NewType = llvm::PointerType::getWithSamePointeeType(
- This.getType(), TargetThisAS);
+ llvm::Type *NewType =
+ llvm::PointerType::get(getLLVMContext(), TargetThisAS);
ThisPtr = getTargetHooks().performAddrSpaceCast(*this, This.getPointer(),
ThisAS, SlotAS, NewType);
}
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 04e42153519ae..bf5013e521097 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -199,8 +199,8 @@ void CodeGenFunction::EmitCXXGlobalVarDeclInit(const VarDecl &D,
unsigned ActualAddrSpace = GV->getAddressSpace();
llvm::Constant *DeclPtr = GV;
if (ActualAddrSpace != ExpectedAddrSpace) {
- llvm::PointerType *PTy = llvm::PointerType::getWithSamePointeeType(
- GV->getType(), ExpectedAddrSpace);
+ llvm::PointerType *PTy =
+ llvm::PointerType::get(getLLVMContext(), ExpectedAddrSpace);
DeclPtr = llvm::ConstantExpr::getAddrSpaceCast(DeclPtr, PTy);
}
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a5a5ed1c98ae0..099c706e84ab2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1918,8 +1918,7 @@ bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
llvm::Constant *AddrInAS0 = Addr;
if (Addr->getAddressSpace() != 0)
AddrInAS0 = llvm::ConstantExpr::getAddrSpaceCast(
- Addr, llvm::PointerType::getWithSamePointeeType(
- cast<llvm::PointerType>(Addr->getType()), 0));
+ Addr, llvm::PointerType::get(CGM.getLLVMContext(), 0));
CtorCGF.EmitAnyExprToMem(Init,
Address(AddrInAS0, Addr->getValueType(),
CGM.getContext().getDeclAlign(VD)),
@@ -1969,8 +1968,7 @@ bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
llvm::Constant *AddrInAS0 = Addr;
if (Addr->getAddressSpace() != 0)
AddrInAS0 = llvm::ConstantExpr::getAddrSpaceCast(
- Addr, llvm::PointerType::getWithSamePointeeType(
- cast<llvm::PointerType>(Addr->getType()), 0));
+ Addr, llvm::PointerType::get(CGM.getLLVMContext(), 0));
DtorCGF.emitDestroy(Address(AddrInAS0, Addr->getValueType(),
CGM.getContext().getDeclAlign(VD)),
ASTTy, DtorCGF.getDestroyer(ASTTy.isDestructedType()),
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 84907bdd37630..cf151025eac5d 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3083,17 +3083,16 @@ CGOpenMPRuntimeGPU::getParameterAddress(CodeGenFunction &CGF,
unsigned NativePointeeAddrSpace =
CGF.getTypes().getTargetAddressSpace(NativePointeeTy);
QualType TargetTy = TargetParam->getType();
- llvm::Value *TargetAddr = CGF.EmitLoadOfScalar(
- LocalAddr, /*Volatile=*/false, TargetTy, SourceLocation());
+ llvm::Value *TargetAddr = CGF.EmitLoadOfScalar(LocalAddr, /*Volatile=*/false,
+ TargetTy, SourceLocation());
// First cast to generic.
TargetAddr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
- TargetAddr, llvm::PointerType::getWithSamePointeeType(
- cast<llvm::PointerType>(TargetAddr->getType()), /*AddrSpace=*/0));
+ TargetAddr,
+ llvm::PointerType::get(CGF.getLLVMContext(), /*AddrSpace=*/0));
// Cast from generic to native address space.
TargetAddr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
- TargetAddr, llvm::PointerType::getWithSamePointeeType(
- cast<llvm::PointerType>(TargetAddr->getType()),
- NativePointeeAddrSpace));
+ TargetAddr,
+ llvm::PointerType::get(CGF.getLLVMContext(), NativePointeeAddrSpace));
Address NativeParamAddr = CGF.CreateMemTemp(NativeParamType);
CGF.EmitStoreOfScalar(TargetAddr, NativeParamAddr, /*Volatile=*/false,
NativeParamType);
@@ -3118,8 +3117,8 @@ void CGOpenMPRuntimeGPU::emitOutlinedFunctionCall(
continue;
}
llvm::Value *TargetArg = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
- NativeArg, llvm::PointerType::getWithSamePointeeType(
- cast<llvm::PointerType>(NativeArg->getType()), /*AddrSpace*/ 0));
+ NativeArg,
+ llvm::PointerType::get(CGF.getLLVMContext(), /*AddrSpace*/ 0));
TargetArgs.emplace_back(
CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(TargetArg, TargetType));
}
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index a0a6299039db3..f6601638e62a1 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2499,7 +2499,7 @@ Address CodeGenFunction::EmitFieldAnnotations(const FieldDecl *D,
auto *PTy = dyn_cast<llvm::PointerType>(VTy);
unsigned AS = PTy ? PTy->getAddressSpace() : 0;
llvm::PointerType *IntrinTy =
- llvm::PointerType::getWithSamePointeeType(CGM.Int8PtrTy, AS);
+ llvm::PointerType::get(CGM.getLLVMContext(), AS);
llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation,
{IntrinTy, CGM.ConstGlobalsPtrTy});
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index fb0a7158d1a39..3b9cce40b2fb6 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -9198,7 +9198,7 @@ class AMDGPUABIInfo final : public DefaultABIInfo {
// Single value types.
auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(Ty);
if (PtrTy && PtrTy->getAddressSpace() == FromAS)
- return llvm::PointerType::getWithSamePointeeType(PtrTy, ToAS);
+ return llvm::PointerType::get(Ty->getContext(), ToAS);
return Ty;
}
@@ -9595,8 +9595,8 @@ llvm::Constant *AMDGPUTargetCodeGenInfo::getNullPointer(
return llvm::ConstantPointerNull::get(PT);
auto &Ctx = CGM.getContext();
- auto NPT = llvm::PointerType::getWithSamePointeeType(
- PT, Ctx.getTargetAddressSpace(LangAS::opencl_generic));
+ auto NPT = llvm::PointerType::get(
+ PT->getContext(), Ctx.getTargetAddressSpace(LangAS::opencl_generic));
return llvm::ConstantExpr::getAddrSpaceCast(
llvm::ConstantPointerNull::get(NPT), PT);
}
@@ -10578,7 +10578,7 @@ ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty) const {
auto GlobalAS = getContext().getTargetAddressSpace(LangAS::cuda_device);
auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(LTy);
if (PtrTy && PtrTy->getAddressSpace() == DefaultAS) {
- LTy = llvm::PointerType::getWithSamePointeeType(PtrTy, GlobalAS);
+ LTy = llvm::PointerType::get(PtrTy->getContext(), GlobalAS);
return ABIArgInfo::getDirect(LTy, 0, nullptr, false);
}
More information about the cfe-commits
mailing list