[llvm] update_test_checks: keep meta variables stable by default (PR #76748)

Jannik Silvanus via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 07:51:29 PST 2024


Nicolai =?utf-8?q?Hähnle?= <nicolai.haehnle at amd.com>,
Nicolai =?utf-8?q?Hähnle?= <nicolai.haehnle at amd.com>,
Nicolai =?utf-8?q?Hähnle?= <nicolai.haehnle at amd.com>,
Nicolai =?utf-8?q?Hähnle?= <nicolai.haehnle at amd.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/76748 at github.com>


================
@@ -410,6 +412,42 @@ def should_add_line_to_output(
     return True
 
 
+def collect_original_check_lines(original_check_lines, ti: TestInfo, prefix_set: set):
+    """
+    Collect pre-existing check lines in a the dictionary original_check_lines.
+    original_check_lines[func_name][prefix] is filled with a list of
+    right-hand-sides of check lines.
+    """
+    in_function_start = None
+    for input_line_info in ti.ro_iterlines():
+        input_line = input_line_info.line
+        if in_function_start is not None:
+            if input_line == "":
+                continue
+            if input_line.lstrip().startswith(";"):
+                m = CHECK_RE.match(input_line)
+                if (
+                    m is not None
+                    and m.group(1) in prefix_set
+                    and m.group(2) not in ["LABEL", "SAME"]
+                ):
+                    if m.group(1) not in in_function_start:
+                        in_function_start[m.group(1)] = []
+                    in_function_start[m.group(1)].append(
+                        input_line[m.span()[1] :].strip()
+                    )
+                continue
+            in_function_start = None
+
+        m = IR_FUNCTION_RE.match(input_line)
+        if m is not None:
+            func_name = m.group(1)
+            if ti.args.function is not None and func_name != ti.args.function:
+                # When filtering on a specific function, skip all others.
+                continue
+
+            in_function_start = original_check_lines[func_name] = {}
----------------
jasilvanus wrote:

Maybe `assert func_name not in original_check_lines`?

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


More information about the llvm-commits mailing list