[Mlir-commits] [mlir] 8800047 - [mlir-ir-printing] Prefix the dump message with the split marker(// -----)
River Riddle
llvmlistbot at llvm.org
Thu Jun 10 17:43:03 PDT 2021
Author: River Riddle
Date: 2021-06-10T17:34:50-07:00
New Revision: 8800047707a9cd86fb7143699af0e5564c28f4aa
URL: https://github.com/llvm/llvm-project/commit/8800047707a9cd86fb7143699af0e5564c28f4aa
DIFF: https://github.com/llvm/llvm-project/commit/8800047707a9cd86fb7143699af0e5564c28f4aa.diff
LOG: [mlir-ir-printing] Prefix the dump message with the split marker(// -----)
This allows for better interaction with tools (such as mlir-lsp-server), as it separates the IR into separate modules for consecutive dumps.
Differential Revision: https://reviews.llvm.org/D104073
Added:
Modified:
mlir/lib/Pass/IRPrinting.cpp
mlir/test/Pass/ir-printing.mlir
mlir/test/Pass/run-reproducer.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp
index b4074cc48d9e2..2094770b39c0e 100644
--- a/mlir/lib/Pass/IRPrinting.cpp
+++ b/mlir/lib/Pass/IRPrinting.cpp
@@ -98,7 +98,7 @@ static void printIR(Operation *op, bool printModuleScope, raw_ostream &out,
OpPrintingFlags flags) {
// Otherwise, check to see if we are not printing at module scope.
if (!printModuleScope)
- return op->print(out << "\n",
+ return op->print(out << " //----- //\n",
op->getBlock() ? flags.useLocalScope() : flags);
// Otherwise, we are printing at module scope.
@@ -106,7 +106,7 @@ static void printIR(Operation *op, bool printModuleScope, raw_ostream &out,
if (auto symbolName =
op->getAttrOfType<StringAttr>(SymbolTable::getSymbolAttrName()))
out << ": @" << symbolName.getValue();
- out << ")\n";
+ out << ") //----- //\n";
// Find the top-level operation.
auto *topLevelOp = op;
@@ -124,7 +124,7 @@ void IRPrinterInstrumentation::runBeforePass(Pass *pass, Operation *op) {
beforePassFingerPrints.try_emplace(pass, op);
config->printBeforeIfEnabled(pass, op, [&](raw_ostream &out) {
- out << formatv("// *** IR Dump Before {0} ***", pass->getName());
+ out << "// -----// IR Dump Before " << pass->getName();
printIR(op, config->shouldPrintAtModuleScope(), out,
config->getOpPrintingFlags());
out << "\n\n";
@@ -154,7 +154,7 @@ void IRPrinterInstrumentation::runAfterPass(Pass *pass, Operation *op) {
}
config->printAfterIfEnabled(pass, op, [&](raw_ostream &out) {
- out << formatv("// *** IR Dump After {0} ***", pass->getName());
+ out << "// -----// IR Dump After " << pass->getName();
printIR(op, config->shouldPrintAtModuleScope(), out,
config->getOpPrintingFlags());
out << "\n\n";
@@ -168,7 +168,7 @@ void IRPrinterInstrumentation::runAfterPassFailed(Pass *pass, Operation *op) {
beforePassFingerPrints.erase(pass);
config->printAfterIfEnabled(pass, op, [&](raw_ostream &out) {
- out << formatv("// *** IR Dump After {0} Failed ***", pass->getName());
+ out << formatv("// -----// IR Dump After {0} Failed", pass->getName());
printIR(op, config->shouldPrintAtModuleScope(), out,
OpPrintingFlags().printGenericOpForm());
out << "\n\n";
diff --git a/mlir/test/Pass/ir-printing.mlir b/mlir/test/Pass/ir-printing.mlir
index 8616d6ff3f488..70b8eaff59991 100644
--- a/mlir/test/Pass/ir-printing.mlir
+++ b/mlir/test/Pass/ir-printing.mlir
@@ -15,52 +15,52 @@ func @bar() {
return
}
-// BEFORE: *** IR Dump Before{{.*}}CSE ***
+// BEFORE: // -----// IR Dump Before{{.*}}CSE //----- //
// BEFORE-NEXT: func @foo()
-// BEFORE: *** IR Dump Before{{.*}}CSE ***
+// BEFORE: // -----// IR Dump Before{{.*}}CSE //----- //
// BEFORE-NEXT: func @bar()
-// BEFORE-NOT: *** IR Dump Before{{.*}}Canonicalizer ***
-// BEFORE-NOT: *** IR Dump After
+// BEFORE-NOT: // -----// IR Dump Before{{.*}}Canonicalizer //----- //
+// BEFORE-NOT: // -----// IR Dump After
-// BEFORE_ALL: *** IR Dump Before{{.*}}CSE ***
+// BEFORE_ALL: // -----// IR Dump Before{{.*}}CSE //----- //
// BEFORE_ALL-NEXT: func @foo()
-// BEFORE_ALL: *** IR Dump Before{{.*}}Canonicalizer ***
+// BEFORE_ALL: // -----// IR Dump Before{{.*}}Canonicalizer //----- //
// BEFORE_ALL-NEXT: func @foo()
-// BEFORE_ALL: *** IR Dump Before{{.*}}CSE ***
+// BEFORE_ALL: // -----// IR Dump Before{{.*}}CSE //----- //
// BEFORE_ALL-NEXT: func @bar()
-// BEFORE_ALL: *** IR Dump Before{{.*}}Canonicalizer ***
+// BEFORE_ALL: // -----// IR Dump Before{{.*}}Canonicalizer //----- //
// BEFORE_ALL-NEXT: func @bar()
-// BEFORE_ALL-NOT: *** IR Dump After
+// BEFORE_ALL-NOT: // -----// IR Dump After
-// AFTER-NOT: *** IR Dump Before
-// AFTER: *** IR Dump After{{.*}}CSE ***
+// AFTER-NOT: // -----// IR Dump Before
+// AFTER: // -----// IR Dump After{{.*}}CSE //----- //
// AFTER-NEXT: func @foo()
-// AFTER: *** IR Dump After{{.*}}CSE ***
+// AFTER: // -----// IR Dump After{{.*}}CSE //----- //
// AFTER-NEXT: func @bar()
-// AFTER-NOT: *** IR Dump After{{.*}}Canonicalizer ***
+// AFTER-NOT: // -----// IR Dump After{{.*}}Canonicalizer //----- //
-// AFTER_ALL-NOT: *** IR Dump Before
-// AFTER_ALL: *** IR Dump After{{.*}}CSE ***
+// AFTER_ALL-NOT: // -----// IR Dump Before
+// AFTER_ALL: // -----// IR Dump After{{.*}}CSE //----- //
// AFTER_ALL-NEXT: func @foo()
-// AFTER_ALL: *** IR Dump After{{.*}}Canonicalizer ***
+// AFTER_ALL: // -----// IR Dump After{{.*}}Canonicalizer //----- //
// AFTER_ALL-NEXT: func @foo()
-// AFTER_ALL: *** IR Dump After{{.*}}CSE ***
+// AFTER_ALL: // -----// IR Dump After{{.*}}CSE //----- //
// AFTER_ALL-NEXT: func @bar()
-// AFTER_ALL: *** IR Dump After{{.*}}Canonicalizer ***
+// AFTER_ALL: // -----// IR Dump After{{.*}}Canonicalizer //----- //
// AFTER_ALL-NEXT: func @bar()
-// BEFORE_MODULE: *** IR Dump Before{{.*}}CSE *** ('func' operation: @foo)
+// BEFORE_MODULE: // -----// IR Dump Before{{.*}}CSE ('func' operation: @foo) //----- //
// BEFORE_MODULE: func @foo()
// BEFORE_MODULE: func @bar()
-// BEFORE_MODULE: *** IR Dump Before{{.*}}CSE *** ('func' operation: @bar)
+// BEFORE_MODULE: // -----// IR Dump Before{{.*}}CSE ('func' operation: @bar) //----- //
// BEFORE_MODULE: func @foo()
// BEFORE_MODULE: func @bar()
-// AFTER_ALL_CHANGE: *** IR Dump After{{.*}}CSE ***
+// AFTER_ALL_CHANGE: // -----// IR Dump After{{.*}}CSE //----- //
// AFTER_ALL_CHANGE-NEXT: func @foo()
-// AFTER_ALL_CHANGE-NOT: *** IR Dump After{{.*}}CSE ***
+// AFTER_ALL_CHANGE-NOT: // -----// IR Dump After{{.*}}CSE //----- //
// We expect that only 'foo' changed during CSE, and the second run of CSE did
// nothing.
-// AFTER_FAILURE-NOT: *** IR Dump After{{.*}}CSE
-// AFTER_FAILURE: *** IR Dump After{{.*}}TestFailurePass Failed ***
+// AFTER_FAILURE-NOT: // -----// IR Dump After{{.*}}CSE
+// AFTER_FAILURE: // -----// IR Dump After{{.*}}TestFailurePass Failed //----- //
diff --git a/mlir/test/Pass/run-reproducer.mlir b/mlir/test/Pass/run-reproducer.mlir
index af36c5bb65f20..d1decfa0cc176 100644
--- a/mlir/test/Pass/run-reproducer.mlir
+++ b/mlir/test/Pass/run-reproducer.mlir
@@ -14,9 +14,9 @@ func @bar() {
return
}
-// BEFORE: *** IR Dump Before{{.*}}CSE ***
+// BEFORE: // -----// IR Dump Before{{.*}}CSE //----- //
// BEFORE-NEXT: func @foo()
-// BEFORE: *** IR Dump Before{{.*}}CSE ***
+// BEFORE: // -----// IR Dump Before{{.*}}CSE //----- //
// BEFORE-NEXT: func @bar()
-// BEFORE-NOT: *** IR Dump Before{{.*}}Canonicalizer ***
-// BEFORE-NOT: *** IR Dump After
+// BEFORE-NOT: // -----// IR Dump Before{{.*}}Canonicalizer //----- //
+// BEFORE-NOT: // -----// IR Dump After
More information about the Mlir-commits
mailing list