[Mlir-commits] [mlir] 9c40495 - [MLIR][NFC] Value print update for block arguments

Uday Bondhugula llvmlistbot at llvm.org
Tue Sep 15 22:18:30 PDT 2020


Author: Uday Bondhugula
Date: 2020-09-16T10:47:28+05:30
New Revision: 9c40495a35a2cac89dd72db54892d6bd7a2abf0d

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

LOG: [MLIR][NFC] Value print update for block arguments

Emit some more information when printing/dumping `Value`s of
`BlockArgument` kind. This is purely to help for debugging purposes.

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

Added: 
    

Modified: 
    mlir/lib/IR/AsmPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 3deb7b477bea..602138d3ada7 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -2359,16 +2359,18 @@ void Value::print(raw_ostream &os) {
   if (auto *op = getDefiningOp())
     return op->print(os);
   // TODO: Improve this.
-  assert(isa<BlockArgument>());
-  os << "<block argument>\n";
+  BlockArgument arg = this->cast<BlockArgument>();
+  os << "<block argument> of type '" << arg.getType()
+     << "' at index: " << arg.getArgNumber() << '\n';
 }
 void Value::print(raw_ostream &os, AsmState &state) {
   if (auto *op = getDefiningOp())
     return op->print(os, state);
 
   // TODO: Improve this.
-  assert(isa<BlockArgument>());
-  os << "<block argument>\n";
+  BlockArgument arg = this->cast<BlockArgument>();
+  os << "<block argument> of type '" << arg.getType()
+     << "' at index: " << arg.getArgNumber() << '\n';
 }
 
 void Value::dump() {


        


More information about the Mlir-commits mailing list