Commit 88000477 authored by River Riddle's avatar River Riddle
Browse files

[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
parent c42dd5db
......@@ -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";
......
......@@ -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 //----- //
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment