Skip to content

Commit

Permalink
Fix to remove usage of deprecated template (#1408)
Browse files Browse the repository at this point in the history
Fix #1407
  • Loading branch information
rjodinchr authored Oct 17, 2024
1 parent 4dc6167 commit 022d172
Show file tree
Hide file tree
Showing 19 changed files with 537 additions and 424 deletions.
4 changes: 2 additions & 2 deletions lib/AllocateDescriptorsPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ bool clspv::AllocateDescriptorsPass::AllocateLiteralSamplerDescriptors(
outs() << " translate literal sampler " << *const_val << " to ("
<< descriptor_set << "," << binding << ")\n";
}
auto *new_call =
CallInst::Create(var_fn, args, "", dyn_cast<Instruction>(call));
auto *new_call = CallInst::Create(
var_fn, args, "", dyn_cast<Instruction>(call)->getIterator());
call->replaceAllUsesWith(new_call);
call->eraseFromParent();
}
Expand Down
11 changes: 6 additions & 5 deletions lib/ClusterConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ clspv::ClusterModuleScopeConstantVars::run(Module &M, ModuleAnalysisManager &) {
Value *indices[] = {zero};
auto *ptr_gep = Builder.CreateInBoundsGEP(clustered_ptr_ty,
ptr_to_ptr, indices);
auto *clustered_ptr_val =
new LoadInst(clustered_ptr_ty, ptr_gep, "", InsertBefore);
auto *clustered_ptr_val = new LoadInst(
clustered_ptr_ty, ptr_gep, "", InsertBefore->getIterator());
auto *clustered_ptr = CastInst::Create(
Instruction::CastOps::IntToPtr, clustered_ptr_val, ptr_type,
"", InsertBefore);
"", InsertBefore->getIterator());
PointeeType = type;
Ptr = clustered_ptr;
} else {
Expand All @@ -186,15 +186,16 @@ clspv::ClusterModuleScopeConstantVars::run(Module &M, ModuleAnalysisManager &) {
getTypeAndPtr(PointeeType, Ptr, InsertBefore);
Instruction *gep = GetElementPtrInst::CreateInBounds(
PointeeType, Ptr, {zero, Builder.getInt32(index)}, "",
InsertBefore);
InsertBefore->getIterator());
phi->setIncomingValue(i, gep);
}
} else {
Type *PointeeType;
Value *Ptr;
getTypeAndPtr(PointeeType, Ptr, inst);
Instruction *gep = GetElementPtrInst::CreateInBounds(
PointeeType, Ptr, {zero, Builder.getInt32(index)}, "", inst);
PointeeType, Ptr, {zero, Builder.getInt32(index)}, "",
inst->getIterator());
user->replaceUsesOfWith(GV, gep);
}
} else {
Expand Down
5 changes: 3 additions & 2 deletions lib/FixupStructuredCFGPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ void clspv::FixupStructuredCFGPass::isolateContinue(
// exit.
phi->addIncoming(phi_values[0], new_exit);
} else if (!phi_values.empty()) {
auto new_phi = PHINode::Create(phi->getType(), phi_values.size(),
"", new_exit->getTerminator());
auto new_phi =
PHINode::Create(phi->getType(), phi_values.size(), "",
new_exit->getTerminator()->getIterator());
for (size_t i = 0; i < phi_values.size(); ++i) {
new_phi->addIncoming(phi_values[i], loop_preds[i]);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/MultiVersionUBOFunctionsPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ void clspv::MultiVersionUBOFunctionsPass::SpecializeCall(
for (auto extra : extra_args) {
new_args.push_back(extra);
}
auto *replacement = CallInst::Create(clone, new_args, "", call);
auto *replacement =
CallInst::Create(clone, new_args, "", call->getIterator());
call->replaceAllUsesWith(replacement);
call->eraseFromParent();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/PrintfPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void clspv::PrintfPass::DefinePrintfInstance(Module &M, CallInst *CI,
assert(Func);
Func->setIsNewDbgInfoFormat(true);

auto *NewCI = CallInst::Create(Func, NewArgs, "", CI);
auto *NewCI = CallInst::Create(Func, NewArgs, "", CI->getIterator());
CI->replaceAllUsesWith(NewCI);
CI->eraseFromParent();

Expand Down
7 changes: 4 additions & 3 deletions lib/PushConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ void RedeclareGlobalPushConstants(Module &M, StructType *mangled_struct_ty,
for (auto iter = gep->idx_begin(); iter != gep->idx_end(); ++iter) {
indices.push_back(*iter);
}
auto new_gep = GetElementPtrInst::Create(push_constant_ty, new_GV,
indices, "", gep);
auto new_gep = GetElementPtrInst::Create(
push_constant_ty, new_GV, indices, "", gep->getIterator());
new_gep->setIsInBounds(gep->isInBounds());
gep->replaceAllUsesWith(new_gep);
gep->eraseFromParent();
Expand Down Expand Up @@ -329,7 +329,8 @@ void RedeclareGlobalPushConstants(Module &M, StructType *mangled_struct_ty,
push_constant_ty, new_GV, indices, gep_operator->isInBounds());
user->replaceAllUsesWith(new_gep);
} else if (auto load = dyn_cast<LoadInst>(user)) {
auto new_load = new LoadInst(load->getType(), new_GV, "", load);
auto new_load =
new LoadInst(load->getType(), new_GV, "", load->getIterator());
load->replaceAllUsesWith(new_load);
load->eraseFromParent();
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/RemoveUnusedArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ void clspv::RemoveUnusedArguments::removeUnusedParameters(
args.push_back(call->getOperand(i));
}
}
CallInst *new_call =
CallInst::Create(new_type, new_function, args, "", call);
CallInst *new_call = CallInst::Create(new_type, new_function, args, "",
call->getIterator());
new_call->takeName(call);
call->replaceAllUsesWith(new_call);
call->eraseFromParent();
Expand Down
15 changes: 8 additions & 7 deletions lib/ReplaceLLVMIntrinsicsPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,9 @@ bool clspv::ReplaceLLVMIntrinsicsPass::replaceMemset(Module &M) {
auto PointeeTy = clspv::InferType(NewArg, M.getContext(), &type_cache);
if (PointeeTy == nullptr) {
PointeeTy = UpdateTy(M.getContext(), NumBytes);
NewArg = GetElementPtrInst::Create(
PointeeTy, NewArg, {ConstantInt::get(I32Ty, 0)}, "", CI);
NewArg = GetElementPtrInst::Create(PointeeTy, NewArg,
{ConstantInt::get(I32Ty, 0)}, "",
CI->getIterator());
}
Type *NewArgTy = PointeeTy;
unsigned Unpacking = 0;
Expand All @@ -359,9 +360,9 @@ bool clspv::ReplaceLLVMIntrinsicsPass::replaceMemset(Module &M) {

for (uint32_t i = 0; i < num_stores; i++) {
Indices.back() = ConstantInt::get(I32Ty, i);
auto Ptr =
GetElementPtrInst::Create(NewArgTy, NewArg, Indices, "", CI);
new StoreInst(NullValue, Ptr, CI);
auto Ptr = GetElementPtrInst::Create(NewArgTy, NewArg, Indices, "",
CI->getIterator());
new StoreInst(NullValue, Ptr, CI->getIterator());
}

CI->eraseFromParent();
Expand Down Expand Up @@ -422,8 +423,8 @@ bool clspv::ReplaceLLVMIntrinsicsPass::replaceMemcpy(Module &M) {

// Avoid the builder for Src in order to prevent the folder from
// creating constant expressions for constant memcpys.
auto SrcElemPtr =
GetElementPtrInst::CreateInBounds(ElemTy, Src, Indices, "", CI);
auto SrcElemPtr = GetElementPtrInst::CreateInBounds(
ElemTy, Src, Indices, "", CI->getIterator());
auto Srci = Builder.CreateLoad(ElemTy, SrcElemPtr, Volatile);
auto DstElemPtr = Builder.CreateGEP(ElemTy, Dst, Indices);
Builder.CreateStore(Srci, DstElemPtr, Volatile);
Expand Down
Loading

0 comments on commit 022d172

Please sign in to comment.