Skip to content

Commit 374eb9d

Browse files
authored
Update after Instruction iterator-insertion deprecation (#2724)
Avoid deprecation warnings after LLVM commit 2f50b280dc8e ("[DebugInfo] Enable deprecation of iterator-insertion methods (#102608)", 2024-09-20).
1 parent dc1221c commit 374eb9d

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

lib/SPIRV/OCLToSPIRV.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,20 +444,23 @@ void OCLToSPIRVBase::visitCallNDRange(CallInst *CI, StringRef DemangledName) {
444444
// local work size
445445
// The arguments need to add missing members.
446446
for (size_t I = 1, E = CI->arg_size(); I != E; ++I)
447-
Mutator.mapArg(I, [=](Value *V) { return getScalarOrArray(V, Len, CI); });
447+
Mutator.mapArg(I, [=](Value *V) {
448+
return getScalarOrArray(V, Len, CI->getIterator());
449+
});
448450
switch (CI->arg_size()) {
449451
case 2: {
450452
// Has global work size.
451453
auto *T = Mutator.getArg(1)->getType();
452-
auto *C = getScalarOrArrayConstantInt(CI, T, Len, 0);
454+
auto *C = getScalarOrArrayConstantInt(CI->getIterator(), T, Len, 0);
453455
Mutator.appendArg(C);
454456
Mutator.appendArg(C);
455457
break;
456458
}
457459
case 3: {
458460
// Has global and local work size.
459461
auto *T = Mutator.getArg(1)->getType();
460-
Mutator.appendArg(getScalarOrArrayConstantInt(CI, T, Len, 0));
462+
Mutator.appendArg(
463+
getScalarOrArrayConstantInt(CI->getIterator(), T, Len, 0));
461464
break;
462465
}
463466
case 4: {
@@ -1158,7 +1161,7 @@ void OCLToSPIRVBase::visitCallToAddr(CallInst *CI, StringRef DemangledName) {
11581161
.mapArg(Mutator.arg_size() - 1,
11591162
[&](Value *V) {
11601163
return std::make_pair(
1161-
castToInt8Ptr(V, CI),
1164+
castToInt8Ptr(V, CI->getIterator()),
11621165
TypedPointerType::get(Type::getInt8Ty(V->getContext()),
11631166
SPIRAS_Generic));
11641167
})

lib/SPIRV/SPIRVInternal.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -801,13 +801,14 @@ Constant *getScalarOrVectorConstantInt(Type *T, uint64_t V,
801801
// an integer pointer type.
802802
/// \param Len is the length of the array.
803803
/// \param V is the value to fill the array.
804-
Value *getScalarOrArrayConstantInt(Instruction *P, Type *T, unsigned Len,
805-
uint64_t V, bool IsSigned = false);
804+
Value *getScalarOrArrayConstantInt(BasicBlock::iterator P, Type *T,
805+
unsigned Len, uint64_t V,
806+
bool IsSigned = false);
806807

807808
/// Get the array from GEP.
808809
/// \param V is a GEP whose pointer operand is a pointer to an array of size
809810
/// \param Size.
810-
Value *getScalarOrArray(Value *V, unsigned Size, Instruction *Pos);
811+
Value *getScalarOrArray(Value *V, unsigned Size, BasicBlock::iterator Pos);
811812

812813
void dumpUsers(Value *V, StringRef Prompt = "");
813814

@@ -920,7 +921,7 @@ std::string getSPIRVFriendlyIRFunctionName(const std::string &UniqName,
920921
PointerType *getInt8PtrTy(PointerType *T);
921922

922923
/// Cast a value to a i8* by inserting a cast instruction.
923-
Value *castToInt8Ptr(Value *V, Instruction *Pos);
924+
Value *castToInt8Ptr(Value *V, BasicBlock::iterator Pos);
924925

925926
template <> inline void SPIRVMap<std::string, Op, SPIRVOpaqueType>::init() {
926927
#define _SPIRV_OP(x) add(#x, OpType##x);

lib/SPIRV/SPIRVUtil.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,12 @@ CallInst *addCallInst(Module *M, StringRef FuncName, Type *RetTy,
10111011

10121012
auto *F = getOrCreateFunction(M, RetTy, getTypes(Args), FuncName, Mangle,
10131013
Attrs, TakeFuncName);
1014+
InsertPosition InsertPos(nullptr);
1015+
if (Pos)
1016+
InsertPos = Pos->getIterator();
10141017
// Cannot assign a Name to void typed values
1015-
auto *CI = CallInst::Create(F, Args, RetTy->isVoidTy() ? "" : InstName, Pos);
1018+
auto *CI =
1019+
CallInst::Create(F, Args, RetTy->isVoidTy() ? "" : InstName, InsertPos);
10161020
CI->setCallingConv(F->getCallingConv());
10171021
CI->setAttributes(F->getAttributes());
10181022
return CI;
@@ -1061,7 +1065,7 @@ PointerType *getInt8PtrTy(PointerType *T) {
10611065
return PointerType::get(T->getContext(), T->getAddressSpace());
10621066
}
10631067

1064-
Value *castToInt8Ptr(Value *V, Instruction *Pos) {
1068+
Value *castToInt8Ptr(Value *V, BasicBlock::iterator Pos) {
10651069
return CastInst::CreatePointerCast(
10661070
V, getInt8PtrTy(cast<PointerType>(V->getType())), "", Pos);
10671071
}
@@ -1453,7 +1457,7 @@ static SPIR::RefParamType transTypeDesc(Type *Ty,
14531457
return SPIR::RefParamType(new SPIR::PrimitiveType(SPIR::PRIMITIVE_INT));
14541458
}
14551459

1456-
Value *getScalarOrArray(Value *V, unsigned Size, Instruction *Pos) {
1460+
Value *getScalarOrArray(Value *V, unsigned Size, BasicBlock::iterator Pos) {
14571461
if (!V->getType()->isPointerTy())
14581462
return V;
14591463
Type *SourceTy;
@@ -1492,8 +1496,8 @@ Constant *getScalarOrVectorConstantInt(Type *T, uint64_t V, bool IsSigned) {
14921496
return nullptr;
14931497
}
14941498

1495-
Value *getScalarOrArrayConstantInt(Instruction *Pos, Type *T, unsigned Len,
1496-
uint64_t V, bool IsSigned) {
1499+
Value *getScalarOrArrayConstantInt(BasicBlock::iterator Pos, Type *T,
1500+
unsigned Len, uint64_t V, bool IsSigned) {
14971501
if (auto *IT = dyn_cast<IntegerType>(T)) {
14981502
assert(Len == 1 && "Invalid length");
14991503
return ConstantInt::get(IT, V, IsSigned);

0 commit comments

Comments
 (0)