[Mlir-commits] [mlir] a9bbbaa - [mlir] Elide large elements attrs when printing Operations in diagnostics

River Riddle llvmlistbot at llvm.org
Tue May 11 13:50:38 PDT 2021


Author: River Riddle
Date: 2021-05-11T13:50:27-07:00
New Revision: a9bbbaaa8810b22c9672694d576e3a0a210af54a

URL: https://github.com/llvm/llvm-project/commit/a9bbbaaa8810b22c9672694d576e3a0a210af54a
DIFF: https://github.com/llvm/llvm-project/commit/a9bbbaaa8810b22c9672694d576e3a0a210af54a.diff

LOG: [mlir] Elide large elements attrs when printing Operations in diagnostics

Diagnostics are intended to be read by users, and in most cases displayed in a terminal. When not eliding huge element attributes, in some cases we end up dumping hundreds of megabytes(gigabytes) to the terminal (or logs), completely obfuscating the main diagnostic being shown.

Differential Revision: https://reviews.llvm.org/D102272

Added: 
    

Modified: 
    mlir/lib/IR/Diagnostics.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp
index 8b3c485573b77..cb3799493972e 100644
--- a/mlir/lib/IR/Diagnostics.cpp
+++ b/mlir/lib/IR/Diagnostics.cpp
@@ -126,7 +126,7 @@ Diagnostic &Diagnostic::operator<<(OperationName val) {
 Diagnostic &Diagnostic::operator<<(Operation &val) {
   std::string str;
   llvm::raw_string_ostream os(str);
-  os << val;
+  val.print(os, OpPrintingFlags().useLocalScope().elideLargeElementsAttrs());
   return *this << os.str();
 }
 


        


More information about the Mlir-commits mailing list