Add support for operands to the return instructions, enhance verifier to report errors through the diagnostics system when invoked by the parser. It doesn't have perfect location info, but it is close enough to be testable.
PiperOrigin-RevId: 205534392
diff --git a/lib/IR/AsmPrinter.cpp b/lib/IR/AsmPrinter.cpp
index ff6ce3e..d811223 100644
--- a/lib/IR/AsmPrinter.cpp
+++ b/lib/IR/AsmPrinter.cpp
@@ -715,7 +715,19 @@
void CFGFunctionPrinter::print(const BranchInst *inst) {
os << " br bb" << getBBID(inst->getDest());
}
-void CFGFunctionPrinter::print(const ReturnInst *inst) { os << " return"; }
+void CFGFunctionPrinter::print(const ReturnInst *inst) {
+ os << " return";
+
+ if (inst->getNumOperands() != 0)
+ os << ' ';
+
+ // TODO: Use getOperands() when we have it.
+ interleaveComma(inst->getInstOperands(), [&](const InstOperand &operand) {
+ printValueID(operand.get());
+ os << " : ";
+ ModulePrinter::print(operand.get()->getType());
+ });
+}
void ModulePrinter::print(const CFGFunction *fn) {
CFGFunctionPrinter(fn, *this).print();