llvm-project
7370091a - [mlir][test-ir-visitors] Fix noSkipBlockErasure crash with block args used across blocks (#183828)

Commit
95 days ago
[mlir][test-ir-visitors] Fix noSkipBlockErasure crash with block args used across blocks (#183828) The noSkipBlockErasure callback in TestVisitors.cpp dropped uses of op results within the same region before erasing a block, but did not drop uses of the block's own arguments (e.g. function entry block arguments). When the block was subsequently erased its block arguments were destroyed while their use-lists were still non-empty, triggering the assertion in IRObjectWithUseList::~IRObjectWithUseList(). Fix this by also iterating over the block's arguments and dropping any uses that belong to the same parent region. This mirrors the existing logic for op result uses and makes the block-erasure walk handle IRs where function arguments are consumed by ops in sibling blocks. Also replace `block->front().getParentRegion()` with `block->getParent()` for robustness (avoids UB when the block has no ops). Add a regression test based on the reproducer from https://github.com/llvm/llvm-project/issues/182996. Fixes #182996
Author
Parents
Loading