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

Hanchenng Wu llvmlistbot at llvm.org
Mon Oct 6 13:51:31 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";
----------------
HanchengWu wrote:

Hi, 
Thanks for the catch! We eventually figured out how to make verbose 2 fast, and removed verbose 1 option.

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


More information about the Mlir-commits mailing list