llvm-project
25ec1baf - [CIR] Fix remaining (part 2) FlattenCFG rewriter contract violations (#192503)

Commit
30 days ago
[CIR] Fix remaining (part 2) FlattenCFG rewriter contract violations (#192503) Fix all 17 remaining MLIR expensive pattern check violations in CIRFlattenCFGPass. Found by MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON. Fingerprint violations (patterns modifying IR without notifying rewriter): - Use rewriter.replaceAllUsesWith() instead of direct replaceAllUsesWith() in replaceCallWithTryCall (tests: invoke-attrs.cpp, try-catch.cpp, try-catch-all-with-cleanup.cpp) - Use rewriter.modifyOpInPlace() for removeCleanupAttr() in TryOp flattening (tests: flatten-try-op.cir, flatten-cleanup-scope-eh.cir, flatten-throwing-in-cleanup.cir) IR verification failures (invalid intermediate IR after pattern application): - Expand nested op checks in Switch, Loop, CleanupScope, and TryOp flattening to include all structured CIR ops (ScopeOp, IfOp, TernaryOp, etc.), not just CleanupScopeOp. Break/continue/return inside nested structured ops creates invalid cross-region branches when the enclosing op hasn't been flattened yet (tests: switch.cir, loop.cpp, cleanup-scope-return-in-loop.cpp, partial-array-cleanup.cpp, switch.cpp, typeid.cpp, flatten-cleanup-scope-simple.cir, flatten-cleanup-scope-multi-exit.cir) - Relax CIR_ResumeOp ParentOneOf to include all structured ops, since cir.resume can temporarily appear inside them during flattening (test: new-delete-deactivation.cpp). Feels weird to do that, but extended documentation to account for. - Change loop region constraints from SizedRegion<1> to MinSizedRegion<1> for cond/step regions, since cleanup scope flattening inside these regions may create multiple blocks (test: loop-cond-cleanup.cpp)
Author
Parents
Loading