Skip to content

Commit 1ebf1af

Browse files
committed
[mlir][SymbolDCE] Track the number of symbols DCE'd
Added a statistic counting the number of erased symbols. Differential Revision: https://reviews.llvm.org/D121930
1 parent c975668 commit 1ebf1af

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

mlir/include/mlir/Transforms/Passes.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ def SymbolDCE : Pass<"symbol-dce"> {
212212
information on `Symbols`.
213213
}];
214214
let constructor = "mlir::createSymbolDCEPass()";
215+
216+
let statistics = [
217+
Statistic<"numDCE", "num-dce'd", "Number of symbols DCE'd">,
218+
];
215219
}
216220

217221
def SymbolPrivatize : Pass<"symbol-privatize"> {

mlir/lib/Transforms/SymbolDCE.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ void SymbolDCE::runOnOperation() {
6262
return;
6363
for (auto &block : nestedSymbolTable->getRegion(0)) {
6464
for (Operation &op : llvm::make_early_inc_range(block)) {
65-
if (isa<SymbolOpInterface>(&op) && !liveSymbols.count(&op))
65+
if (isa<SymbolOpInterface>(&op) && !liveSymbols.count(&op)) {
6666
op.erase();
67+
++numDCE;
68+
}
6769
}
6870
}
6971
});

0 commit comments

Comments
 (0)