From 647aa6616fa5fee8770e3ea041b7df391050fa51 Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Wed, 2 Jul 2025 09:25:24 +0200 Subject: [PATCH] [mlir][SPIRVToLLVM] Set valid insertion point after op erasure (#146551) 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. (`ConversionPatternRewriter` will start behaving more like a "normal" rewriter.) --- .../Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp index 0e9eb9799c3e..2a87f7864348 100644 --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp @@ -269,8 +269,9 @@ class GPULaunchLowering : public ConvertOpToLLVMPattern { copyInfo.push_back(info); } // Create a call to the kernel and copy the data back. - rewriter.replaceOpWithNewOp(op, kernelFunc, - ArrayRef()); + Operation *callOp = rewriter.replaceOpWithNewOp( + op, kernelFunc, ArrayRef()); + rewriter.setInsertionPointAfter(callOp); for (CopyInfo info : copyInfo) copy(loc, info.src, info.dst, info.size, rewriter); return success();