[Mlir-commits] [mlir] [mlir] generate-test-checks.py does not double insert note. (PR #166443)
Michael Maitland
llvmlistbot at llvm.org
Tue Nov 4 12:58:31 PST 2025
https://github.com/michaelmaitland created https://github.com/llvm/llvm-project/pull/166443
When we generate test checks into the original test file (inplace), it was incorrectly removing empty lines.
I tested this by running
```
my-downstream-opt-tool file.mlir -mypass | python3 ~/llvm-project/mlir/utils/generate-test-checks.py --source file.mlir -i
```
>From f1fac1a6c8fd21f8c7121182dfd7d088905d0ca0 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaelmaitland at meta.com>
Date: Tue, 4 Nov 2025 12:40:50 -0800
Subject: [PATCH] [mlir] generate-test-checks.py does not double insert note.
When we generate test checks into the original test file (inplace), it
was incorrectly
---
mlir/utils/generate-test-checks.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/mlir/utils/generate-test-checks.py b/mlir/utils/generate-test-checks.py
index 3712a6b9c963d..aae0b14965cad 100755
--- a/mlir/utils/generate-test-checks.py
+++ b/mlir/utils/generate-test-checks.py
@@ -234,10 +234,17 @@ def process_source_lines(source_lines, note, args):
source_split_re = re.compile(args.source_delim_regex)
source_segments = [[]]
+ skip_next_empty_line = False
for line in source_lines:
# Remove previous note.
- if line in note:
+ if line and line in note:
+ skip_next_empty_line = True
continue
+ # Skip the first empty line after the note
+ if skip_next_empty_line and not line:
+ skip_next_empty_line = False
+ continue
+ skip_next_empty_line = False
# Remove previous CHECK lines.
if line.find(args.check_prefix) != -1:
continue
More information about the Mlir-commits
mailing list