summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-12-05 17:46:37 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-12-05 17:47:03 -0800
commit12e57cf6c030a4d1a071ee668d17c5db169d98d6 (patch)
treecdd9ca9781f036d7750d869a5f74ee7c409f7206
parent71999ff7f2b23091d06f1306b844038d56c48ae9 (diff)
downloadbcm5719-llvm-12e57cf6c030a4d1a071ee668d17c5db169d98d6.tar.gz
bcm5719-llvm-12e57cf6c030a4d1a071ee668d17c5db169d98d6.zip
NFC: Add documentation for `-mlir-print-op-on-diagnostic` and `-mlir-print-stacktrace-on-diagnostic`.
This change adds proper documentation in Diagnostics.md, allowing for users to more easily find them. PiperOrigin-RevId: 284092336
-rw-r--r--mlir/g3doc/Diagnostics.md49
1 files changed, 49 insertions, 0 deletions
diff --git a/mlir/g3doc/Diagnostics.md b/mlir/g3doc/Diagnostics.md
index 457cab85932..0c6ef7a24fa 100644
--- a/mlir/g3doc/Diagnostics.md
+++ b/mlir/g3doc/Diagnostics.md
@@ -197,6 +197,55 @@ destroyed.
} // The diagnostic is automatically reported here.
```
+## Diagnostic Configuration Options
+
+Several options are provided to help control and enhance the behavior of
+diagnostics. These options are listed below:
+
+### Print Operation On Diagnostic
+
+Command Line Flag: `-mlir-print-op-on-diagnostic`
+
+When a diagnostic is emitted on an operation, via `Operation::emitError/...`,
+the textual form of that operation is printed and attached as a note to the
+diagnostic. This option is useful for understanding the current form of an
+operation that may be invalid, especially when debugging verifier failures. An
+example output is shown below:
+
+```shell
+test.mlir:3:3: error: 'module_terminator' op expects parent op 'module'
+ "module_terminator"() : () -> ()
+ ^
+test.mlir:3:3: note: see current operation: "module_terminator"() : () -> ()
+ "module_terminator"() : () -> ()
+ ^
+```
+
+### Print StackTrace On Diagnostic
+
+Command Line Flag: `-mlir-print-stacktrace-on-diagnostic`
+
+When a diagnostic is emitted, attach the current stack trace as a note to the
+diagnostic. This option is useful for understanding which part of the compiler
+generated certain diagnostics. An example output is shown below:
+
+```shell
+test.mlir:3:3: error: 'module_terminator' op expects parent op 'module'
+ "module_terminator"() : () -> ()
+ ^
+test.mlir:3:3: note: diagnostic emitted with trace:
+ #0 0x000055dd40543805 llvm::sys::PrintStackTrace(llvm::raw_ostream&) llvm/lib/Support/Unix/Signals.inc:553:11
+ #1 0x000055dd3f8ac162 emitDiag(mlir::Location, mlir::DiagnosticSeverity, llvm::Twine const&) /lib/IR/Diagnostics.cpp:292:7
+ #2 0x000055dd3f8abe8e mlir::emitError(mlir::Location, llvm::Twine const&) /lib/IR/Diagnostics.cpp:304:10
+ #3 0x000055dd3f998e87 mlir::Operation::emitError(llvm::Twine const&) /lib/IR/Operation.cpp:324:29
+ #4 0x000055dd3f99d21c mlir::Operation::emitOpError(llvm::Twine const&) /lib/IR/Operation.cpp:652:10
+ #5 0x000055dd3f96b01c mlir::OpTrait::HasParent<mlir::ModuleOp>::Impl<mlir::ModuleTerminatorOp>::verifyTrait(mlir::Operation*) /mlir/IR/OpDefinition.h:897:18
+ #6 0x000055dd3f96ab38 mlir::Op<mlir::ModuleTerminatorOp, mlir::OpTrait::ZeroOperands, mlir::OpTrait::ZeroResult, mlir::OpTrait::HasParent<mlir::ModuleOp>::Impl, mlir::OpTrait::IsTerminator>::BaseVerifier<mlir::OpTrait::HasParent<mlir::ModuleOp>::Impl<mlir::ModuleTerminatorOp>, mlir::OpTrait::IsTerminator<mlir::ModuleTerminatorOp> >::verifyTrait(mlir::Operation*) /mlir/IR/OpDefinition.h:1052:29
+ # ...
+ "module_terminator"() : () -> ()
+ ^
+```
+
## Common Diagnostic Handlers
To interface with the diagnostics infrastructure, users will need to register a
OpenPOWER on IntegriCloud