Skip to content

Commit 47b5ad2

Browse files
[mlir][CSE] Fix dominanceInfo analysis preservation (llvm#192279)
The CSE pass calls `markAnalysesPreserved<DominanceInfo, PostDominanceInfo>()` at the end. While CSE erases operations, it does not remove their corresponding dominator trees, causing them to be unnecessarily preserved in memory. This PR addresses the issue by explicitly calling invalidate within CSE to clean up the dominator trees for those erased operations.
1 parent 12a4adf commit 47b5ad2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mlir/lib/Transforms/CSE.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,13 @@ void CSEDriver::simplify(Operation *op, bool *changed) {
394394
for (auto &region : op->getRegions())
395395
simplifyRegion(knownValues, region);
396396

397-
/// Erase any operations that were marked as dead during simplification.
398-
for (auto *op : opsToErase)
397+
/// Erase any operations that were marked as dead during simplification, and
398+
/// remove their associated dominator trees.
399+
for (auto *op : opsToErase) {
400+
for (Region &region : op->getRegions())
401+
domInfo->invalidate(&region);
399402
rewriter.eraseOp(op);
403+
}
400404
if (changed)
401405
*changed = !opsToErase.empty();
402406

0 commit comments

Comments
 (0)