diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp --- a/mlir/lib/IR/Value.cpp +++ b/mlir/lib/IR/Value.cpp @@ -32,6 +32,11 @@ /// Return the type of this value. Type Value::getType() const { + // Support a null Value so the asmprinter doesn't crash on invalid IR (e.g. + // operations that have dropAllReferences() called on them). + if (!*this) + return Type(); + if (BlockArgument arg = dyn_cast()) return arg.getType();