[llvm] 4484190 - update_test_checks: precommit a test case

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 18:58:48 PST 2024


Author: Nicolai Hähnle
Date: 2024-03-08T03:58:11+01:00
New Revision: 448419007e1bb8a9e2edfe2c1c87fef6d104442a

URL: https://github.com/llvm/llvm-project/commit/448419007e1bb8a9e2edfe2c1c87fef6d104442a
DIFF: https://github.com/llvm/llvm-project/commit/448419007e1bb8a9e2edfe2c1c87fef6d104442a.diff

LOG: update_test_checks: precommit a test case

The test case demonstrates how meta variables are needlessly renamed,
making diffs harder to read.

Added: 
    llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values.ll
    llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values.ll.expected
    llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll
    llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll.expected
    llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values3.ll
    llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values3.ll.expected
    llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values4.ll
    llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values4.ll.expected
    llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values.test
    llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values2.test
    llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values3.test
    llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values4.test

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values.ll b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values.ll
new file mode 100644
index 00000000000000..8457bf7dc40a2e
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values.ll
@@ -0,0 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
+; RUN: opt < %s -S | FileCheck %s
+
+; The assumption underlying this test is that there are pre-existing check lines
+; but something has changed, and we would like to avoid needless changes of
+; meta variable names so that 
diff s end up being easier to read, e.g. avoid
+; changing X_I33 into X_I34 or renumbering the various TMP variables.
+
+define i32 @func({i32, i32} %x, i32 %y) {
+; CHECK-LABEL: define i32 @func(
+; CHECK-SAME: { i32, i32 } [[X:%.*]], i32 [[Y:%.*]]) {
+; CHECK-NEXT:    [[X_I33:%.*]] = extractvalue { i32, i32 } [[X]], 0
+; CHECK-NEXT:    [[TMP1:%.*]] = add i32 [[X_I33]], [[Y]]
+; CHECK-NEXT:    [[TMP2:%.*]] = mul i32 [[TMP1]], 3
+; CHECK-NEXT:    ret i32 [[TMP2]]
+;
+  %x.i34 = extractvalue {i32, i32} %x, 0
+  %1 = add i32 %y, 1
+  %2 = add i32 %x.i34, %1
+  %3 = mul i32 %2, 3
+  ret i32 %3
+}

diff  --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values.ll.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values.ll.expected
new file mode 100644
index 00000000000000..5142e3ed32ba45
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values.ll.expected
@@ -0,0 +1,23 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
+; RUN: opt < %s -S | FileCheck %s
+
+; The assumption underlying this test is that there are pre-existing check lines
+; but something has changed, and we would like to avoid needless changes of
+; meta variable names so that 
diff s end up being easier to read, e.g. avoid
+; changing X_I33 into X_I34 or renumbering the various TMP variables.
+
+define i32 @func({i32, i32} %x, i32 %y) {
+; CHECK-LABEL: define i32 @func(
+; CHECK-SAME: { i32, i32 } [[X:%.*]], i32 [[Y:%.*]]) {
+; CHECK-NEXT:    [[X_I34:%.*]] = extractvalue { i32, i32 } [[X]], 0
+; CHECK-NEXT:    [[TMP1:%.*]] = add i32 [[Y]], 1
+; CHECK-NEXT:    [[TMP2:%.*]] = add i32 [[X_I34]], [[TMP1]]
+; CHECK-NEXT:    [[TMP3:%.*]] = mul i32 [[TMP2]], 3
+; CHECK-NEXT:    ret i32 [[TMP3]]
+;
+  %x.i34 = extractvalue {i32, i32} %x, 0
+  %1 = add i32 %y, 1
+  %2 = add i32 %x.i34, %1
+  %3 = mul i32 %2, 3
+  ret i32 %3
+}

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
new file mode 100644
index 00000000000000..d05c26241f87c1
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll
@@ -0,0 +1,30 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
+; 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-NEXT:    [[TMP2:%.*]] = call i32 @foo(i1 [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = icmp eq i32 [[X]], 1
+; CHECK-NEXT:    [[TMP4:%.*]] = call i32 @foo(i1 [[TMP3]])
+; CHECK-NEXT:    [[TMP5:%.*]] = icmp ne i32 [[TMP4]], 0
+; CHECK-NEXT:    [[TMP6:%.*]] = select i1 [[TMP5]], i32 [[TMP4]], i32 [[TMP2]]
+; CHECK-NEXT:    [[TMP7:%.*]] = icmp eq i32 [[X]], 2
+; CHECK-NEXT:    [[TMP8:%.*]] = call i32 @foo(i1 [[TMP7]])
+; CHECK-NEXT:    [[TMP9:%.*]] = icmp ne i32 [[TMP8]], 0
+; CHECK-NEXT:    [[TMP10:%.*]] = select i1 [[TMP9]], i32 [[TMP8]], i32 [[TMP6]]
+; CHECK-NEXT:    ret i32 [[TMP10]]
+;
+  %1 = icmp eq i32 %x, 0
+  %2 = call i32 @foo(i1 %1)
+
+  %3 = icmp eq i32 %x, 2
+  %4 = call i32 @foo(i1 %3)
+  %5 = icmp ne i32 %4, 0
+  %6 = select i1 %5, i32 %4, i32 %2
+
+  ret i32 %6
+}
+
+declare i32 @foo(i1)

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
new file mode 100644
index 00000000000000..53f60bda8ee591
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll.expected
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
+; 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-NEXT:    [[TMP2:%.*]] = call i32 @foo(i1 [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = icmp eq i32 [[X]], 2
+; CHECK-NEXT:    [[TMP4:%.*]] = call i32 @foo(i1 [[TMP3]])
+; CHECK-NEXT:    [[TMP5:%.*]] = icmp ne i32 [[TMP4]], 0
+; CHECK-NEXT:    [[TMP6:%.*]] = select i1 [[TMP5]], i32 [[TMP4]], i32 [[TMP2]]
+; CHECK-NEXT:    ret i32 [[TMP6]]
+;
+  %1 = icmp eq i32 %x, 0
+  %2 = call i32 @foo(i1 %1)
+
+  %3 = icmp eq i32 %x, 2
+  %4 = call i32 @foo(i1 %3)
+  %5 = icmp ne i32 %4, 0
+  %6 = select i1 %5, i32 %4, i32 %2
+
+  ret i32 %6
+}
+
+declare i32 @foo(i1)

diff  --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values3.ll b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values3.ll
new file mode 100644
index 00000000000000..3b449291d0e7f8
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values3.ll
@@ -0,0 +1,38 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
+; RUN: opt < %s -S | FileCheck %s
+
+; Test that we don't regress 
diff  quality by trying to keep variable names
+; stable (and messing up the matching).
+
+define i32 @func(i32 %x) {
+; CHECK-LABEL: define i32 @func(
+; CHECK-SAME: i32 [[X:%.*]]) {
+; 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]])
+; CHECK-NEXT:    [[TMP5:%.*]] = icmp ne i32 [[TMP4]], 0
+; CHECK-NEXT:    [[TMP6:%.*]] = select i1 [[TMP5]], i32 [[TMP4]], i32 [[TMP2]]
+; CHECK-NEXT:    [[TMP7:%.*]] = icmp eq i32 [[X]], 2
+; CHECK-NEXT:    [[TMP8:%.*]] = call i32 @foo(i1 [[TMP7]])
+; CHECK-NEXT:    [[TMP9:%.*]] = icmp ne i32 [[TMP8]], 0
+; CHECK-NEXT:    [[TMP10:%.*]] = select i1 [[TMP9]], i32 [[TMP8]], i32 [[TMP6]]
+; CHECK-NEXT:    ret i32 [[TMP10]]
+;
+  %1 = icmp eq i32 %x, 0
+  %2 = call i32 @foo(i1 %1)
+
+  %3 = icmp eq i32 %x, 2
+  %4 = call i32 @foo(i1 %3)
+  %5 = icmp ne i32 %4, 0
+  %6 = select i1 %5, i32 %4, i32 %2
+
+  %7 = icmp eq i32 %x, 1
+  %8 = call i32 @foo(i1 %7)
+  %9 = icmp ne i32 %8, 0
+  %10 = select i1 %9, i32 %8, i32 %6
+
+  ret i32 %10
+}
+
+declare i32 @foo(i1)

diff  --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values3.ll.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values3.ll.expected
new file mode 100644
index 00000000000000..3d0f772505a659
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values3.ll.expected
@@ -0,0 +1,38 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
+; RUN: opt < %s -S | FileCheck %s
+
+; Test that we don't regress 
diff  quality by trying to keep variable names
+; stable (and messing up the matching).
+
+define i32 @func(i32 %x) {
+; CHECK-LABEL: define i32 @func(
+; CHECK-SAME: i32 [[X:%.*]]) {
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i32 [[X]], 0
+; CHECK-NEXT:    [[TMP2:%.*]] = call i32 @foo(i1 [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = icmp eq i32 [[X]], 2
+; CHECK-NEXT:    [[TMP4:%.*]] = call i32 @foo(i1 [[TMP3]])
+; CHECK-NEXT:    [[TMP5:%.*]] = icmp ne i32 [[TMP4]], 0
+; CHECK-NEXT:    [[TMP6:%.*]] = select i1 [[TMP5]], i32 [[TMP4]], i32 [[TMP2]]
+; CHECK-NEXT:    [[TMP7:%.*]] = icmp eq i32 [[X]], 1
+; CHECK-NEXT:    [[TMP8:%.*]] = call i32 @foo(i1 [[TMP7]])
+; CHECK-NEXT:    [[TMP9:%.*]] = icmp ne i32 [[TMP8]], 0
+; CHECK-NEXT:    [[TMP10:%.*]] = select i1 [[TMP9]], i32 [[TMP8]], i32 [[TMP6]]
+; CHECK-NEXT:    ret i32 [[TMP10]]
+;
+  %1 = icmp eq i32 %x, 0
+  %2 = call i32 @foo(i1 %1)
+
+  %3 = icmp eq i32 %x, 2
+  %4 = call i32 @foo(i1 %3)
+  %5 = icmp ne i32 %4, 0
+  %6 = select i1 %5, i32 %4, i32 %2
+
+  %7 = icmp eq i32 %x, 1
+  %8 = call i32 @foo(i1 %7)
+  %9 = icmp ne i32 %8, 0
+  %10 = select i1 %9, i32 %8, i32 %6
+
+  ret i32 %10
+}
+
+declare i32 @foo(i1)

diff  --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values4.ll b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values4.ll
new file mode 100644
index 00000000000000..e3d8452f963101
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values4.ll
@@ -0,0 +1,41 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
+; RUN: opt < %s -S | FileCheck %s
+
+; A test that hits the quadratic runtime prevention in the 
diff  algorithm and
+; a more complex case of name conflict avoidance.
+
+define i32 @func(i32 %x) {
+; CHECK-LABEL: define i32 @func(
+; CHECK-SAME: i32 [[X:%.*]]) {
+; CHECK-NEXT:    [[TMP1:%.*]] = mul i32 [[X]], 3
+; CHECK-NEXT:    [[TMP2:%.*]] = add i32 [[TMP1]], 4
+; CHECK-NEXT:    [[TMP3:%.*]] = call i32 @foo(i32 [[TMP2]])
+; CHECK-NEXT:    [[TMP4:%.*]] = call i32 @foo(i32 [[TMP3]])
+; CHECK-NEXT:    [[TMP5:%.*]] = call i32 @foo(i32 [[TMP4]])
+; CHECK-NEXT:    [[TMP6:%.*]] = call i32 @foo(i32 [[TMP5]])
+; CHECK-NEXT:    [[TMP7:%.*]] = call i32 @foo(i32 [[TMP6]])
+; CHECK-NEXT:    [[TMP8:%.*]] = call i32 @foo(i32 [[TMP7]])
+; CHECK-NEXT:    [[TMP9:%.*]] = call i32 @foo(i32 [[TMP8]])
+; CHECK-NEXT:    [[TMP10:%.*]] = call i32 @foo(i32 [[TMP9]])
+; CHECK-NEXT:    [[TMP11:%.*]] = call i32 @foo(i32 [[TMP10]])
+; CHECK-NEXT:    [[TMP12:%.*]] = call i32 @foo(i32 [[TMP11]])
+; CHECK-NEXT:    ret i32 [[TMP12]]
+;
+  %1 = mul i32 %x, 3
+  %2 = call i32 @foo(i32 %1)
+  %3 = call i32 @foo(i32 %2)
+  %4 = call i32 @foo(i32 %3)
+  %5 = call i32 @foo(i32 %4)
+  %6 = call i32 @foo(i32 %5)
+  %7 = call i32 @foo(i32 %6)
+  %8 = xor i32 %7, 1
+  %9 = call i32 @foo(i32 %8)
+  %10 = add i32 %9, 1
+  %11 = call i32 @foo(i32 %10)
+  %12 = call i32 @foo(i32 %11)
+  %13 = call i32 @foo(i32 %12)
+
+  ret i32 %13
+}
+
+declare i32 @foo(i1)

diff  --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values4.ll.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values4.ll.expected
new file mode 100644
index 00000000000000..5962bdafd9ea0a
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values4.ll.expected
@@ -0,0 +1,42 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
+; RUN: opt < %s -S | FileCheck %s
+
+; A test that hits the quadratic runtime prevention in the 
diff  algorithm and
+; a more complex case of name conflict avoidance.
+
+define i32 @func(i32 %x) {
+; CHECK-LABEL: define i32 @func(
+; CHECK-SAME: i32 [[X:%.*]]) {
+; CHECK-NEXT:    [[TMP1:%.*]] = mul i32 [[X]], 3
+; CHECK-NEXT:    [[TMP2:%.*]] = call i32 @foo(i32 [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = call i32 @foo(i32 [[TMP2]])
+; CHECK-NEXT:    [[TMP4:%.*]] = call i32 @foo(i32 [[TMP3]])
+; CHECK-NEXT:    [[TMP5:%.*]] = call i32 @foo(i32 [[TMP4]])
+; CHECK-NEXT:    [[TMP6:%.*]] = call i32 @foo(i32 [[TMP5]])
+; CHECK-NEXT:    [[TMP7:%.*]] = call i32 @foo(i32 [[TMP6]])
+; CHECK-NEXT:    [[TMP8:%.*]] = xor i32 [[TMP7]], 1
+; CHECK-NEXT:    [[TMP9:%.*]] = call i32 @foo(i32 [[TMP8]])
+; CHECK-NEXT:    [[TMP10:%.*]] = add i32 [[TMP9]], 1
+; CHECK-NEXT:    [[TMP11:%.*]] = call i32 @foo(i32 [[TMP10]])
+; CHECK-NEXT:    [[TMP12:%.*]] = call i32 @foo(i32 [[TMP11]])
+; CHECK-NEXT:    [[TMP13:%.*]] = call i32 @foo(i32 [[TMP12]])
+; CHECK-NEXT:    ret i32 [[TMP13]]
+;
+  %1 = mul i32 %x, 3
+  %2 = call i32 @foo(i32 %1)
+  %3 = call i32 @foo(i32 %2)
+  %4 = call i32 @foo(i32 %3)
+  %5 = call i32 @foo(i32 %4)
+  %6 = call i32 @foo(i32 %5)
+  %7 = call i32 @foo(i32 %6)
+  %8 = xor i32 %7, 1
+  %9 = call i32 @foo(i32 %8)
+  %10 = add i32 %9, 1
+  %11 = call i32 @foo(i32 %10)
+  %12 = call i32 @foo(i32 %11)
+  %13 = call i32 @foo(i32 %12)
+
+  ret i32 %13
+}
+
+declare i32 @foo(i1)

diff  --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values.test b/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values.test
new file mode 100644
index 00000000000000..c6287a6b29ca92
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values.test
@@ -0,0 +1,2 @@
+# RUN: cp -f %S/Inputs/stable_ir_values.ll %t.ll && %update_test_checks %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/stable_ir_values.ll.expected

diff  --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values2.test b/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values2.test
new file mode 100644
index 00000000000000..3cebcd52f00521
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values2.test
@@ -0,0 +1,2 @@
+# RUN: cp -f %S/Inputs/stable_ir_values2.ll %t.ll && %update_test_checks %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/stable_ir_values2.ll.expected

diff  --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values3.test b/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values3.test
new file mode 100644
index 00000000000000..83bc80128541f3
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values3.test
@@ -0,0 +1,2 @@
+# RUN: cp -f %S/Inputs/stable_ir_values3.ll %t.ll && %update_test_checks %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/stable_ir_values3.ll.expected

diff  --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values4.test b/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values4.test
new file mode 100644
index 00000000000000..89f252f8078064
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values4.test
@@ -0,0 +1,2 @@
+# RUN: cp -f %S/Inputs/stable_ir_values4.ll %t.ll && %update_test_checks %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/stable_ir_values4.ll.expected


        


More information about the llvm-commits mailing list