summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Transforms
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-12-05 11:52:58 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-12-05 11:53:28 -0800
commit33a64540ade2dc9e860ddd6d4c1adbd1088e94c2 (patch)
treebb11bcc4bfc10ec5bf5ac0413607c8bfb2d1f4e7 /mlir/lib/Transforms
parent4d61a79db46e1cab990444cbcb84467faff7f042 (diff)
downloadbcm5719-llvm-33a64540ade2dc9e860ddd6d4c1adbd1088e94c2.tar.gz
bcm5719-llvm-33a64540ade2dc9e860ddd6d4c1adbd1088e94c2.zip
Add support for instance specific pass statistics.
Statistics are a way to keep track of what the compiler is doing and how effective various optimizations are. It is useful to see what optimizations are contributing to making a particular program run faster. Pass-instance specific statistics take this even further as you can see the effect of placing a particular pass at specific places within the pass pipeline, e.g. they could help answer questions like "what happens if I run CSE again here". Statistics can be added to a pass by simply adding members of type 'Pass::Statistics'. This class takes as a constructor arguments: the parent pass pointer, a name, and a description. Statistics can be dumped by the pass manager in a similar manner to how pass timing information is dumped, i.e. via PassManager::enableStatistics programmatically; or -pass-statistics and -pass-statistics-display via the command line pass manager options. Below is an example: struct MyPass : public OperationPass<MyPass> { Statistic testStat{this, "testStat", "A test statistic"}; void runOnOperation() { ... ++testStat; ... } }; $ mlir-opt -pass-pipeline='func(my-pass,my-pass)' foo.mlir -pass-statistics Pipeline Display: ===-------------------------------------------------------------------------=== ... Pass statistics report ... ===-------------------------------------------------------------------------=== 'func' Pipeline MyPass (S) 15 testStat - A test statistic MyPass (S) 6 testStat - A test statistic List Display: ===-------------------------------------------------------------------------=== ... Pass statistics report ... ===-------------------------------------------------------------------------=== MyPass (S) 21 testStat - A test statistic PiperOrigin-RevId: 284022014
Diffstat (limited to 'mlir/lib/Transforms')
-rw-r--r--mlir/lib/Transforms/CSE.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp
index 70eb69c2f9c..18f9fce5e46 100644
--- a/mlir/lib/Transforms/CSE.cpp
+++ b/mlir/lib/Transforms/CSE.cpp
@@ -124,6 +124,10 @@ struct CSE : public OperationPass<CSE> {
private:
/// Operations marked as dead and to be erased.
std::vector<Operation *> opsToErase;
+
+ /// Statistics for CSE.
+ Statistic numCSE{this, "num-cse'd", "Number of operations CSE'd"};
+ Statistic numDCE{this, "num-dce'd", "Number of operations trivially DCE'd"};
};
} // end anonymous namespace
@@ -143,6 +147,7 @@ LogicalResult CSE::simplifyOperation(ScopedMapTy &knownValues, Operation *op) {
// If the operation is already trivially dead just add it to the erase list.
if (op->use_empty()) {
opsToErase.push_back(op);
+ ++numDCE;
return success();
}
@@ -160,6 +165,8 @@ LogicalResult CSE::simplifyOperation(ScopedMapTy &knownValues, Operation *op) {
!op->getLoc().isa<UnknownLoc>()) {
existing->setLoc(op->getLoc());
}
+
+ ++numCSE;
return success();
}
OpenPOWER on IntegriCloud