[Mlir-commits] [mlir] 647aa66 - [mlir][SPIRVToLLVM] Set valid insertion point after op erasure (#146551)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jul 2 00:25:27 PDT 2025


Author: Matthias Springer
Date: 2025-07-02T09:25:24+02:00
New Revision: 647aa6616fa5fee8770e3ea041b7df391050fa51

URL: https://github.com/llvm/llvm-project/commit/647aa6616fa5fee8770e3ea041b7df391050fa51
DIFF: https://github.com/llvm/llvm-project/commit/647aa6616fa5fee8770e3ea041b7df391050fa51.diff

LOG: [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.)

Added: 
    

Modified: 
    mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp

Removed: 
    


################################################################################
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();


        


More information about the Mlir-commits mailing list