@@ -49,11 +49,6 @@ static std::string strFromOs(function_ref<void(raw_ostream &)> func) {
49
49
return buf;
50
50
}
51
51
52
- // / Escape special characters such as '\n' and quotation marks.
53
- static std::string escapeString (std::string str) {
54
- return strFromOs ([&](raw_ostream &os) { os.write_escaped (str); });
55
- }
56
-
57
52
// / Put quotation marks around a given string.
58
53
static std::string quoteString (const std::string &str) {
59
54
return " \" " + str + " \" " ;
@@ -169,8 +164,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
169
164
os.indent ();
170
165
// Emit invisible anchor node from/to which arrows can be drawn.
171
166
Node anchorNode = emitNodeStmt (" " , kShapeNone );
172
- os << attrStmt (" label" , quoteString (escapeString (std::move (label))))
173
- << " ;\n " ;
167
+ os << attrStmt (" label" , quoteString (label)) << " ;\n " ;
174
168
builder ();
175
169
os.unindent ();
176
170
os << " }\n " ;
@@ -288,8 +282,32 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
288
282
return str;
289
283
}
290
284
285
+ std::string getClusterLabel (Operation *op) {
286
+ return strFromOs ([&](raw_ostream &os) {
287
+ // Print operation name and type.
288
+ os << op->getName ();
289
+ if (printResultTypes) {
290
+ os << " : (" ;
291
+ std::string buf;
292
+ llvm::raw_string_ostream ss (buf);
293
+ interleaveComma (op->getResultTypes (), ss);
294
+ os << truncateString (buf) << " )" ;
295
+ }
296
+
297
+ // Print attributes.
298
+ if (printAttrs) {
299
+ os << " \\ l" ;
300
+ for (const NamedAttribute &attr : op->getAttrs ()) {
301
+ os << attr.getName ().getValue () << " : " ;
302
+ emitMlirAttr (os, attr.getValue ());
303
+ os << " \\ l" ;
304
+ }
305
+ }
306
+ });
307
+ }
308
+
291
309
// / Generate a label for an operation.
292
- std::string getLabel (Operation *op) {
310
+ std::string getRecordLabel (Operation *op) {
293
311
return strFromOs ([&](raw_ostream &os) {
294
312
os << " {" ;
295
313
@@ -369,9 +387,9 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
369
387
for (Region ®ion : op->getRegions ())
370
388
processRegion (region);
371
389
},
372
- getLabel (op));
390
+ getClusterLabel (op));
373
391
} else {
374
- node = emitNodeStmt (getLabel (op), kShapeNode ,
392
+ node = emitNodeStmt (getRecordLabel (op), kShapeNode ,
375
393
backgroundColors[op->getName ()].second );
376
394
}
377
395
0 commit comments