Skip to content

Commit 87590ce

Browse files
svenvhsys-ce-bb
authored andcommitted
Update calls to PointerType::get with opaque equivalent (#3107)
Update after llvm-project commit 146ad71 ("[IR] Deprecate PointerType::get/getUnqual pointee type overload (#134517)", 2025-04-06). Original commit: KhronosGroup/SPIRV-LLVM-Translator@2c6186986a285e2
1 parent b912eea commit 87590ce

File tree

8 files changed

+22
-20
lines changed

8 files changed

+22
-20
lines changed

llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,8 @@ LLVMToSPIRVDbgTran::transDbgTemplateParameter(const DITemplateParameter *TP) {
11271127
Constant *C = cast<ConstantAsMetadata>(TVVal)->getValue();
11281128
Ops[ValueIdx] = SPIRVWriter->transValue(C, nullptr)->getId();
11291129
} else {
1130-
SPIRVType *TyPtr = SPIRVWriter->transType(
1131-
PointerType::get(Type::getInt8Ty(M->getContext()), 0));
1130+
SPIRVType *TyPtr =
1131+
SPIRVWriter->transType(PointerType::get(M->getContext(), 0));
11321132
Ops[ValueIdx] = BM->addNullConstant(TyPtr)->getId();
11331133
}
11341134
}

