[Mlir-commits] [mlir] [mlir][SPIRVToLLVM] Set valid insertion point after op erasure (PR #146551)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Jul 1 08:43:07 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-spirv
@llvm/pr-subscribers-mlir
Author: Matthias Springer (matthias-springer)
<details>
<summary>Changes</summary>
Erasing/replacing an op, which is also the current insertion point, invalidates the insertion point. Explicitly set the insertion point, so that `copy` does not crash after the One-Shot Dialect Conversion refactoring.
---
Full diff: https://github.com/llvm/llvm-project/pull/146551.diff
1 Files Affected:
- (modified) mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp (+3-2)
``````````diff
diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
index 0e9eb9799c3e0..2a87f78643486 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
@@ -269,8 +269,9 @@ class GPULaunchLowering : public ConvertOpToLLVMPattern<gpu::LaunchFuncOp> {
copyInfo.push_back(info);
}
// Create a call to the kernel and copy the data back.
- rewriter.replaceOpWithNewOp<LLVM::CallOp>(op, kernelFunc,
- ArrayRef<Value>());
+ Operation *callOp = rewriter.replaceOpWithNewOp<LLVM::CallOp>(
+ op, kernelFunc, ArrayRef<Value>());
+ rewriter.setInsertionPointAfter(callOp);
for (CopyInfo info : copyInfo)
copy(loc, info.src, info.dst, info.size, rewriter);
return success();
``````````
</details>
https://github.com/llvm/llvm-project/pull/146551
More information about the Mlir-commits
mailing list