[Mlir-commits] [mlir] [mlir][tblgen] Adds support for embedded LIT tests in TableGen records (PR #158017)

Kshitij Jain llvmlistbot at llvm.org
Mon Sep 22 10:27:53 PDT 2025


================
@@ -0,0 +1,65 @@
+// RUN: mlir-tblgen -gen-lit-tests -I %S/../../include -dialect=test %s | FileCheck %s
+
+include "mlir/Pass/PassBase.td"
+include "mlir/IR/Testable.td"
+
+def TestPassWithEmbeddedLitTests : Pass<"test-pass-with-embedded-lit-tests"> {
+  let summary = "pass summary";
+  let description = [{
+    Pass description
+  }];
+  
+  let tests = [
+    LitTest<
+      "lit_test_file_1.mlir", 
+      [{
+          func.func @test1() {
----------------
jkshtj wrote:

>>If it's the former then we'd always need the user to also specify the full "after" version of the IR.
>
>I don't quite get what is the "after" version in the context of the documentation?
>
>>    It seemed to me, from the comments, that there may be a third option of just generating a --verify-roundtrip test.
>
>Right.

Ok, I see the misalignment in our expectations now. 

You're primarily thinking about tests for operations while I started out with working on tests for passes. For operations, I agree that all we need are `--verify-roundtrip` tests. For passes however, I think it makes sense to have the user specify before/after IR snippets that we generate the tests from.

And I do like the idea of having the snippets be a part of the `description` field itself, so as to not introduce additional complications for documentation rendering. Let me take another shot at things based on the feedback.

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


More information about the Mlir-commits mailing list