llvm-spirv/lib/SPIRV/OCLToSPIRV.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,8 +1491,8 @@ void OCLToSPIRVBase::visitCallEnqueueKernel(CallInst *CI,
14911491
// If no event arguments in original call, add dummy ones
14921492
if (!HasEvents) {
14931493
Args.push_back(getInt32(M, 0)); // dummy num events
1494-
Value *Null = Constant::getNullValue(PointerType::get(
1495-
getSPIRVType(OpTypeDeviceEvent, true), SPIRAS_Generic));
1494+
Value *Null = Constant::getNullValue(
1495+
PointerType::get(CI->getContext(), SPIRAS_Generic));
14961496
Args.push_back(Null); // dummy wait events
14971497
Args.push_back(Null); // dummy ret event
14981498
}

llvm-spirv/lib/SPIRV/SPIRVBuiltinHelper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Value *BuiltinCallMutator::doConversion() {
9999

100100
// Sanitize the return type, in case it's a TypedPointerType.
101101
if (auto *TPT = dyn_cast<TypedPointerType>(ReturnTy))
102-
ReturnTy = PointerType::get(TPT->getElementType(), TPT->getAddressSpace());
102+
ReturnTy = PointerType::get(CI->getContext(), TPT->getAddressSpace());
103103

104104
CallInst *NewCall =
105105
Builder.Insert(addCallInst(CI->getModule(), FuncName, ReturnTy, Args,
@@ -238,7 +238,7 @@ Value *BuiltinCallHelper::addSPIRVCall(IRBuilder<> &Builder, spv::Op Opcode,
238238
const Twine &Name) {
239239
// Sanitize the return type, in case it's a TypedPointerType.
240240
if (auto *TPT = dyn_cast<TypedPointerType>(ReturnTy))
241-
ReturnTy = PointerType::get(TPT->getElementType(), TPT->getAddressSpace());
241+
ReturnTy = PointerType::get(Builder.getContext(), TPT->getAddressSpace());
242242

243243
// Copy the types into the mangling info.
244244
BuiltinFuncMangleInfo BtnInfo;
@@ -352,7 +352,7 @@ Type *BuiltinCallHelper::getSPIRVType(spv::Op TypeOpcode,
352352
STy = StructType::create(M->getContext(), FullName);
353353

354354
unsigned AddrSpace = getOCLOpaqueTypeAddrSpace(TypeOpcode);
355-
return UseRealType ? (Type *)PointerType::get(STy, AddrSpace)
355+
return UseRealType ? (Type *)PointerType::get(M->getContext(), AddrSpace)
356356
: TypedPointerType::get(STy, AddrSpace);
357357
}
358358

llvm-spirv/lib/SPIRV/SPIRVLowerBitCastToNonStandardType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ static Value *removeBitCasts(Value *OldValue, Type *NewTy, NFIRBuilder &Builder,
8686

8787
if (auto *ASCI = dyn_cast<AddrSpaceCastInst>(OldValue)) {
8888
Builder.SetInsertPoint(ASCI);
89-
Type *NewSrcTy = PointerType::get(NewTy, ASCI->getSrcAddressSpace());
89+
Type *NewSrcTy =
90+
PointerType::get(Builder.getContext(), ASCI->getSrcAddressSpace());
9091
Value *Pointer = removeBitCasts(ASCI->getPointerOperand(), NewSrcTy,
9192
Builder, InstsToErase);
9293
return RauwBitcasts(ASCI, Builder.CreateAddrSpaceCast(Pointer, NewTy));

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ Type *SPIRVToLLVM::transType(SPIRVType *T, bool UseTPT) {
383383
Type *ElementTy = transType(T->getPointerElementType(), UseTPT);
384384
if (UseTPT)
385385
return TypedPointerType::get(ElementTy, AS);
386-
return mapType(T, PointerType::get(ElementTy, AS));
386+
return mapType(T, PointerType::get(*Context, AS));
387387
}
388388
case OpTypeUntypedPointerKHR: {
389389
unsigned AS = SPIRSPIRVAddrSpaceMap::rmap(T->getPointerStorageClass());
@@ -463,7 +463,7 @@ Type *SPIRVToLLVM::transType(SPIRVType *T, bool UseTPT) {
463463
if (UseTPT) {
464464
return mapType(T, TypedPointerType::get(STy, 1));
465465
}
466-
return mapType(T, PointerType::get(STy, 1));
466+
return mapType(T, PointerType::get(*Context, 1));
467467
}
468468
case OpTypeVmeImageINTEL: {
469469
auto *VT = static_cast<SPIRVTypeVmeImageINTEL *>(T)->getImageType();
@@ -648,8 +648,7 @@ SPIRVToLLVM::transTypeVector(const std::vector<SPIRVType *> &BT, bool UseTPT) {
648648

649649
static Type *opaquifyType(Type *Ty) {
650650
if (auto *TPT = dyn_cast<TypedPointerType>(Ty)) {
651-
Ty = PointerType::get(opaquifyType(TPT->getElementType()),
652-
TPT->getAddressSpace());
651+
Ty = PointerType::get(Ty->getContext(), TPT->getAddressSpace());
653652
}
654653
return Ty;
655654
}
@@ -3034,7 +3033,8 @@ Value *SPIRVToLLVM::transFixedPointInst(SPIRVInstruction *BI, BasicBlock *BB) {
30343033
std::vector<Value *> Args;
30353034
Args.reserve(8);
30363035
if (RetTy->getIntegerBitWidth() > 64) {
3037-
llvm::PointerType *RetPtrTy = llvm::PointerType::get(RetTy, SPIRAS_Generic);
3036+
llvm::PointerType *RetPtrTy =
3037+
llvm::PointerType::get(*Context, SPIRAS_Generic);
30383038
Value *Alloca =
30393039
new AllocaInst(RetTy, M->getDataLayout().getAllocaAddrSpace(), "", BB);
30403040
Value *RetValPtr = new AddrSpaceCastInst(Alloca, RetPtrTy, "", BB);
@@ -3158,7 +3158,8 @@ Value *SPIRVToLLVM::transArbFloatInst(SPIRVInstruction *BI, BasicBlock *BB,
31583158
std::vector<Value *> Args;
31593159

31603160
if (RetTy->getIntegerBitWidth() > 64) {
3161-
llvm::PointerType *RetPtrTy = llvm::PointerType::get(RetTy, SPIRAS_Generic);
3161+
llvm::PointerType *RetPtrTy =
3162+
llvm::PointerType::get(*Context, SPIRAS_Generic);
31623163
ArgTys.push_back(RetPtrTy);
31633164
Value *Alloca =
31643165
new AllocaInst(RetTy, M->getDataLayout().getAllocaAddrSpace(), "", BB);
@@ -4505,8 +4506,7 @@ void SPIRVToLLVM::createCXXStructor(const char *ListName,
45054506

45064507
// Type of a structor entry: { i32, void ()*, i8* }
45074508
Type *PriorityTy = Type::getInt32Ty(*Context);
4508-
PointerType *CtorTy = PointerType::getUnqual(
4509-
FunctionType::get(Type::getVoidTy(*Context), false));
4509+
PointerType *CtorTy = PointerType::getUnqual(*Context);
45104510
PointerType *ComdatTy = PointerType::getUnqual(*Context);
45114511
StructType *StructorTy = StructType::get(PriorityTy, CtorTy, ComdatTy);
45124512

llvm-spirv/lib/SPIRV/SPIRVToOCL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ void SPIRVToOCLBase::visitCallGenericCastToPtrBuiltIn(CallInst *CI, Op OC) {
643643
Value *PtrArg = CI->getArgOperand(0);
644644
auto AddrSpace =
645645
static_cast<SPIRAddressSpace>(CI->getType()->getPointerAddressSpace());
646-
Type *NewTy = PointerType::get(PtrArg->getType(), AddrSpace);
646+
Type *NewTy = PointerType::get(CI->getContext(), AddrSpace);
647647
Value *ASC = Builder.CreateAddrSpaceCast(PtrArg, NewTy);
648648
CI->replaceAllUsesWith(ASC);
649649
CI->eraseFromParent();

llvm-spirv/lib/SPIRV/SPIRVToOCL20.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ CallInst *SPIRVToOCL20Base::mutateCommonAtomicArguments(CallInst *CI, Op OC) {
176176
if (auto *TypedPtrTy = dyn_cast<TypedPointerType>(PtrArgTy)) {
177177
if (TypedPtrTy->getAddressSpace() != SPIRAS_Generic) {
178178
Type *ElementTy = TypedPtrTy->getElementType();
179-
Type *FixedPtr = PointerType::get(ElementTy, SPIRAS_Generic);
179+
Type *FixedPtr = PointerType::get(CI->getContext(), SPIRAS_Generic);
180180
PtrArg = Builder.CreateAddrSpaceCast(PtrArg, FixedPtr,
181181
PtrArg->getName() + ".as");
182182
PtrArgTy = TypedPointerType::get(ElementTy, SPIRAS_Generic);
@@ -222,7 +222,8 @@ void SPIRVToOCL20Base::visitCallSPIRVAtomicCmpExchg(CallInst *CI) {
222222
[=](IRBuilder<> &Builder, Value *Expected) {
223223
Builder.CreateStore(Expected, PExpected);
224224
unsigned AddrSpc = SPIRAS_Generic;
225-
Type *PtrTyAS = PointerType::get(PExpected->getType(), AddrSpc);
225+
Type *PtrTyAS =
226+
PointerType::get(Expected->getContext(), AddrSpc);
226227
Value *V = Builder.CreateAddrSpaceCast(
227228
PExpected, PtrTyAS, PExpected->getName() + ".as");
228229
return std::make_pair(V, TypedPointerType::get(MemTy, AddrSpc));

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
637637
}
638638

639639
SPIRVType *LLVMToSPIRVBase::transPointerType(Type *ET, unsigned AddrSpc) {
640-
Type *T = PointerType::get(ET, AddrSpc);
640+
Type *T = PointerType::get(ET->getContext(), AddrSpc);
641641
if (ET->isFunctionTy() &&
642642
!BM->checkExtension(ExtensionID::SPV_INTEL_function_pointers,
643643
SPIRVEC_FunctionPointers, toString(T)))

0 commit comments

Comments
 (0)