[PATCH] D93078: [utils] Fix UpdateTestChecks case where 2 runs differ for last label

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 10 16:42:37 PST 2020


mtrofin created this revision.
mtrofin added reviewers: sstefan1, pengfei, lebedev.ri.
Herald added a subscriber: arichardson.
mtrofin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Two RUN lines produce outputs that, each, have some common parts and
some different parts. The common parts are checked under label A. The
differing parts are associated to a function and checked under labels B
and C, respectivelly.
When build_function_body_dictionary is called for the first RUN line, it
will attribute the function body to labels A and C. When the second RUN
is passed to build_function_body_dictionary, it sees that the function
body under A is different from what it has. If in this second RUN line,
A were at the end of the prefixes list, A's body is still kept
associated with the first run's function.

When we output the function body (i.e. add_checks), we stop after
emitting for the first prefix matching that function. So we end up with
the wrong function body (first RUN's A-association).

There is no reason to special-case the last label in the prefixes list,
and the fix is to always clear a label association if we find a RUN line
where the body is different.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93078

Files:
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-1.ll
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-2.ll
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test
  llvm/utils/UpdateTestChecks/common.py


Index: llvm/utils/UpdateTestChecks/common.py
===================================================================
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -293,11 +293,8 @@
             func_dict[prefix][func].args_and_sig = args_and_sig
             continue
           else:
-            if prefix == prefixes[-1]:
-              warn('Found conflicting asm under the same prefix: %r!' % (prefix,))
-            else:
-              func_dict[prefix][func] = None
-              continue
+            func_dict[prefix][func] = None
+            continue
 
       func_dict[prefix][func] = function_body(scrubbed_body, scrubbed_extra, args_and_sig, attrs)
       func_order[prefix].append(func)
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test
@@ -0,0 +1,14 @@
+# REQUIRES: x86-registered-target
+
+# RUN: cp -f %S/Inputs/common-label-different-bodies-1.ll %t-1.ll
+# RUN: cp -f %S/Inputs/common-label-different-bodies-2.ll %t-2.ll
+# RUN: cp -f %S/Inputs/common-label-different-bodies-3.ll %t-3.ll
+# RUN: %update_llc_test_checks %t-1.ll
+# RUN: %update_llc_test_checks %t-2.ll
+# RUN: %update_llc_test_checks %t-3.ll
+# RUN: FileCheck --input-file=%t-1.ll %s
+# RUN: FileCheck --input-file=%t-2.ll %s
+# RUN: FileCheck --input-file=%t-3.ll %s
+
+# CHECK: B-LABEL: fold_v2i64
+# CHECK-NOT: A-LABEL: fold_v2i64
\ No newline at end of file
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -mattr=+sse2 | FileCheck %s --check-prefixes=A,B
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=A,C
+
+declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+; A: declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+
+define <2 x i64> @fold_v2i64() {
+entry:
+  %r = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> <i64 255, i64 -1>)
+  ret <2 x i64> %r
+}
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-2.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-2.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -mattr=+sse2 | FileCheck %s --check-prefixes=A,B
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=C,A
+
+declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+; A: declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+
+define <2 x i64> @fold_v2i64() {
+entry:
+  %r = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> <i64 255, i64 -1>)
+  ret <2 x i64> %r
+}
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-1.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-1.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -mattr=+sse2 | FileCheck %s --check-prefixes=A,B
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --allow-unused-prefixes=true --check-prefixes=C,A,UNUSED
+
+declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+; A: declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+
+define <2 x i64> @fold_v2i64() {
+entry:
+  %r = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> <i64 255, i64 -1>)
+  ret <2 x i64> %r
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93078.311066.patch
Type: text/x-patch
Size: 3840 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201211/fe2f63a1/attachment.bin>


More information about the llvm-commits mailing list