[llvm] 2b5a164 - UpdateTestChecks: fix handling of UTC with spaces

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 7 09:25:47 PST 2022


Author: Roman Lebedev
Date: 2022-03-07T20:25:23+03:00
New Revision: 2b5a16420f37d74a7e7e1c367356a5749d5a3c2e

URL: https://github.com/llvm/llvm-project/commit/2b5a16420f37d74a7e7e1c367356a5749d5a3c2e
DIFF: https://github.com/llvm/llvm-project/commit/2b5a16420f37d74a7e7e1c367356a5749d5a3c2e.diff

LOG: UpdateTestChecks: fix handling of UTC with spaces

We can't just split by space, that's not going to give us the same
argv we'd have gotten from the shell, it could be in a string,
we must actually parse that as argv.

Added: 
    llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter-with-spaces.ll
    llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter-with-spaces.ll.filter.expected
    llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/filter-with-spaces.test

Modified: 
    llvm/utils/UpdateTestChecks/common.py

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter-with-spaces.ll b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter-with-spaces.ll
new file mode 100644
index 0000000000000..ff8e748e800ca
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter-with-spaces.ll
@@ -0,0 +1,9 @@
+; RUN: opt < %s -passes='print<cost-model>' -mtriple=x86_64-pc-linux-gnu 2>&1 -disable-output -mattr=+sse2 | FileCheck %s --check-prefixes=SSE2
+
+define void @replication_i64_stride2() nounwind {
+  %vf2 = shufflevector <2 x i64> undef, <2 x i64> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
+  %vf4 = shufflevector <4 x i64> undef, <4 x i64> poison, <8 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3>
+  %vf8 = shufflevector <8 x i64> undef, <8 x i64> poison, <16 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6, i32 7, i32 7>
+  %vf16 = shufflevector <16 x i64> undef, <16 x i64> poison, <32 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6, i32 7, i32 7, i32 8, i32 8, i32 9, i32 9, i32 10, i32 10, i32 11, i32 11, i32 12, i32 12, i32 13, i32 13, i32 14, i32 14, i32 15, i32 15>
+  ret void
+}

diff  --git a/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter-with-spaces.ll.filter.expected b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter-with-spaces.ll.filter.expected
new file mode 100644
index 0000000000000..d40cedf7ef228
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/Inputs/x86-filter-with-spaces.ll.filter.expected
@@ -0,0 +1,13 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --filter "vf4 ="
+; RUN: opt < %s -passes='print<cost-model>' -mtriple=x86_64-pc-linux-gnu 2>&1 -disable-output -mattr=+sse2 | FileCheck %s --check-prefixes=SSE2
+
+define void @replication_i64_stride2() nounwind {
+; SSE2-LABEL: 'replication_i64_stride2'
+; SSE2:  Cost Model: Found an estimated cost of 18 for instruction: %vf4 = shufflevector <4 x i64> undef, <4 x i64> poison, <8 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3>
+;
+  %vf2 = shufflevector <2 x i64> undef, <2 x i64> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
+  %vf4 = shufflevector <4 x i64> undef, <4 x i64> poison, <8 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3>
+  %vf8 = shufflevector <8 x i64> undef, <8 x i64> poison, <16 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6, i32 7, i32 7>
+  %vf16 = shufflevector <16 x i64> undef, <16 x i64> poison, <32 x i32> <i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6, i32 7, i32 7, i32 8, i32 8, i32 9, i32 9, i32 10, i32 10, i32 11, i32 11, i32 12, i32 12, i32 13, i32 13, i32 14, i32 14, i32 15, i32 15>
+  ret void
+}

diff  --git a/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/filter-with-spaces.test b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/filter-with-spaces.test
new file mode 100644
index 0000000000000..6761b280e180c
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_analyze_test_checks/filter-with-spaces.test
@@ -0,0 +1,13 @@
+# REQUIRES: x86-registered-target
+
+## Check that --filter works properly.
+# RUN: cp -f %S/Inputs/x86-filter-with-spaces.ll %t.ll && %update_analyze_test_checks --filter="vf4 =" %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/x86-filter-with-spaces.ll.filter.expected
+
+## Check that running the script again does not change the result:
+# RUN: %update_analyze_test_checks --filter="vf4 =" %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/x86-filter-with-spaces.ll.filter.expected
+
+## Check that running the script again, without arguments, does not change the result:
+# RUN: %update_analyze_test_checks %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/x86-filter-with-spaces.ll.filter.expected

diff  --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 38a0fd12625f4..9745e60bc45ea 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -7,6 +7,7 @@
 import re
 import subprocess
 import sys
+import shlex
 
 ##### Common utilities for update_*test_checks.py
 
@@ -1072,7 +1073,7 @@ def get_autogennote_suffix(parser, args):
 def check_for_command(line, parser, args, argv, argparse_callback):
     cmd_m = UTC_ARGS_CMD.match(line)
     if cmd_m:
-        for option in cmd_m.group('cmd').strip().split(' '):
+        for option in shlex.split(cmd_m.group('cmd').strip()):
             if option:
                 argv.append(option)
         args = parser.parse_args(filter(lambda arg: arg not in args.tests, argv))


        


More information about the llvm-commits mailing list