[Mlir-commits] [mlir] 618caf6 - [mlir] print-op-graph: StringMap=>map to stabilize iteration order

Fangrui Song llvmlistbot at llvm.org
Thu Feb 2 20:03:39 PST 2023


Author: Fangrui Song
Date: 2023-02-02T20:03:34-08:00
New Revision: 618caf6fcce17d6f1ca752604138fb234e781ff3

URL: https://github.com/llvm/llvm-project/commit/618caf6fcce17d6f1ca752604138fb234e781ff3
DIFF: https://github.com/llvm/llvm-project/commit/618caf6fcce17d6f1ca752604138fb234e781ff3.diff

LOG: [mlir] print-op-graph: StringMap=>map to stabilize iteration order

Added: 
    

Modified: 
    mlir/lib/Transforms/ViewOpGraph.cpp
    mlir/test/Transforms/print-op-graph.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp
index 186118b2e067a..bdefbe3d2abd5 100644
--- a/mlir/lib/Transforms/ViewOpGraph.cpp
+++ b/mlir/lib/Transforms/ViewOpGraph.cpp
@@ -13,11 +13,11 @@
 #include "mlir/IR/Operation.h"
 #include "mlir/Pass/Pass.h"
 #include "mlir/Support/IndentedOstream.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/GraphWriter.h"
-#include <utility>
+#include <map>
 #include <optional>
+#include <utility>
 
 namespace mlir {
 #define GEN_PASS_DEF_VIEWOPGRAPH
@@ -58,7 +58,7 @@ static std::string quoteString(const std::string &str) {
   return "\"" + str + "\"";
 }
 
-using AttributeMap = llvm::StringMap<std::string>;
+using AttributeMap = std::map<std::string, std::string>;
 
 namespace {
 
@@ -134,7 +134,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
   void emitAttrList(raw_ostream &os, const AttributeMap &map) {
     os << "[";
     interleaveComma(map, os, [&](const auto &it) {
-      os << this->attrStmt(it.getKey(), it.getValue());
+      os << this->attrStmt(it.first, it.second);
     });
     os << "]";
   }

diff  --git a/mlir/test/Transforms/print-op-graph.mlir b/mlir/test/Transforms/print-op-graph.mlir
index d36c4fcb340fd..3f8d483524780 100644
--- a/mlir/test/Transforms/print-op-graph.mlir
+++ b/mlir/test/Transforms/print-op-graph.mlir
@@ -20,8 +20,8 @@
 //       DFG:         v[[TEST_RET:.*]] [label = "test.return
 //       DFG:   v[[ARG0]] -> v[[TEST_BR]]
 //       DFG:   v[[CONST10]] -> v[[TEST_BR]]
-//       DFG:   v[[ANCHOR]] -> v[[TEST_RET]] [{{.*}}, ltail = [[CLUSTER_MERGE_BLOCKS]]]
-//       DFG:   v[[ANCHOR]] -> v[[TEST_RET]] [{{.*}}, ltail = [[CLUSTER_MERGE_BLOCKS]]]
+//       DFG:   v[[ANCHOR]] -> v[[TEST_RET]] [ltail = [[CLUSTER_MERGE_BLOCKS]], style = solid];
+//       DFG:   v[[ANCHOR]] -> v[[TEST_RET]] [ltail = [[CLUSTER_MERGE_BLOCKS]], style = solid];
 
 // CFG-LABEL: digraph G {
 //       CFG:   subgraph {{.*}} {
@@ -47,8 +47,8 @@
 //       CFG:   v[[C2]] -> v[[C3]]
 //       CFG:   v[[C3]] -> v[[C4]]
 //       CFG:   v[[C4]] -> v[[TEST_FUNC]]
-//       CFG:   v[[TEST_FUNC]] -> v[[ANCHOR]] [{{.*}}, lhead = [[CLUSTER_MERGE_BLOCKS]]]
-//       CFG:   v[[ANCHOR]] -> v[[TEST_RET]] [{{.*}}, ltail = [[CLUSTER_MERGE_BLOCKS]]]
+//       CFG:   v[[TEST_FUNC]] -> v[[ANCHOR]] [lhead = [[CLUSTER_MERGE_BLOCKS]], style = dashed];
+//       CFG:   v[[ANCHOR]] -> v[[TEST_RET]] [ltail = [[CLUSTER_MERGE_BLOCKS]], style = dashed];
 
 func.func @merge_blocks(%arg0: i32, %arg1 : i32) -> () {
   %0 = arith.constant dense<[[0, 1], [2, 3]]> : tensor<2x2xi32>


        


More information about the Mlir-commits mailing list