[llvm] update_test_checks: collect original check lines for old versions of lit tests (PR #111148)

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 06:02:32 PDT 2024


https://github.com/nhaehnle created https://github.com/llvm/llvm-project/pull/111148

Old versions of UTC produced function labels like:

    ; CHECK-LABEL: @func(

Fix the regular expression used when scanning for old check lines to recognizes this form of label.

This allows meta variable stability to apply when running UTC on tests using this form of label.

Reported-by: Nikita Popov <npopov at redhat.com>

>From 4859c951b5b9a9b294bae228dcfeccf8e16e19ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= <nicolai.haehnle at amd.com>
Date: Fri, 4 Oct 2024 14:51:59 +0200
Subject: [PATCH] update_test_checks: collect original check lines for old
 versions of lit tests

Old versions of UTC produced function labels like:

    ; CHECK-LABEL: @func(

Fix the regular expression used when scanning for old check lines to
recognizes this form of label.

This allows meta variable stability to apply when running UTC on tests
using this form of label.

Reported-by: Nikita Popov <npopov at redhat.com>
---
 .../update_test_checks/Inputs/stable_ir_values2.ll         | 7 +++----
 .../Inputs/stable_ir_values2.ll.expected                   | 7 +++----
 llvm/utils/UpdateTestChecks/common.py                      | 5 ++++-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll
index d05c26241f87c1..c6ccaa4f450762 100644
--- a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll
@@ -1,10 +1,9 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -S | FileCheck %s
 
 define i32 @func(i32 %x) {
-; CHECK-LABEL: define i32 @func(
-; CHECK-SAME: i32 [[X:%.*]]) {
-; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i32 [[X]], 0
+; CHECK-LABEL: @func(
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i32 [[X:.*]], 0
 ; CHECK-NEXT:    [[TMP2:%.*]] = call i32 @foo(i1 [[TMP1]])
 ; CHECK-NEXT:    [[TMP3:%.*]] = icmp eq i32 [[X]], 1
 ; CHECK-NEXT:    [[TMP4:%.*]] = call i32 @foo(i1 [[TMP3]])
diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll.expected
index 6311a55a1f9de1..d5d2eb71ac5656 100644
--- a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll.expected
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll.expected
@@ -1,10 +1,9 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -S | FileCheck %s
 
 define i32 @func(i32 %x) {
-; CHECK-LABEL: define i32 @func(
-; CHECK-SAME: i32 [[X:%.*]]) {
-; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i32 [[X]], 0
+; CHECK-LABEL: @func(
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i32 [[X:%.*]], 0
 ; CHECK-NEXT:    [[TMP6:%.*]] = call i32 @foo(i1 [[TMP1]])
 ; CHECK-NEXT:    [[TMP7:%.*]] = icmp eq i32 [[X]], 2
 ; CHECK-NEXT:    [[TMP8:%.*]] = call i32 @foo(i1 [[TMP7]])
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 759fc5d7a43aa2..8ed600e5629e96 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -454,7 +454,7 @@ def collect_original_check_lines(ti: TestInfo, prefix_set: set):
                     continue
 
                 if check_kind == "LABEL":
-                    m = IR_FUNCTION_RE.match(line)
+                    m = IR_FUNCTION_LABEL_RE.match(line)
                     if m is not None:
                         func_name = m.group(1)
                         if (
@@ -572,6 +572,9 @@ def invoke_tool(exe, cmd_args, ir, preprocess_cmd=None, verbose=False):
 )
 
 IR_FUNCTION_RE = re.compile(r'^\s*define\s+(?:internal\s+)?[^@]*@"?([\w.$-]+)"?\s*\(')
+IR_FUNCTION_LABEL_RE = re.compile(
+    r'^\s*(?:define\s+(?:internal\s+)?[^@]*)?@"?([\w.$-]+)"?\s*\('
+)
 TRIPLE_IR_RE = re.compile(r'^\s*target\s+triple\s*=\s*"([^"]+)"$')
 TRIPLE_ARG_RE = re.compile(r"-m?triple[= ]([^ ]+)")
 MARCH_ARG_RE = re.compile(r"-march[= ]([^ ]+)")



More information about the llvm-commits mailing list