[Mlir-commits] [mlir] 04644a9 - [mlir] Fixed ordering of pass statistics.
Slava Zakharin
llvmlistbot at llvm.org
Tue Jul 19 15:57:32 PDT 2022
Author: Slava Zakharin
Date: 2022-07-19T15:52:02-07:00
New Revision: 04644a9e55161c09e100b35919499cd087315255
URL: https://github.com/llvm/llvm-project/commit/04644a9e55161c09e100b35919499cd087315255
DIFF: https://github.com/llvm/llvm-project/commit/04644a9e55161c09e100b35919499cd087315255.diff
LOG: [mlir] Fixed ordering of pass statistics.
The change makes sure the plain C string statistics names
are properly ordered.
Differential Revision: https://reviews.llvm.org/D130122
Added:
Modified:
mlir/lib/Pass/PassStatistics.cpp
mlir/test/Pass/pipeline-stats.mlir
mlir/test/lib/Pass/TestPassManager.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp
index 4c14711a0a968..4dfb9257abb42 100644
--- a/mlir/lib/Pass/PassStatistics.cpp
+++ b/mlir/lib/Pass/PassStatistics.cpp
@@ -33,11 +33,10 @@ static void printPassEntry(raw_ostream &os, unsigned indent, StringRef pass,
return;
// Make sure to sort the statistics by name.
- llvm::array_pod_sort(stats.begin(), stats.end(),
- [](const auto *lhs, const auto *rhs) {
- return llvm::array_pod_sort_comparator<const char *>(
- &lhs->name, &rhs->name);
- });
+ llvm::array_pod_sort(
+ stats.begin(), stats.end(), [](const auto *lhs, const auto *rhs) {
+ return StringRef{lhs->name}.compare(StringRef{rhs->name});
+ });
// Collect the largest name and value length from each of the statistics.
size_t largestName = 0, largestValue = 0;
diff --git a/mlir/test/Pass/pipeline-stats.mlir b/mlir/test/Pass/pipeline-stats.mlir
index 27335601b98b0..e71cb69fa99af 100644
--- a/mlir/test/Pass/pipeline-stats.mlir
+++ b/mlir/test/Pass/pipeline-stats.mlir
@@ -5,14 +5,17 @@
// LIST: Pass statistics report
// LIST: TestStatisticPass
// LIST-NEXT: (S) {{0|8}} num-ops - Number of operations counted
+// LIST-NEXT: (S) {{0|8}} num-ops2 - Number of operations counted one more time
// LIST-NOT: Verifier
// PIPELINE: Pass statistics report
// PIPELINE: 'func.func' Pipeline
// PIPELINE-NEXT: TestStatisticPass
// PIPELINE-NEXT: (S) {{0|4}} num-ops - Number of operations counted
+// PIPELINE-NEXT: (S) {{0|4}} num-ops2 - Number of operations counted one more time
// PIPELINE-NEXT: TestStatisticPass
// PIPELINE-NEXT: (S) {{0|4}} num-ops - Number of operations counted
+// PIPELINE-NEXT: (S) {{0|4}} num-ops2 - Number of operations counted one more time
func.func @foo() {
return
diff --git a/mlir/test/lib/Pass/TestPassManager.cpp b/mlir/test/lib/Pass/TestPassManager.cpp
index a61cfacb7cb09..b22bcaf2db44a 100644
--- a/mlir/test/lib/Pass/TestPassManager.cpp
+++ b/mlir/test/lib/Pass/TestPassManager.cpp
@@ -172,10 +172,17 @@ struct TestStatisticPass
StringRef getArgument() const final { return "test-stats-pass"; }
StringRef getDescription() const final { return "Test pass statistics"; }
+ // Use a couple of statistics to verify their ordering
+ // in the print out. The statistics are registered in the order
+ // of construction, so put "num-ops2" before "num-ops" and
+ // make sure that the order is reversed.
+ Statistic opCountDuplicate{this, "num-ops2",
+ "Number of operations counted one more time"};
Statistic opCount{this, "num-ops", "Number of operations counted"};
void runOnOperation() final {
getOperation()->walk([&](Operation *) { ++opCount; });
+ getOperation()->walk([&](Operation *) { ++opCountDuplicate; });
}
};
} // namespace
More information about the Mlir-commits
mailing list