aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2023-11-23 05:34:05 +0100
committerNicolai Hähnle <nicolai.haehnle@amd.com>2024-03-08 03:58:11 +0100
commit448419007e1bb8a9e2edfe2c1c87fef6d104442a (patch)
treec3407255eb3db13bed26b1a5e53184f2b95f760e /llvm
parenta4703e5bccc63eca45e0e4bff8f04f82d8622ebe (diff)
downloadllvm-448419007e1bb8a9e2edfe2c1c87fef6d104442a.zip
llvm-448419007e1bb8a9e2edfe2c1c87fef6d104442a.tar.gz
llvm-448419007e1bb8a9e2edfe2c1c87fef6d104442a.tar.bz2
update_test_checks: precommit a test case
The test case demonstrates how meta variables are needlessly renamed, making diffs harder to read.
Diffstat (limited to 'llvm')
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values.ll22
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values.ll.expected23
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll30
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values2.ll.expected26
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values3.ll38
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values3.ll.expected38
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values4.ll41
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/stable_ir_values4.ll.expected42
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values.test2
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values2.test2
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values3.test2
-rw-r--r--llvm/test/tools/UpdateTestChecks/update_test_checks/stable_ir_values4.test2
12 files changed, 268 insertions, 0 deletions
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 0000000..8457bf7
--- /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 diffs 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 0000000..5142e3e
--- /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 diffs 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 0000000..d05c262
--- /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 0000000..53f60bd
--- /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 0000000..3b44929
--- /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 0000000..3d0f772
--- /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 0000000..e3d8452
--- /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 0000000..5962bda
--- /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 0000000..c6287a6
--- /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 0000000..3cebcd5
--- /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 0000000..83bc801
--- /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 0000000..89f252f
--- /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