[Mlir-commits] [mlir] 1ebf1af - [mlir][SymbolDCE] Track the number of symbols DCE'd

Nandor Licker llvmlistbot at llvm.org
Fri Mar 18 00:23:47 PDT 2022


Author: Nandor Licker
Date: 2022-03-18T09:23:02+02:00
New Revision: 1ebf1afb4ff4e99e7ba774614c648941cab1972c

URL: https://github.com/llvm/llvm-project/commit/1ebf1afb4ff4e99e7ba774614c648941cab1972c
DIFF: https://github.com/llvm/llvm-project/commit/1ebf1afb4ff4e99e7ba774614c648941cab1972c.diff

LOG: [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

Added: 
    

Modified: 
    mlir/include/mlir/Transforms/Passes.td
    mlir/lib/Transforms/SymbolDCE.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Transforms/Passes.td b/mlir/include/mlir/Transforms/Passes.td
index 8b9d2c45b7b57..54f4094c7b4e5 100644
--- a/mlir/include/mlir/Transforms/Passes.td
+++ b/mlir/include/mlir/Transforms/Passes.td
@@ -212,6 +212,10 @@ def SymbolDCE : Pass<"symbol-dce"> {
     information on `Symbols`.
   }];
   let constructor = "mlir::createSymbolDCEPass()";
+
+  let statistics = [
+    Statistic<"numDCE", "num-dce'd", "Number of symbols DCE'd">,
+  ];
 }
 
 def SymbolPrivatize : Pass<"symbol-privatize"> {

diff  --git a/mlir/lib/Transforms/SymbolDCE.cpp b/mlir/lib/Transforms/SymbolDCE.cpp
index 1169239099595..707e4bfff0d95 100644
--- a/mlir/lib/Transforms/SymbolDCE.cpp
+++ b/mlir/lib/Transforms/SymbolDCE.cpp
@@ -62,8 +62,10 @@ void SymbolDCE::runOnOperation() {
       return;
     for (auto &block : nestedSymbolTable->getRegion(0)) {
       for (Operation &op : llvm::make_early_inc_range(block)) {
-        if (isa<SymbolOpInterface>(&op) && !liveSymbols.count(&op))
+        if (isa<SymbolOpInterface>(&op) && !liveSymbols.count(&op)) {
           op.erase();
+          ++numDCE;
+        }
       }
     }
   });


        


More information about the Mlir-commits mailing list