The GenericOp printer should support malformed IR without crashing
GitHub issue #59529
Differential Revision: https://reviews.llvm.org/D142818
/// represented as a string prefixed with '@'. The reference is surrounded with
/// ""'s and escaped if it has any special or non-printable characters in it.
static void printSymbolReference(StringRef symbolRef, raw_ostream &os) {
- assert(!symbolRef.empty() && "expected valid symbol reference");
+ if (symbolRef.empty()) {
+ os << "@<<INVALID EMPTY SYMBOL>>";
+ return;
+ }
os << '@';
printKeywordOrString(symbolRef, os);
}