[Mlir-commits] [mlir] [MLIR] Add options to generate-runtime-verification to enable faster pass running (PR #160331)

Matthias Springer llvmlistbot at llvm.org
Fri Oct 3 00:10:44 PDT 2025


================
@@ -36,10 +44,47 @@ void GenerateRuntimeVerificationPass::runOnOperation() {
     ops.push_back(verifiableOp);
   });
 
+  // Create error message generator based on verboseLevel
+  auto errorMsgGenerator = [vLevel = verboseLevel.getValue()](
+                               Operation *op, StringRef msg) -> std::string {
+    std::string buffer;
+    llvm::raw_string_ostream stream(buffer);
+    OpPrintingFlags flags;
+    // We may generate a lot of error messages and so we need to ensure the
+    // printing is fast.
+    flags.elideLargeElementsAttrs();
+    flags.printGenericOpForm();
+    flags.skipRegions();
+    flags.useLocalScope();
+    stream << "ERROR: Runtime op verification failed\n";
+    if (vLevel == 2) {
+      // print full op including operand names, very expensive
+      op->print(stream, flags);
+      stream << "\n " << msg;
+    } else if (vLevel == 1) {
+      // print op name and operand types
+      stream << "Op: " << op->getName().getStringRef() << "\n";
----------------
matthias-springer wrote:

As we're generating a lot of output, I think it's worth to pick a shorter syntax. How about this (fits into one line and can be grepped easily):

```
"dialect.op_name"(...) : (operand types) -> (result_types)
```

Something along the lines of:
```
stream << op->getName().getStringRef() << "(...) : (";
llvm::interleaveComma(TypeRange(op->getOperands()), stream);
stream << ") -> ("
llvm::interleaveComma(TypeRange(op->getResultTypes()), stream);
stream << ")";
```


https://github.com/llvm/llvm-project/pull/160331


More information about the Mlir-commits mailing list