Skip to content

Commit

Permalink
update_test_checks: collect original check lines for old versions of …
Browse files Browse the repository at this point in the history
…lit tests (#111148)

Old versions of UTC produced function labels like:

    ; CHECK-LABEL: @func(

Fix the regular expression used when scanning for old check lines to
recognize 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@redhat.com>
  • Loading branch information
nhaehnle authored Oct 4, 2024
1 parent bf488ed commit 9f3f76a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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]])
Expand Down
Original file line number Diff line number Diff line change
@@ -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]])
Expand Down
5 changes: 4 additions & 1 deletion llvm/utils/UpdateTestChecks/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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[= ]([^ ]+)")
Expand Down

0 comments on commit 9f3f76a

Please sign in to comment.