[mlir] DialectConversion: avoid double-free when rolling back op creation
Dialect conversion infrastructure may roll back op creation by erasing the operations in the reverse order of their creation. While this guarantees uses of values will be deleted before their definitions, this does not guarantee that a parent operation will not be deleted before its child. (This may happen in case of block inlining or if child operations, such as terminators, are created in the parent's `build` function before the parent itself.) Handle the parent/child relationship between ops by removing all child ops from the blocks before erasing the parent. The child ops remain live, detached from a block, and will be safely destroyed in their turn, which may come later than that of the parent. Differential Revision: https://reviews.llvm.org/D80134
Loading
Please register or sign in to comment