Skip to content

Commit aa902d1

Browse files
svenvhjsji
authored andcommitted
Update after Instruction iterator-insertion deprecation (#2724)
Avoid deprecation warnings after LLVM commit 2f50b28 ("[DebugInfo] Enable deprecation of iterator-insertion methods (#102608)", 2024-09-20). Original commit: KhronosGroup/SPIRV-LLVM-Translator@374eb9d8a4ee0ec
1 parent 75e05a4 commit aa902d1

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

llvm-spirv/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
})

llvm-spirv/lib/SPIRV/SPIRVInternal.h

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

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

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

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

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

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

llvm-spirv/lib/SPIRV/SPIRVUtil.cpp

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

10141014
auto *F = getOrCreateFunction(M, RetTy, getTypes(Args), FuncName, Mangle,
10151015
Attrs, TakeFuncName);
1016+
InsertPosition InsertPos(nullptr);
1017+
if (Pos)
1018+
InsertPos = Pos->getIterator();
10161019
// Cannot assign a Name to void typed values
1017-
auto *CI = CallInst::Create(F, Args, RetTy->isVoidTy() ? "" : InstName, Pos);
1020+
auto *CI =
1021+
CallInst::Create(F, Args, RetTy->isVoidTy() ? "" : InstName, InsertPos);
10181022
CI->setCallingConv(F->getCallingConv());
10191023
CI->setAttributes(F->getAttributes());
10201024
return CI;
@@ -1063,7 +1067,7 @@ PointerType *getInt8PtrTy(PointerType *T) {
10631067
return PointerType::get(T->getContext(), T->getAddressSpace());
10641068
}
10651069

1066-
Value *castToInt8Ptr(Value *V, Instruction *Pos) {
1070+
Value *castToInt8Ptr(Value *V, BasicBlock::iterator Pos) {
10671071
return CastInst::CreatePointerCast(
10681072
V, getInt8PtrTy(cast<PointerType>(V->getType())), "", Pos);
10691073
}
@@ -1455,7 +1459,7 @@ static SPIR::RefParamType transTypeDesc(Type *Ty,
14551459
return SPIR::RefParamType(new SPIR::PrimitiveType(SPIR::PRIMITIVE_INT));
14561460
}
14571461

1458-
Value *getScalarOrArray(Value *V, unsigned Size, Instruction *Pos) {
1462+
Value *getScalarOrArray(Value *V, unsigned Size, BasicBlock::iterator Pos) {
14591463
if (!V->getType()->isPointerTy())
14601464
return V;
14611465
Type *SourceTy;
@@ -1494,8 +1498,8 @@ Constant *getScalarOrVectorConstantInt(Type *T, uint64_t V, bool IsSigned) {
14941498
return nullptr;
14951499
}
14961500

1497-
Value *getScalarOrArrayConstantInt(Instruction *Pos, Type *T, unsigned Len,
1498-
uint64_t V, bool IsSigned) {
1501+
Value *getScalarOrArrayConstantInt(BasicBlock::iterator Pos, Type *T,
1502+
unsigned Len, uint64_t V, bool IsSigned) {
14991503
if (auto *IT = dyn_cast<IntegerType>(T)) {
15001504
assert(Len == 1 && "Invalid length");
15011505
return ConstantInt::get(IT, V, IsSigned);

0 commit comments

Comments
 (0)