diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -646,8 +646,9 @@ StringRef name = op->getName().getStringRef(); if (name.startswith((defaultDialect + ".").str())) name = name.drop_front(defaultDialect.size() + 1); - // TODO: remove this special case. - else if (name.startswith("std.")) + // TODO: remove this special case (and update test/IR/parser.mlir) + else if ((defaultDialect.empty() || defaultDialect == "builtin") && + name.startswith("std.")) name = name.drop_front(4); p.getStream() << name; } diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir --- a/mlir/test/IR/parser.mlir +++ b/mlir/test/IR/parser.mlir @@ -1312,7 +1312,7 @@ // operations like `test.default_dialect` can define a default dialect // used in nested region. // CHECK-LABEL: func @default_dialect -func @default_dialect() { +func @default_dialect(%bool : i1) { test.default_dialect { // The test dialect is the default in this region, the following two // operations are parsed identically. @@ -1324,8 +1324,17 @@ // example. // CHECK: "test.op_with_attr"() {test.attr = "test.value"} : () -> () "test.op_with_attr"() {test.attr = "test.value"} : () -> () + + // TODO: remove this after removing the special casing for std in the printer. + // Verify that operations in the standard dialect keep the `std.` prefix. + // CHECK: std.assert + assert %bool, "Assertion" "test.terminator"() : ()->() } + // The same operation outside of the region does not have an std. prefix. + // CHECK-NOT: std.assert + // CHECK: assert + assert %bool, "Assertion" return }