Skip to content

Commit 647aa66

Browse files
[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.)
1 parent 83272a4 commit 647aa66

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,9 @@ class GPULaunchLowering : public ConvertOpToLLVMPattern<gpu::LaunchFuncOp> {
269269
copyInfo.push_back(info);
270270
}
271271
// Create a call to the kernel and copy the data back.
272-
rewriter.replaceOpWithNewOp<LLVM::CallOp>(op, kernelFunc,
273-
ArrayRef<Value>());
272+
Operation *callOp = rewriter.replaceOpWithNewOp<LLVM::CallOp>(
273+
op, kernelFunc, ArrayRef<Value>());
274+
rewriter.setInsertionPointAfter(callOp);
274275
for (CopyInfo info : copyInfo)
275276
copy(loc, info.src, info.dst, info.size, rewriter);
276277
return success();

0 commit comments

Comments
 (0)