Skip to content

Commit

Permalink
[CIR][FlattenCFG] Fix rewrite API misuse (#1163)
Browse files Browse the repository at this point in the history
We need to perform all erasures via the rewrite API instead of directly
for the framework to work correctly. This was detected by a combination
of `-DMLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON` [1] and ASAN.

[1]
https://mlir.llvm.org/getting_started/Debugging/#detecting-invalid-api-usage
  • Loading branch information
smeenai authored Nov 25, 2024
1 parent f00568c commit 9db508a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class CIRTryOpFlattening : public mlir::OpRewritePattern<cir::TryOp> {
if (!callOp.getCleanup().empty()) {
mlir::Block *cleanupBlock = &callOp.getCleanup().getBlocks().back();
auto cleanupYield = cast<cir::YieldOp>(cleanupBlock->getTerminator());
cleanupYield->erase();
rewriter.eraseOp(cleanupYield);
rewriter.mergeBlocks(cleanupBlock, landingPadBlock);
rewriter.setInsertionPointToEnd(landingPadBlock);
}
Expand Down

0 comments on commit 9db508a

Please sign in to comment.