Fix crash with segmentation fault caused by setting a parent operator
that is not func::FuncOp with sparse_tensor SortOp.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp | ||
---|---|---|
1023 ↗ | (On Diff #496834) | Thanks for filing the bug and looking into this. The code crashes since the rewriting indeed assumes to find a func op during codegen, in particular auto insertPoint = op->template getParentOfType<func::FuncOp>(); during SparseBufferRewriting. However, it seems we need to fix this at the rewriting level, not in verification of the op (which is really a user facing validation). |
Since matchAndRewriteSortOp was already getting the insertPoint, it seems perfectly reasonable to have the function return failure if it can't do so. I also like that it catches the error exactly where it is introduced: if we changed the function to compute insertPoint differently, then the check is still valid (and if we change the function to not compute insertPoint at all, then it's also clear that we should remove the check).
Thanks :)